Repository navigation
Conversation
The per-tab CDP proxy bound 127.0.0.1:<random> and accepted any WebSocket connection, forwarding arbitrary CDP commands (Runtime.evaluate, cookie reads, navigation) to the tab's webContents. The HTTP /json discovery endpoints disclosed the debugger URL with no auth. Attacker-controlled web content in the built-in browser could discover the port and drive the debugger — full control of the tab's DOM/JS. Defense, matching Chrome's own CDP endpoint design: - Embed a 144-bit random token in the debugger URL path; reject WS upgrades that present the wrong/no token (timing-safe compare). - Reject any WS upgrade carrying a browser Origin header (the local agent-browser client never sends one; page JS always does). - Gate /json discovery behind a loopback Host check (DNS-rebinding defense) and reject Origin-bearing requests so it can't be used as a port oracle. Transparent to agent-browser, which discovers the tokenized URL via /json/version as a non-browser client (no Origin). Co-authored-by: Orca <[email protected]>
The cookie-import staging directory under userData held a full copy of the browser cookie database (session tokens). It was created with the default umask (world-readable dir + 0644 file) and, in the post-restart import handoff path, persists on disk across a restart. On a shared/multi-user machine another local account could read the staged cookies. Create the staging dir 0700 (and chmod it, since recursive mkdir leaves an existing dir's mode untouched) and the copied DB 0600. Co-authored-by: Orca <[email protected]>
3 of 5 tasks
8 of 9 tasks
Collaborator
|
Thanks for flagging the unauthenticated CDP proxy. The web-page path is now closed on main by #27415, which refuses handshakes and discovery requests that carry an Origin or a non-loopback Host, the same policy Chrome uses for its debugging port. |
Contributor
Author
8 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security scan + hardening (browser/CDP surface)
Ran a multi-agent security scan of Orca across 12 attack-surface dimensions
(Electron process model, IPC validation, command injection, path traversal,
network/socket auth, web+mobile pairing & RPC allowlist, secrets/credentials,
browser/CDP automation, web-content XSS/SSRF, SSH transport/relay deploy,
auto-updater/supply-chain, and protocol deserialization). Each candidate finding
was adversarially verified by two independent skeptics — a reachability lens
(can an untrusted party actually reach it?) and an exploit-correctness lens
(does the code really do the unsafe thing?) — calibrated for an ADE threat model
where local privileged execution (running shells, spawning agents) is by design.
Net result: the codebase is well-hardened (sandboxed renderer, fail-closed guest
webviews, token-authed sockets, E2EE + per-device-token pairing). This PR fixes
the confirmed real issue plus one adjacent local-secrets hardening gap.
Fix 1 — Authenticate the CDP debugger proxy (primary)
CdpWsProxy(one per browser tab, drivesagent-browser) bound127.0.0.1:<random>and accepted any WebSocket connection with no auth,forwarding arbitrary CDP commands (
Runtime.evaluate, cookie reads, navigation,screenshots) straight to the tab's
webContents.debugger. The HTTP/jsondiscovery endpoints disclosed the debugger URL unauthenticated.
Threat: attacker-controlled web content in the built-in browser is explicitly
untrusted. It could discover the proxy port and open a WebSocket to it, gaining
full control of the tab's DOM/JS — a privilege crossing.
Fix (mirrors how Chrome's own CDP endpoint defends itself):
with a missing/wrong token (timing-safe compare).
Originheader — the localagent-browserclient (native, non-browser) never sends one; page JS always does./jsondiscovery behind a loopbackHostcheck (DNS-rebinding defense)and reject
Origin-bearing requests, so it can't serve as a port oracle.Transparent to
agent-browser: it discovers the tokenizedwebSocketDebuggerUrlvia
/json/versionas a non-browser client (verified the bundled binary uses/jsondiscovery), then connects with the token in the path.Fix 2 — Restrict cookie-import staging file permissions
The cookie-import staging dir under
userDataheld a full copy of the browsercookie database (session tokens), created with the default umask
(world-readable dir +
0644file). In the post-restart import handoff path itpersists across a restart. On a shared/multi-user machine, another local
account could read the staged cookies.
Fix: create the staging dir
0700(andchmodit, since recursivemkdirleaves an existing dir's mode untouched) and the copied DB
0600.Found but intentionally NOT fixed here (recommended follow-ups)
buildConnectConfiginssh-connection-utils.ts): the in-processssh2transport sets nohostVerifier, so it accepts any host key (MITM-able on untrusted networks).A correct fix is a TOFU + key-mismatch UX feature (read
known_hosts,prompt on first connect / on mismatch, persist decisions) — too large and
product/UX-laden to land in a security patch. Worth a dedicated issue. (Note:
Orca also has a system-
sshfallback transport which uses the OSknown_hosts; the gap is specific to the in-processssh2path.)httpsorigin(
browser-webauthn-access.ts):isSecureBrowserOrigin()returns true forany
https://origin, so a FIDO HID device is auto-selected without a userpicker for arbitrary sites. Real-world impact is bounded by WebAuthn's
user-presence (physical touch) and RP-ID binding, and tightening it risks
breaking legitimate security-key login in the embedded browser — so it needs a
deliberate decision (account/device picker UX) rather than a blind behavior
change. Flagged for review.
Verified and dismissed (sample)
0.0.0.0pairing bind (gated by E2EE + 192-bit per-device tokens), pre-auth WSDoS (sockets reaped at 10s), grab-guest-script pre-poisoning, updater SSRF, and
relay-deploy MITM were all checked and found gated behind the trusted boundary or
existing crypto — not exploitable by an untrusted party.
Testing
vitest runoncdp-ws-proxy.test.ts(added 7 auth tests: token-gated WS,wrong/absent token, Origin rejection, loopback-Host and Origin gating on
/json, happy path) +browser-cookie-import.test.ts— 38 passing.agent-browser-bridge,cdp-bridge-integration,cdp-screenshot) — 86 passing.tsgotypecheck (node project) andoxlinton changed files — clean./electronsmoke test of live browser automation.🤖 Generated with Claude Code
Made with Orca 🐋