Skip to content

fix(browser): keep declared scenario secrets out of redacted evidence - #1590

Merged
morluto merged 1 commit into
morluto:mainfrom
Adolanium:fix/scenario-secret-redaction
Oct 10, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
Adolanium:fix/scenario-secret-redaction

Conversation

@Adolanium

@Adolanium Adolanium commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #1591.

Declared scenario secrets could survive redaction when the marker [REDACTED:<id>] contained the secret, and storage identity fields were copied unchanged.

Problem and expected behavior

docs/browser-scenario-contract.md says declared secret values are removed from observed content, including a secret declared only so matching observations are removed. redactExplicitText already refuses a replacement that still contains a declared literal.

BrowserScenarioSecrets.redact always inserted [REDACTED:<secret_id>]. For secret id password and value pass, the result seen [REDACTED:password] in the page still contains pass. redactBytes searched only the original buffer, so a longer secret's marker could reintroduce a shorter secret. Cookie name, domain, and path, and localStorage / sessionStorage keys, were stored without redaction. Header names already went through redact.

Change and scope

Text, URL, and byte replacement now pick the first of [REDACTED:<id>], [REDACTED], …, and an empty string that does not contain a declared spelling. If a spelling remains, text becomes empty, a URL is returned as redacted with an empty URL, and bytes become an empty buffer. Storage capture redacts cookie names, domains, paths, and storage keys through the same text redactor.

Ordinary long secrets still use [REDACTED:<id>]. Longest-first replacement is unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: browser scenario secret redaction, while projecting captured text, URLs, bodies, and storage.
  • CLI and MCP/tool-catalog contract: none. The same scenario fields are returned. A marker that would keep a secret is replaced by a marker that does not, or the field is cleared and marked redacted.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: retained scenario text, URL strings, body bytes, and storage identity fields no longer include a declared secret spelling introduced by redaction. Digests still describe the retained bytes.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: BrowserScenario.test.ts covers the pass / password marker and a byte body whose longer marker would have contained pass. PlaywrightScenarioArtifacts.test.ts covers a secret used as a cookie name and a storage key.
  • Base reproduction or other evidence: executed the previous replacement. pass remained inside [REDACTED:password], and a body containing only session-secret-value gained pass from [REDACTED:password].
  • User-visible CLI/MCP output (if applicable): scenario evidence uses [REDACTED] when the id marker would contain a declared secret. Storage names that equal a secret are redacted.
  • Remaining proof gaps: no live browser scenario was captured. The regression uses the redaction and artifact functions directly.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- src/browser/BrowserScenario.test.ts src/browser/PlaywrightScenarioArtifacts.test.ts — 17 tests passed.
  • npx tsc --noEmit --pretty false — no errors.
  • npx oxlint on the four edited files — 0 errors.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Callers that compared an exact [REDACTED:<id>] marker still get that marker when it does not contain a declared spelling. A short secret that is a substring of its id now produces [REDACTED] instead of a marker that still contains the secret.
  • Real Hopper/Ghidra, browser, or OS coverage: not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: declared secret values no longer remain in scenario evidence through a redaction marker or a storage identity field.

Review checklist

  • This PR addresses a concrete problem or an agreed enhancement.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

A redaction marker such as [REDACTED:password] can contain the secret it replaced, and the byte replacer never scanned the marker it inserted. Cookie names, domains, paths, and storage keys were also stored raw. Choose a marker that does not contain a declared spelling, drop the result when a spelling remains, and redact storage identity fields.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@CassieFox23

CassieFox23 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: In my tests the PR fixes #1591. The secret pass is gone from its marker, and a cookie or storage name that equals a secret is hidden. Still open on both main and the PR: the DOM shows a secret with & or < as &amp; or &lt;, and one with a space as %20 in a link.

Results

I ran each case through capture-browser-scenario on Chromium 154 (BSD-3-Clause), with a made-up secret unique to each case. I searched every output for it, raw and as URL, form, JSON, HTML and base64 text. Launch and connect mode agreed on the cases I ran in both.

