fix(server): server browser input follows the preview control permission #16765
main fromrefs/pull/16765/head·opened View on GitHubProblem#
The server-side browser stream checks the wrong permission for page input and file uploads.
#9789 split browser preview control out of orchestration:operate into a new preview:operate permission, and moved every preview RPC to it (RpcAuthorization.ts, previewOpen through previewReportStatus). The server-side browser from #15328 merged about twelve hours before #9789, and its stream handler was not part of that change. ServerBrowserStream.ts still checks orchestration:operate:
- the stream websocket sets
canOperatefromsession.scopes.includes(AuthOrchestrationOperateScope), and drops all clicks, typing, scrolling and navigation input when it is false; POST /api/preview-stream/uploadauthenticates withAuthOrchestrationOperateScope.
So the two permissions disagree in both directions:
- A device paired with
orchestration:readandpreview:operate, but notorchestration:operate, can open and navigate a server-browser preview through the RPCs, but its input is silently ignored and its file uploads get a 403. - A device paired with
orchestration:operatebut deliberately notpreview:operatecannot open a preview, but can still click, type and upload files in an already open server-browser tab.
The default pairing scopes include both permissions, so this shows up with custom-scoped pairing links (t3 pair --scope ...), which is what #9789 made possible.
Change#
ServerBrowserStream.ts checks AuthPreviewOperateScope instead of AuthOrchestrationOperateScope in its two places: the stream's canOperate and the upload route. Viewing the stream and downloads still need only orchestration:read, and interactive=false still forces read-only. No client change is needed; the server decides interactivity.
Scope and approval#
A small, focused fix for an obvious regression: one file, two permission checks, plus tests. It makes the server-side browser follow the permission #9789 already introduced for every other preview action. It does not change default scopes or any behavior for sessions that have both permissions.
Verification#
Updated apps/server/src/preview/ServerBrowserStream.test.ts:
- The stream test now runs four cases: read only,
preview:operate,preview:operatewithinteractive=false, andorchestration:operatewithoutpreview:operate. Only thepreview:operateinteractive case forwards input. - The upload test now expects 403 for
orchestration:operatealone and 204 forpreview:operate.
vp test run apps/server/src/preview/ServerBrowserStream.test.ts
Without the fix: 3 of 11 tests fail (the preview:operate stream case, the orchestration:operate-only stream case, and the upload test). With the fix: 11 of 11 pass. Server typecheck (tsc --noEmit in apps/server) and lint on both files are clean.
Not checked: a manual run with a custom-scoped pairing link against a real server-browser tab. The tests use the real route handler with mocked authentication and a stub browser.
Found and fixed with Claude Opus 5.5 in Claude Code, running inside T3 Code. The bug was first flagged by GPT-6.1 Sol in Codex CLI.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
Pre-merge checks failed. Please resolve the failing checks before merging.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
92204caa-f0e2-4296-8aa6-08daa83db1cd
📥 Commits
Reviewing files that changed from the base of the PR and between b77108bc41506ad7ba28839d9a8e04ba79fe340b and 5d231d47ed9deabca4781d2d97bf0c737696bbc0.
📒 Files selected for processing (2)
apps/server/src/preview/ServerBrowserStream.test.tsapps/server/src/preview/ServerBrowserStream.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The preview WebSocket operation and file-chooser upload checks now use
AuthPreviewOperateScope. Tests cover the required scopes, interactive stream behavior, upload responses, and stale chooser IDs.Changes#
Preview authorization
Layer / File(s) Summary WebSocket operation authorization
apps/server/src/preview/ServerBrowserStream.ts,apps/server/src/preview/ServerBrowserStream.test.tsWebSocket operation requires preview-operate scope and an interactive stream. Tests cover read-only, preview-operate, non-interactive, and orchestration-operate-only sessions. File-chooser upload authorization
apps/server/src/preview/ServerBrowserStream.ts,apps/server/src/preview/ServerBrowserStream.test.tsUploads authenticate with preview-operate scope. Tests expect 403 for orchestration-operate-only access, 204 for preview-operate access, and 409 for a stale chooser. Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
maria-rcksMerge Risk: ⚪ Minimal · up to
5d231The preview-operation scope change is ready to merge after normal checks.
Security Architecture Review#
Security architecture risk: 🔵 Low · up to
5d231The change aligns browser input and uploads with preview-control permission while preserving read-only restrictions. No new vulnerability was demonstrated. Upload ownership and concurrent failure handling remain incompletely established.
Retained concerns No architecture-level concerns identified.
Security review details
Security Blast Radius
- inferred — The changed authority concerns server-browser state accessible to authenticated preview-authorized sessions: interactive page actions and client-supplied files delivered to an open chooser. Authorization is scope-based, with caller-supplied resource identifiers; the inspected code does not establish per-session ownership isolation. Existing preview RPC forwarding supports an environment-scoped authority interpretation, but the intended chooser-controller restriction remains unverified.
Trust Boundaries and Controls
- observed — Client-controlled interactivity and resource identifiers do not grant operation permission. The server derives permission from the authenticated session, blocks non-acknowledgement input when operation is disallowed, and checks preview:operate before accepting upload data. The inspected tests cover denied orchestration-operate-only access, allowed preview-operation access and non-interactive streams.
Resilience and Maintainability Implications
- observed — Viewer operations retain owner and generation checks before queued execution. Scoped disconnection releases viewer control and pressed input before removing the viewer, and capture-session cleanup remains registered. Chooser uploads use a separate direct path, so these viewer guarantees cannot be assumed to cover upload concurrency or interruption.
Hardening Proposals
- proposed — Explicitly define whether any preview-authorized session or only the current browser controller may answer a chooser. If controller-exclusive behavior is required, bind upload authorization and file application to that controller and its generation, including concurrent, interrupted and repeated requests.
Caution
Pre-merge checks failed#
Please resolve all errors before merging. Addressing warnings is optional.
- Ignore (reviewers only)
❌ Failed checks (1 error)#
Check name Status Explanation Resolution Approvability ❌ Error Fail under the rule “Changes authentication, pairing, credentials, secrets, or remote connection trust.” The diff changes access-control checks in apps/server/src/preview/ServerBrowserStream.ts: lin…This pull request needs a maintainer's review of the permission-gate changes before CodeRabbit approves it. ✅ Passed checks (4 passed)
Check name Status Explanation Title check ✅ Passed The title clearly summarizes the main change: server browser input now uses the preview control permission. Description check ✅ Passed The description covers the problem, change, scope and approval rationale, focused verification results, and the manual check that was not performed. Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request. Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request. Full details: Approvability
Explanation
Fail under the rule “Changes authentication, pairing, credentials, secrets, or remote connection trust.” The diff changes access-control checks in
apps/server/src/preview/ServerBrowserStream.ts: line 75 now gates stream input onAuthPreviewOperateScope, and line 239 requires that scope for uploads, replacingAuthOrchestrationOperateScope. This changes which authenticated sessions can control the preview and upload files. The other changed file only updates tests.- Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create a new PR
- Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.juliusmarminge added labelsmacroscope-review
Note
Written by
gpt-6.1-solon behalf of MariaThanks for identifying the preview permission mismatch. Both the stream input gate and upload authentication already use AuthPreviewOperateScope on main through #17772, so this defect is already fixed. We are closing the redundant change under the review-capacity guidance in Read this first. If a custom-scoped session still fails on current main, provide that reproduction and a focused remaining fix for reconsideration.
maria-rcks closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This is a focused fix aligning server-browser input and uploads with the preview-operation permission, with targeted tests and no default changes. It modifies a production access-control boundary for interactive browser actions and file uploads, so human review is warranted despite the small scope.
Notes:
- Diff unchanged. Approvability was decided on eligibility alone.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).