fix(secrets): redact plain-string secret values from traces and text downloads
Merged
OK
2mo ago+149+149+012345678901234567890123456789-129-129-012345678901234567890123456789
What and why
- A registered secret a test passes as a plain string (
app.open('/?token=' + KEY),fill(KEY)) was redacted from titles, labels, and agent input since #727, but stayed verbatim intrace.zip. #727 left this out on purpose: trace rewriting was gated on the session's exposure level, which only a secret fill or an engine-held secret (basic auth) raises. A plain string raises neither, so the trace was kept as recorded and labelednot-required. - The gate assumed the runner sees every way a value reaches the app. It does not: a URL, a
fill, or the app's own config never touch the exposure model. Traces and text downloads are now rewritten whenever the session's ledger holds a value (every static secret, and a provider's once resolved), the same way reports and observations already are.redactsRecordingsinpackages/e2e/src/run/secrecy.tsis the one place that decides. - The
engineexposure level only fed that gate, so it is removed. Exposure now decides pixels and saved-session taint only. Screencast frames are still dropped only after a secret fill: a plain string is protected as text only, like an engine-held secret. - Labels: a trace from a session that knows a secret value is now
complete(scanned) instead ofnot-required, and a scanned text downloadcompleteinstead ofincomplete.not-requiredstays for runs with no secret value. tests/integration/plain-string-secrets.test.tsnow records a trace (trace: 'on'), adds a plain-stringfill, inflates every zip entry, and asserts no plain, base64, or base64url form of the value (any case) remains. It fails on main ontrace.zip!trace.trace.- Docs:
security.mdx(Redaction, Where redaction stops, the artifacts table),debugging.mdx,reference/engine.mdx,reference/errors.mdx(TRACE_WITHHELD), and the AGENTS.md invariant.
export function redactsRecordings(secrecy: SessionSecrecy): boolean {
return !secrecy.ledger.isEmpty;
}
Cost
Every trace in a project with a secret is now scanned, not just traces after a fill. A trace with nothing to redact is still not rewritten (bytes untouched). Testbed (has credentials), full suite with --trace on, 70 traces, 9.4 MB:
| main | this branch | |
|---|---|---|
| wall | 15.4s, 15.9s | 16.4s, 16.5s |
| user CPU | 17.6s, 18.8s | 21.6s, 22.1s |
| trace labels | 67 not-required, 3 complete | 70 complete |
Roughly 55 ms CPU per trace. The scan is the existing redactFragments pass from #663; I did not add a prefilter, for the reason #663 gives (it would duplicate the spelling rules).
Verified
Ran it locally: yes
- testbed, scratch config (
trace: 'on',secrets: { probe: 'plain-Zr8Kq2Wm5Tx9' }) and one test:app.open('/forms?token=' + S),screen.getByLabel('Full name').fill(S),toHaveValue(S). Rannode node_modules/e2e/dist/cli/bin.js run --config e2e.plainsecret.config.tson a main build and on this branch, then inflated every zip entry under.e2eand counted the plain, base64, and base64url forms of the value (case-insensitive).
| main | this branch | |
|---|---|---|
trace.zip!trace.trace | 20 | 0 |
trace.zip!trace.network | 2 | 0 |
trace redaction | not-required | complete |
- Mutation check: putting the old gate back (
return secrecy.exposure.withholdsPixels) and rebuilding fails the integration test ontrace.zip!trace.trace.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.