Skip to content

fix(cli): keep WebSocket credentials out of daemon argv - #2764

Closed
mcc0nnell wants to merge 3 commits into
ChromeDevTools:mainfrom
mcc0nnell:ihb/wsheaders-secret-transport
Closed

mcc0nnell wants to merge 3 commits into
ChromeDevTools:mainfrom
mcc0nnell:ihb/wsheaders-secret-transport

Conversation

@mcc0nnell

@mcc0nnell mcc0nnell commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • preserve resolved wsHeaders across the CLI → daemon → MCP handoff without serializing header values into daemon argv
  • add CHROME_DEVTOOLS_MCP_WS_HEADERS as a secret-friendly input for direct users
  • scrub secret-bearing WebSocket-header environment variables after parsing
  • redact WebSocket header values from Puppeteer connection debug logs
  • keep precedence as explicit flag > config > public env
  • document the safer credential path while retaining --wsHeaders compatibility

Why

wsHeaders is coerced from JSON into an object. The daemon path currently runs structured options through the generic serializer, which turns the object into [object Object].

A straightforward JSON.stringify fix would restore propagation, but it would also place values such as Authorization: Bearer ... into the long-lived daemon/MCP process argv. This patch instead removes resolved headers from daemon argv and passes them through a dedicated inherited environment channel.

The internal resolved-header variable is consumed only in --viaCli mode so parent-resolved precedence is preserved when the child reparses configuration. The public environment variable remains a fallback for direct invocation and does not override an explicit flag or config value. Both secret-bearing environment variables are deleted after parsing so they are not inherited by subsequently launched Chrome processes.

The browser connection path also logged the entire Puppeteer connect-options object. Because that object contains wsHeaders, enabling --logFile could otherwise persist header values after moving them out of argv. Header names remain visible for diagnostics, but all header values are now replaced with [REDACTED] in that log representation without modifying the options passed to Puppeteer.

Verification

  • npm run typecheck
  • npm run check-format
  • npm run test -- tests/cli.test.ts tests/daemon/utils.test.ts
  • npm run gen
  • regression test verifies a bearer canary is absent from serialized daemon argv
  • precedence tests cover flag/config/public-env and the internal CLI handoff
  • browser regression test verifies WebSocket header values are redacted from connection logging and the original connection options are not mutated

All commits are signed and include DCO Signed-off-by trailers.

Security context has also been reported through Google OSS VRP (Issue 563146214).

@OrKoN

OrKoN commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

@mcc0nnell could you please rebase the PR?

@OrKoN

OrKoN commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

I am not sure we should support env vars for this. Would not be the args also visible for the CLI / regular MCP server args? Let's document that users can use --config file if they have sensitive headers or are worried about local system being compromised.

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

marked as requested changes

@mcc0nnell

Copy link
Copy Markdown
Contributor Author

Split this up per review instead of carrying the env-variable design forward. #2797 is the narrow object-serialization fix with no env transport, and #2901 carries the independent WebSocket-header log redaction. Closing this larger version to avoid duplicate/conflicting changes.

@mcc0nnell mcc0nnell closed this Oct 2, 2026
twotnguyen pushed a commit to twotnguyen/chrome-devtools-mcp that referenced this pull request Oct 16, 2026
…vTools#2901)

## Summary

- Redact WebSocket header values and URL credentials (userinfo and query
parameters) before logging Puppeteer connection options.
- Redact `--wsHeaders` / `--ws-headers` and connection endpoint
arguments in the daemon startup log, while passing the original
arguments to the spawned daemon.
- Keep the redaction helpers in `src/utils/logger.ts` rather than
expanding the `BrowserManager` public API.
- Verify the actual `ensureBrowser()` path sends unmodified credentials
to `puppeteer.connect`, alongside focused URL/daemon logging regression
tests.

## Scope

This is the logging-safety piece split out of ChromeDevTools#2764. It does not add
environment-variable transport or change `wsHeaders` precedence or CLI
serialization.

## Validation (Butcher; PR-pinned devtools-frontend revision)

- `npm run format` — passed
- `npm run build` — passed
- `node scripts/test.js --test-name-pattern='preserves
WebSocket|sensitive connection logging' tests/browser.test.ts
tests/utils/logger.test.ts` — passed (7 selected tests)
- `git diff --check` — passed

Updated in c5b9bdc.

---------

Signed-off-by: Robert McConnell <[email protected]>
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.

2 participants