Skip to content

fix(browser): refuse web pages on the agent-browser CDP proxy - #27415

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/p0fix-cdp-proxy-origin
Oct 11, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/p0fix-cdp-proxy-origin

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26

ELI5

When an agent drives a tab in Orca's built-in browser, Orca opens a small local "remote control" port for that tab. Anything that could reach that port could take over the tab. That includes an ordinary web page, in the Orca browser or any other browser, that scans local ports. It could run code in the page or read every cookie in that browser profile, which includes cookies you imported from your real browser. Now the port only answers local automation tools, the same way Chrome's own debugging port does.

What Changed

  • Before: the per-tab CDP proxy (src/main/browser/cdp-ws-proxy.ts) listened on 127.0.0.1:<random port> and accepted any WebSocket handshake. It forwarded every DevTools command, including Runtime.evaluate and Network.getAllCookies, to the tab's debugger. A new connection also kicked the agent's connection off. Its /json/version discovery endpoint answered whatever Host the request named.
  • After: a new check, isTrustedCdpLoopbackRequest, gates both the HTTP discovery endpoints and the WebSocket handshake. Requests are refused with 403 if they carry an Origin header (browsers always send one on a WebSocket handshake; CDP clients don't) or if their Host is not 127.0.0.1:<port> or localhost:<port> (that would be a DNS-rebound page). A refused handshake never reaches the connection handler, so the agent's connection stays up.

Agents see no change. agent-browser finds the socket through /json/version with a loopback Host and sends no Origin, so its connection is accepted as before.

Why

This copies the policy Chrome applies to its own --remote-debugging-port, which rejects WebSocket handshakes that carry an Origin. Every CDP client that works against real Chrome therefore keeps working here. Alternatives considered:

  • An unguessable token in the socket path: that still leaves /json/version open to DNS rebinding unless Host is checked, so the Host check is needed either way. The Origin check alone closes the web-page path.
  • Authenticating the client with a shared secret (the approach in the earlier PR [Fable] security(browser): authenticate CDP proxy + restrict cookie-import staging perms #5035): this needs agent-browser to pass the secret, which it doesn't support. It is a bigger change for no extra protection against web pages.

A same-user local process can still connect. That is unchanged and in line with the rest of Orca's local-execution threat model.

Linked Issue

No issue was filed. This came out of a P0 sweep of open PRs: #5035 reported the unauthenticated proxy in June, and the gap is still present on main.

Visual Proof

N/A. This only changes which network requests the local proxy accepts, and nothing in the UI changes.

Testing

  • src/main/browser/cdp-ws-proxy-origin.test.ts (new) covers five cases. Four failed before the fix: a handshake with a web Origin is refused with 403, a handshake with a rebound Host is refused with 403, the automation client stays connected through a refused takeover, and discovery with a non-loopback Host is refused with 403. The fifth checks that loopback discovery still answers 200.

  • The existing cdp-ws-proxy.test.ts and cdp-ws-proxy-focus-replay.test.ts pass (47 tests total). The src/main/browser suite passes apart from two manager test files that fail the same way on unmodified main.

  • pnpm tc, oxlint, pnpm run check:code-quality:changed and pnpm lint pass.

  • Tested on macOS. The change is platform-neutral Node HTTP/ws code, and SSH and mobile are not involved, because the proxy only ever binds to the desktop's own loopback address.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: closes a cross-origin path to cookie theft and page takeover. Cross-platform: no platform-specific code. Remote SSH and mobile: not affected. Backwards compatibility: CDP clients that send no Origin are unaffected. Performance: one header comparison per request.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f6c5ba5-6f16-4ea7-97d0-d875a3e75c7d

📥 Commits

Reviewing files that changed from the base of the PR and between d03b16874238dd3b5db0664a3861a8dc6a715f5b and 7875a77.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d6989b5-23f9-4f19-b659-dae9483f9fa2


📥 Commits

Reviewing files that changed from the base of the PR and between 0024735 and d03b16874238dd3b5db0664a3861a8dc6a715f5b.



📒 Files selected for processing (3)
  • src/main/browser/cdp-loopback-request-guard.ts
  • src/main/browser/cdp-ws-proxy-origin.test.ts
  • src/main/browser/cdp-ws-proxy.ts


Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.




📝 Walkthrough
📝 Walkthrough

Walkthrough

The proxy now checks HTTP discovery requests and WebSocket upgrades with a loopback request guard. The guard rejects requests with an Origin header and accepts requests whose Host matches 127.0.0.1 or localhost at the configured port. The proxy returns 403 for rejected requests. Tests cover rejected and accepted requests, and verify that a rejected WebSocket upgrade does not disconnect the automation client.



Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to d03b1

The change blocks web pages from reaching the local CDP proxy while still allowing loopback automation clients that send no Origin header. No merge-blocking risk was identified.

Pre-merge checks | Passed 3 | Failed 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check Warning The description explains the change, security rationale, testing, scope, and compatibility impact. However, the required Linked Issue section states that no issue was filed, which conflicts with the r… Add the actual linked issue reference under the Linked Issue section, for example by replacing Fixes # with the applicable issue number or URL.
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: refusing web-page access to the agent-browser CDP proxy.
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: Description check

Explanation

The description explains the change, security rationale, testing, scope, and compatibility impact. However, the required Linked Issue section states that no issue was filed, which conflicts with the repository template requiring an actual issue link.




✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR



  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrcaWin
OrcaWin force-pushed the OrcaWin/p0fix-cdp-proxy-origin branch from d03b168 to 7875a77 Compare October 11, 2026 08:23
@OrcaWin
OrcaWin merged commit 80d34c3 into main Oct 11, 2026
29 checks passed
brennanb2025 pushed a commit that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant