Repository navigation
fix(browse): close v20 ABE cookie exfiltration window via --remote-debugging-pipe - #1181
Closed
NewCoder3294 wants to merge 5 commits into
Closed
NewCoder3294 wants to merge 5 commits into
NewCoder3294 wants to merge 5 commits into
Conversation
Thin wrapper around two Node streams (Writable + Readable) that speaks CDP with NUL-byte-delimited JSON framing. Handles id-based request/ response correlation and error/close propagation. Not wired into anything yet; follow-up commits swap cookie-import's TCP CDP path to use this. Refs #1136.
Pipe-transport equivalent of extractCookiesViaCdp. Uses Target.getTargets + Target.attachToTarget(flatten: true) to acquire a page session over a single CDP pipe connection, then Network.getAllCookies. Still not wired into importCookiesViaCdp; next commit swaps the TCP path over. Refs #1136.
Spawns Chrome with --remote-debugging-pipe instead of --remote-debugging-port, closing the v20 ABE cookie exfiltration window where any same-user local process could connect to Chrome's debug port (in the 1-3s it's listening) and call Network.getAllCookies to read decrypted v20 cookies. Pipe transport is inherited by Chrome only; no TCP socket binds, no /json/list HTTP endpoint exists. Target discovery via Target.getTargets + Target.attachToTarget(flatten: true). Browser.getVersion replaces the old /json/version fetch for diagnostics. Uses node:child_process.spawn for the Chrome subprocess because Bun.spawn exposes fds >= 3 as raw numeric fds, not streams, and Node stream-to-Web bridges hang in Bun on those sockets. The non-CDP path (direct SQLite + DPAPI on v10/v11 cookies) is unchanged; this change only affects the Windows v20 ABE fallback. Closes #1136.
Adds an error listener on the Chrome child process. Without it, async
spawn failures (ENOENT, EACCES, antivirus interference) emit 'error'
with no handler and crash the parent process via Node's default
behavior. Errors surface via the transport's error path or the stdio
null-check guard.
Also tightens type casts at the CdpPipeTransport call site to reuse
the existing NodeWritable/NodeReadable aliases instead of inline
import('node:stream') references.
Refs #1136.
Three narrow robustness fixes flagged during review: 1. CdpPipeTransport.readStream 'end' handler now sets this.closed = true before aborting pending. Without this, a send() after end would queue a promise forever (the 'closed' guard wouldn't trigger). 2. extractCookiesViaCdpPipe guards cookiesResp.cookies with ?? [] so a CDP response missing the cookies field returns an empty array instead of throwing TypeError. 3. extractCookiesViaCdpPipe validates attached.sessionId is a non-empty string. flatten:true should always return one, but defensive guards beat silent fallback to the browser-level session. Three new tests lock each fix: - send-after-end rejects with cdp_error/closed - empty getAllCookies response returns [] - attachToTarget without sessionId throws cdp_error Refs #1136.
Contributor
|
@NewCoder3294 Rewrite the implementation to bound operations and prevent sends after terminal stream failures while retaining the listener removal. |
Contributor
|
The cookie-import transport implementation is superseded by merged #2964 (v1.90.0.0): the old TCP fallback is removed, and the replacement uses the Node/Playwright private-pipe path with owned-process supervision and bounded cleanup. Closing this alternative implementation without merging its branch. Native Windows encrypted extraction remains disabled by an empty qualification allowlist; #1136 stays open for its still-unmet Windows v20 import/qualification acceptance, not because the old TCP exposure remains. |
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.
Resolves #1136.
What changes
Swaps the cookie-import Windows v20 ABE fallback from
--remote-debugging-port(TCP, bindable by any same-user process during the 1-3s CDP window) to--remote-debugging-pipe(stdio pipes, inherited only by the spawning process). No TCP socket binds and no/json/listHTTP endpoint exists.CdpPipeTransportclass — NUL-delimited JSON framing over Node-style streams (child.stdio[3]write,child.stdio[4]read). Unit-testable viaPassThroughmocks.extractCookiesViaCdpPipe— usesTarget.getTargets+Target.attachToTarget(flatten: true)+Network.enable+Network.getAllCookiesover a single pipe connection.importCookiesViaCdprewritten: spawns with--remote-debugging-pipe, routes through the new transport. The TCP port randomizer, retry loop, and WebSocket helper are removed. The Chrome subprocess usesnode:child_process.spawn(notBun.spawn) because Bun returns raw numeric fds for stdio indices ≥ 3 and Node stream↔Web bridges hang in Bun on those sockets — this is the only place in the file that uses Node'schild_process.buildCdpSpawnArgs(exePath, userDataDir, profile)helper — pure argv builder, unit-testable without spawning anything.chromeProcgets an explicit'error'listener — without it, an async spawn failure (ENOENT, EACCES, AV interference) would crash the parent via Node's default handler.CdpPipeTransportflipsclosed = trueon unexpected read-stream end so post-endsend()rejects immediately;extractCookiesViaCdpPipeguardscookiesResp.cookies ?? []and validates `attached.sessionId` is a non-empty string before use.What does NOT change
The non-CDP cookie import path (SQLite + DPAPI for v10/v11 on macOS/Linux/Windows pre-ABE) is untouched. Tests for that path still pass.
Commits (bisectable)
feat(browse): add CdpPipeTransport for --remote-debugging-pipe CDP— primitive, 9 unit testsfeat(browse): add extractCookiesViaCdpPipe using CDP pipe transport— extractor, 4 unit testsfix(browse): switch cookie-import CDP from TCP port to stdio pipe— the fix, 4 unit tests forbuildCdpSpawnArgsfix(browse): handle chromeProc spawn error events— hardeningfix(browse): defensive hardening for cookie-import CDP pipe path— defensive guards + 3 testsTesting
CdpPipeTransportframing/error/close/post-end behavior (10),extractCookiesViaCdpPipetarget selection, session scoping, domain filtering, missing-sessionId, missing-cookies-field (6),buildCdpSpawnArgsregression tests locking the--remote-debugging-pipeflag set (4).bun testsuite passes with no new failures vs basemain. Four pre-existing failures onmainare preserved unchanged:test/brain-sync.test.ts(bearer-json secret scan),test/skill-validation.test.ts(2MB fixture size),test/touchfiles.test.ts(skill selection count),test/model-overlay-opus-4-7.test.ts(pacing phrase). None of these relate to this change.Windows v20 ABE integration smoke test was not run locally — developer machine is macOS. Happy to iterate on any Windows-specific feedback.
Out of scope (per issue)
extractCookiesViaCdp[Pipe]for non-Chromium targets.