Skip to content

browse: the audit log persisted fill, type, cookie and header values verbatim - #4057

Closed
derHaken wants to merge 1 commit into
garrytan:mainfrom
derHaken:audit-redact-typed-values
Closed

derHaken wants to merge 1 commit into
garrytan:mainfrom
derHaken:audit-redact-typed-values

Conversation

@derHaken

@derHaken derHaken commented Nov 6, 2026

Copy link
Copy Markdown

Problem

browse/src/audit.ts writes every command's joined args to the on-disk JSONL audit log after truncation only. A fill #password <value>, type <value>, cookie name=<value> or header Authorization: <value> therefore persists the credential verbatim in a plain file in the daemon's cwd, and a page or Playwright error that echoes the value stores a second copy in error. The activity stream's filterArgs does not reach this path: it filters the args array for the sidebar, while the audit entry receives one joined string.

Change

Redaction happens in audit.ts itself, before truncation and before the line exists, for every command that carries a typed value:

command logged as
fill <selector> <value> <selector> <redacted>
type, js, dialog-accept <redacted> (whole)
cookie name=value / header Name: value name=<redacted> / Name:<redacted> (no separator: whole)
storage set key value set key <redacted>

Everything after the kept part counts as the value, so a selector with spaces loses its tail too (more is hidden, never less). The error text is scrubbed of the same value, whole and per 4+ character piece. Navigation, click and other lines are unchanged. REDACTED, redactArgs and scrubSecret are exported so the behaviour is testable and reusable.

Tests

browse/test/audit-redact.test.ts: each command shape, the no-separator cases, the error scrub, redaction-before-truncation (a 500-character type value cannot leak its head), and the on-disk line via a temp log. Without the source change the test file does not load, since the exports do not exist. bun test browse/test/activity.test.ts browse/test/audit-redact.test.ts: 30 pass.

Related surface, not changed here

activity.ts's filterArgs (the in-memory stream the sidebar reads) is narrower than this: it redacts a fill value only when the selector looks like a password field (/password|passwd|secret|token/i), headers only for authorization/x-api-key/cookie, and never js, dialog-accept or storage set. A fill into #pin or input[name=pw] still streams its value. Happy to follow up with a shared redaction if you'd like the two paths unified.

🤖 Generated with Claude Code

…verbatim

`writeAuditEntry` wrote the joined args of every command to the on-disk
JSONL audit log after truncation only, so `fill #password <value>`,
`type <value>`, `cookie name=<value>` and `header Authorization: <value>`
left the credential in a plain file in the daemon's cwd, and a page or
Playwright error that echoed the value put a second copy in `error`.
The activity stream's `filterArgs` never applied here: it works on the
args array, and the audit entry receives one joined string.

The value is now redacted in audit.ts itself, before truncation and
before the line exists, for every command that carries a typed value:
fill keeps its selector, type/js/dialog-accept are hidden whole, cookie
and header keep their name, storage set keeps its key; everything after
the kept part counts as the value, so a selector with spaces loses its
tail too (more hidden, never less). The error text is scrubbed of the
same value, whole and per 4+ character piece. Navigation and click lines
are unchanged.

Tests cover each command shape, the error scrub, redaction-before-
truncation and the on-disk line; without the change the test file does
not load (the exports do not exist).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Nov 6, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for this. The leak is real. A maintainer lane is rewriting the fix on current main (our policy for outside code), crediting you with Co-authored-by for anything carried over. We'll link the landed PR here and close this one then.

@capy-ai

capy-ai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Thanks @derHaken. This was a real gap: the browse audit log stored fill/type/cookie/header values verbatim. We rebuilt the fix on current main in #4073, which merged as b10cc47 with you credited. Two leftover edges (query strings in the page URL, and very short values echoed in error text) are tracked separately. Closing this one as superseded.

@capy-ai capy-ai Bot closed this Nov 6, 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