Repository navigation
fix(browser): refuse web pages on the agent-browser CDP proxy - #27415
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
📥 Commits
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to 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 |
|
d03b168 to
7875a77
Compare
Co-authored-by: m4air <[email protected]> (cherry picked from commit 80d34c3)
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
src/main/browser/cdp-ws-proxy.ts) listened on127.0.0.1:<random port>and accepted any WebSocket handshake. It forwarded every DevTools command, includingRuntime.evaluateandNetwork.getAllCookies, to the tab's debugger. A new connection also kicked the agent's connection off. Its/json/versiondiscovery endpoint answered whateverHostthe request named.isTrustedCdpLoopbackRequest, gates both the HTTP discovery endpoints and the WebSocket handshake. Requests are refused with 403 if they carry anOriginheader (browsers always send one on a WebSocket handshake; CDP clients don't) or if theirHostis not127.0.0.1:<port>orlocalhost:<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/versionwith 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:/json/versionopen to DNS rebinding unless Host is checked, so the Host check is needed either way. The Origin check alone closes the web-page path.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.tsandcdp-ws-proxy-focus-replay.test.tspass (47 tests total). Thesrc/main/browsersuite passes apart from two manager test files that fail the same way on unmodified main.pnpm tc,oxlint,pnpm run check:code-quality:changedandpnpm lintpass.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
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
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)