Where the secret was main 472f31323 leaks? PR ed500f3bd leaks?
Page text, short secret pass with id password (the #1591 repro) yes, [REDACTED:password] no, [REDACTED]
Network body with two secrets, pass and session-secret-value yes no
Cookie name, localStorage key, sessionStorage key yes no
Cookie path yes no
Values in an input, cookie, storage, URL, header, body or console log no no
Page text or input with &, < or ", shown HTML-escaped in the DOM yes yes, same as main
Link href with a space written as %20, shown in the DOM and accessibility text yes yes, same as main

The last two rows are not caused by the PR. They are a separate gap, filed as #1608. With no secrets declared, main and the PR gave the same output once I set aside ids, timings and event order.

Check Node 22.23.1 Node 24.18.0 Node 26.11.1
6 browser unit test files on PR head 43 of 43 pass 43 of 43 pass 43 of 43 pass
The PR's 2 new tests on main not run both fail not run
npm run check:fast on PR head not run pass not run

Main has one failing test of its own, keeps failed event finalization failed across cleanup retries. It also fails with the PR's tests copied in, so the PR did not cause it.

Not run

  • Cookie domain as a secret, since no host name here could be one.
  • Screenshot pixels. Text drawn in an image cannot be redacted. I only searched the PNG bytes.
  • Spellings the docs say are not read, such as base64 made by the page itself.
  • Evidence bundle export, the MCP path and headed mode.
  • Other systems and other Chromium versions.
  • npm run check, docs:check and the full test suite.

Thanks, Adolanium, for the exact strings in the issue and for tests that fail on main.

More cases, with short secrets

Each row is main 472f31323 against PR ed500f3bd, from the page text unless the row says otherwise. I also built main with the PR patch applied. Its output matched the PR head on all 38 secrets in 10 cases.

Case main PR
tok declared with id token [REDACTED:token], which holds tok [REDACTED]; the cookie named tok shows as [REDACTED]
abcdef inside the longer tokA-abcdef-9x longest first, one marker each same as main
Two secrets that overlap by 4 characters in q1w2e3r4t5y6 [REDACTED:id_p]t5y6, the tail of the second secret stays same as main
3-character xq7 in boxq7ing and in a storage value bo[REDACTED:tri]ing; the storage value gets redacted-secret and no hash same as main
3-character xq7 as a storage key kxq7 kxq7 k[REDACTED:tri]
Secrets RED, ACT and ED:, plus one long one nested markers; every marker holds RED … for all four; the ids are lost
Body abcx with secrets abc and 1]x body keeps [REDACTED:s1]x, which holds 1]x body is empty (0 bytes, redacted: true)
Empty string as the secret no marker appears no marker appears
Secret written as a literal in the request, not as a reference the echoed parameters keep it same as main
Secret not declared at all stays everywhere, as the docs say same as main
Inline value key in secrets; unset environment variable both rejected, exit 1 same as main

The PR's choice to use … or an empty field when the marker still holds a secret is what the PR body says. One short secret like RED turns every marker in that run into …. REA also empties a body when a marker and the text beside it join into a declared secret, like 1]x above.

The id password holds pass. REA keeps ids in secret_references and in the echoed parameters, so a search for pass still finds password. I counted those as the caller's own labels, not leaks.

Random-input check

I called redact, redactBytes and sanitizeUrl from each built tree. I used 3 seeds of 20,000 inputs each, 60,000 per function. Each input had 1 to 3 secrets of 1 to 4 characters and a text of up to 30 characters. The 16-character alphabet had [, ], :, R, E, D and A to make clashes with the marker. A result leaked if it held a declared spelling.

Function main leaked PR leaked PR emptied the result
redact (text) 8,050 of 60,000 0 52
redactBytes 8,159 of 60,000 0 56
sanitizeUrl 9,861 of 60,000 0 62

Emptying is the PR's fallback when no marker is safe. This alphabet is built to cause clashes, so real pages will hit it far less often.

Commands
# build each tree (Node 24.18.0), from git archive of the commit
git archive <sha> | tar -x -C <dir> && cd <dir> && npm ci && npm run build

# one run per case, secrets passed as environment variables
REA_SEC_<ID>='<made-up value>' node scripts/rea.mjs capture-browser-scenario scenario.json --json

# connect mode: a fresh headless Chromium and a new profile for every run
chromium-browser --headless=new --remote-debugging-port=9471 \
  --user-data-dir=<new dir> --password-store=basic about:blank

# unit tests, on Node 22, 24 and 26
node scripts/run-development-tests.mjs focused \
  src/browser/PlaywrightScenarioBrowser.test.ts \
  src/browser/PlaywrightBrowserScenarioProvider.test.ts \
  src/browser/PlaywrightExecutionBoundary.test.ts \
  src/browser/PlaywrightScenarioArtifacts.test.ts \
  src/browser/PlaywrightScenarioEvents.test.ts \
  src/browser/BrowserScenario.test.ts

# on a git clone of the PR head
npm run check:fast

Every run used env -i, a fake home folder, no D-Bus, a short TMPDIR, and nice -n 10. A small Python server on 127.0.0.1 served the pages. It echoed a query value into a response body and a header.

Raw output: where each made-up secret was found

raw@ is the raw spelling. html_text and html_full are HTML-escaped. uri is percent-encoded. "clean" means no spelling anywhere. I searched JSON strings, network bodies, PNG bytes, stderr and the Chromium log. A start_url.url hit is the caller's own request echoed back in parameters. It is the same on both trees.

## c2p launch
  s_text       main: clean
               pr:   clean
  s_input      main: clean
               pr:   clean
  s_cname      main: ['[email protected][].name']
               pr:   clean
  s_cval       main: clean
               pr:   clean
  s_lskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_lsval      main: clean
               pr:   clean
  s_sskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_ssval      main: clean
               pr:   clean
  s_urlq       main: clean
               pr:   clean
  s_startq     main: clean
               pr:   clean
  s_reqhdr     main: clean
               pr:   clean
  s_reqbody    main: clean
               pr:   clean
  s_resp       main: clean
               pr:   clean
  s_console    main: clean
               pr:   clean
