fix(e2e): redact plain-string secret values in titles, labels, and agent input
A value registered in config.secrets (or a credential password) that a test passes as a plain string, not as a secrets.get() handle, leaked into model input, reports, and file names. Only error messages and observations masked it. docs/security.mdx promises every occurrence is redacted.
test(`title holds ${process.env.KEY}`, async ({ app, agent }) => {
await app.open(`/?token=${process.env.KEY}`);
await agent.act(`inspect ${process.env.KEY}`, { params: { note: process.env.KEY } });
});
On main the value showed up in: test title, testId, and step labels in report.json; list reporter output; junit testcase names; summary.md; the failure page file name; artifact directory names; the custom executor's ctx.step.instruction / ctx.step.params; the built-in agent's act prompt and judgment prompts; agentContext.
What changed
Redaction now happens once, at the place each piece of text is produced:
- Titles:
collectModuletakes a title redactor and applies it as everytest/describetitle registers (packages/e2e/src/collect/registry.ts). Every caller (runner collection, worker collection,RealmManager) passesstaticSecretLedger(config.allSecrets).redact, a ledger of the static values built once per secrets map (packages/e2e/src/run/secrecy.ts). Every process redacts the same way, so ids still match between the runner and its workers. Test ids,--grep, reporters, artifact dirs, and failure page names all come from the redacted title, so none of them needs its own fix. Titles are redacted before NFC normalization, and the 512-byte limit is checked again after redaction. Two titles in one file that differ only in a secret value raise the existing duplicate-title-path error. - Step labels:
StepRecorder.runredacts the label before it records, publishes, or traces it (packages/e2e/src/run/steps.ts). Before a session opens, the attempt's redactor used to pass text through unchanged. It now falls back to the static values (redactForSession). The standalone (MCP) recorder had no redactor at all and now uses the same one. - Agent steps:
dispatchAgentStepredacts the instruction and every string in the params (keys and values) before anything reads the spec (packages/e2e/src/agent/act.ts). The executor, the built-in agent's prompt, the step label, the trace cache, and the ledger all get the same redacted step. Secret handles are already placeholders at this point, sotypeSecretstill fills the real value. unique()templates follow their leaves:redactParams(packages/e2e/src/agent/act-validation.ts) rewrites each template's pointer to the redacted keys and redacts its value too. A template with a secret in its key or value still slots into the cache key.- Judgments:
Invocationredacts the system message and the built prompt (the repair text before its 2000-character cut).agentContextis redacted per step and per judgment against the live ledger, not once when the agent selection is cached. - Param keys: two keys of one object that redact to the same text are
INVALID_ARGUMENT, not a silent overwrite. e2e explore: the goal becomes the title, artifact name, report goal, and model context, and it is redacted once when the state is built (packages/e2e/src/explore/index.ts).--last-failedafter upgrading: a test whose title holds a secret gets a new id once, so the previous run's failure list does not match it.
Out of scope, documented in "Where redaction stops":
- A Playwright trace of a session no secret reached is kept as recorded, so a URL the test spelled a value into stays in the trace text. The exposure model decides this.
- Titles are redacted at collection, before any provider runs, so a provider-returned value is not redacted from titles.
Verified
Ran it locally: yes
- Scratch project (
/tmp/fix-plain-string-secret-redaction) with a random 27-character static secret: a describe and test title holding it,app.open('/?token=' + S),getByText('missing ' + S)(fails on purpose),agent.act('inspect ' + S, { params: { note: S, ['key ' + S]: [S] } })on a custom executor that dumpsctx.step,console.log/console.errorof it, and a second test that types the secret throughsecrets.get('probe')+typeSecretand checks the server got the real value. Ran with the built CLI,node dist/cli/bin.js run --reporter list,junit,markdown, then grepped every output file and file name for the value.
| surface | main | this branch |
|---|---|---|
| CLI list output (stdout lines with the value) | 6 | 0 |
executor ctx.step dump | instruction, params, keys, agentContext | all <secret:probe> |
files under .e2e containing it | report.json, junit.xml, summary.md, failure page | none |
paths under .e2e containing it | 10 (artifact dirs, failure page name) | 0 |
| failing assertion error message | masked | masked |
typeSecret through the handle | passes | passes |
- New integration test
packages/e2e/tests/integration/plain-string-secrets.test.ts(worker path plus the built-in agent in-process) fails 4 of 5 on main; the handle-typing control passes on both. The new explore andredactParamstests fail on main too.