## c2p connect
  s_text       main: clean
               pr:   clean
  s_input      main: clean
               pr:   clean
  s_cname      main: ['[email protected][].name']
               pr:   clean
  s_cval       main: clean
               pr:   clean
  s_lskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_lsval      main: clean
               pr:   clean
  s_sskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_ssval      main: clean
               pr:   clean
  s_urlq       main: clean
               pr:   clean
  s_startq     main: clean
               pr:   clean
  s_reqhdr     main: clean
               pr:   clean
  s_reqbody    main: clean
               pr:   clean
  s_resp       main: clean
               pr:   clean
  s_console    main: clean
               pr:   clean
## c2s launch
  s_text       main: ['[email protected]']
               pr:   ['[email protected]']
  s_input      main: ['[email protected]', '[email protected]']
               pr:   ['[email protected]', '[email protected]']
  s_cname      main: ['[email protected][].name']
               pr:   clean
  s_cval       main: clean
               pr:   clean
  s_lskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_lsval      main: clean
               pr:   clean
  s_sskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_ssval      main: clean
               pr:   clean
  s_urlq       main: ['[email protected]', '[email protected]']
               pr:   ['[email protected]', '[email protected]']
  s_startq     main: clean
               pr:   clean
  s_reqhdr     main: clean
               pr:   clean
  s_reqbody    main: clean
               pr:   clean
  s_resp       main: clean
               pr:   clean
  s_console    main: clean
               pr:   clean
## c2s connect
  s_text       main: ['[email protected]']
               pr:   ['[email protected]']
  s_input      main: ['[email protected]', '[email protected]']
               pr:   ['[email protected]', '[email protected]']
  s_cname      main: ['[email protected][].name']
               pr:   clean
  s_cval       main: clean
               pr:   clean
  s_lskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_lsval      main: clean
               pr:   clean
  s_sskey      main: ['[email protected]_storage[].name']
               pr:   clean
  s_ssval      main: clean
               pr:   clean
  s_urlq       main: ['[email protected]', '[email protected]']
               pr:   ['[email protected]', '[email protected]']
  s_startq     main: clean
               pr:   clean
  s_reqhdr     main: clean
               pr:   clean
  s_reqbody    main: clean
               pr:   clean
  s_resp       main: clean
               pr:   clean
  s_console    main: clean
               pr:   clean
## c1a launch
  password     main: ['[email protected][].body.content(b64-decoded)', '[email protected]', '[email protected]', '[email protected][].name', '[email protected]_storage[].name']
               pr:   clean
## c1a connect
  password     main: ['[email protected][].body.content(b64-decoded)', '[email protected]', '[email protected]', '[email protected][].name', '[email protected]_storage[].name']
               pr:   clean
## c1b launch
  password     main: clean
               pr:   clean
  pin          main: ['[email protected][].body.content(b64-decoded)']
               pr:   clean
## c1b connect
  password     main: clean
               pr:   clean
  pin          main: ['[email protected][].body.content(b64-decoded)']
               pr:   clean
## c7 launch
  pathsec      main: ['raw@start_url.url', '[email protected][].path']
               pr:   ['raw@start_url.url']

The #1591 strings, called straight on the built functions:

main redact: "seen [REDACTED:password] in the page"
main redactBytes: "body [REDACTED:password] tail"
pr redact: "seen [REDACTED] in the page"
pr redactBytes: "body [REDACTED] tail"
Test pages

One page and one script per case, from a local server on 127.0.0.1:8791. The script set a cookie, a localStorage entry and a sessionStorage entry, logged to the console, and sent a POST with an X-Req-Tok header and a JSON body. The server echoed a query value into a JSON response body and an X-Resp-Tok header. The page had a text field, a mirror of its value and a link built with encodeURIComponent. The scenario filled the field from a secret reference and clicked the link. One more secret sat in the start URL query. It captured DOM, accessibility, storage, URL and history after each step. At the end it also took a screenshot. It kept console, network, frame, popup and download events. Network events kept bodies and header values.

The plain case used values like SECRET-c2p-cname-7f3a91d2. The special case used values like SECRET c2s cname 7f/3"+&q<z>.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1 (browser runs on 24.18.0)
  • Head / base: ed500f3bd / 654340525. The head did not move and GitHub reports it mergeable.
  • Main: 472f31323. It changed 8 files under src/browser since the base, and none of those changes mention secrets or redaction. The PR applies to main with patch.
  • Other: Chromium 154 (BSD-3-Clause), the one Fedora 44 ships
  • Build: 154.0.8037.57

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Welcome to REA, @Adolanium! Thanks for handling declared secrets that appear inside redaction markers, cookie names, and storage keys. Those are easy places to miss when redacting captured evidence, and the regression cases make the behavior clear. Squash-merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: evidence Evidence, artifacts, and reconstruction bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Scenario redaction can keep a declared secret

3 participants