Repository navigation
Redact typed passwords, credential headers and listed secrets everywhere capture sends them - #589
Conversation
…ere capture sends them A trace zip and the live dashboard recorded everything a run typed. Password masking (#530) only covered the field in the replayed page, so the typed value still showed in command rows, step titles, the transcript, network and console. Redaction is now automatic in all four adapters: a value typed into an <input type="password"> is learned before the typing command's row is sent, and Authorization, Proxy-Authorization, Cookie and Set-Cookie header values and cookie values are hidden, with names kept. A `secrets` option adds values nothing marks as secret. Everything is replaced with the same fixed placeholder, live and in the trace, and `maskInputs: false` turns the automatic part off. Closes #573
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
[High impact] Redaction now changes captured text across all four adapters and both live and archived output. The PR is not ready to merge because passwords can still reach live frames and remain in earlier trace resources. FindingsSummaryThe PR adds automatic password and credential redaction, plus a
Reviews (12) · Last reviewed commit: "Expect the redacted step title in the We..." · Reviewed by Greptile |
The core redaction test instantiated the abstract SessionCapturerBase, which fails pnpm typecheck. Skipped-secret warnings logged text built from the configured entries, so a log line could carry data read from them or the environment; adapters now log only a count. The document.cookie rewrite used a regex with overlapping quantifiers that is polynomial on long runs of spaces; it is now a linear split, mirrored in Python, with a long-spaces test. Addresses review comments on #589
…rces
Selenium's sendKeys('Super', 'Secret') learns the joined password but its
row keeps the parts, and the walk only joined one-character arrays, so
neither part matched and the password reached the dashboard and trace.
A string array whose joined text holds a secret no single part holds is
now redacted as that text, in both languages, with mirror vectors.
Python sends a test file's source once, before its password is typed, and
the backend builds the archive from that stored copy. Learning a new
password now re-sends the sources already sent, which the backend
replaces by path, so the archive no longer keeps the literal.
Addresses review comments on #589
Joining any string array in the walk also merged unrelated arrays, such as separate console.log arguments, into one entry whenever a secret spanned two of them. Only Selenium's element sendKeys records typed text in parts, so it now records the joined text, as the W3C payload and the Python adapter already do, and the walk is back to joining only one-character keystroke arrays. Addresses review comments on #589
setValue('#password', ['Super', 'Secret']) learned the joined password, but
its row kept the two parts, and neither matched the learned value on its own,
so both reached the dashboard and the trace. The row now records the parts
joined, as the field receives them, while Nightwatch still gets the original
arguments; this mirrors Selenium's sendKeys row.
Addresses review comments on #589
setValue('#password', ['Super', 'Secret']) learned the joined password, but
its row kept the two parts, and neither matched the learned value on its own,
so both reached the dashboard and the trace. The row now records the parts
joined, as the field receives them, while Nightwatch still gets the original
arguments; this mirrors Selenium's sendKeys row.
Addresses review comments on #589
ddb98e7 to
f83c83d
Compare
…fore it was typed
A typing row keeps the special keys pressed between a value's parts, so
sendKeys('Super', Key.SHIFT, 'Secret') learned SuperSecret while its row
held the two parts with the key code between them, and neither matched.
A secret's typed form now matches with any special keys between its
characters, in the TypeScript redactor and the Python mirror alike.
With per-spec or per-test archives, a slice written before a later test
typed a password kept it, in the spec source every slice carries. Each
written archive is now recorded with the redactor it was written under, and
finalizing the run rewrites the ones written before the redactor grew. The
rewrite lives in trace and reads the zip with fflate, which the service now
declares because its bundle keeps third-party imports external.
Addresses review comments on #589
The cleanup that re-redacts an archive written before a later password was learned rewrote every string, including generated references such as a screenshot's resource name or a body's `_sha1`, while the entries they name kept their filenames. A password that happened to appear in one of those names left the player unable to load the screenshot, body or stylesheet. A string that names an entry of the archive is now kept as written. Addresses review comments on #589
The cleanup put back any string equal to an archive entry's name, wherever it appeared, so captured text that matched one (a console line reading `trace.trace`, say) stayed readable even after a later test typed it as a password. Only the `sha1` and `_sha1` fields the writer stores entry names under are now put back; captured text is always redacted. Addresses review comments on #589
# Conflicts: # CLAUDE.md # packages/selenium-devtools-py/tests/test_mirror_vectors.py # packages/selenium-devtools/tests/mirror-vectors.test.ts # packages/shared/mirror-vectors.json
| this.#pending.push( | ||
| noteTypedInput(args[1], () => | ||
| direct | ||
| ? direct.getElementType(elementId) | ||
| : browser.getElementProperty(elementId, 'type') | ||
| ) |
There was a problem hiding this comment.
Passwords can leave before learning
TypedInputReads.read() starts the field-type read without waiting. Only the command row waits for it later; BiDi console and network callbacks send frames immediately. If typing triggers a console message or request before the read returns, that frame uses the old redactor and sends the password unchanged.
Hold those outgoing frames until pending typing reads settle, without holding the WebdriverIO hook open.
How this was verified: BiDi callbacks send directly through sendUpstream, while the password enters the redactor only after the separate field-type read resolves.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| let parsed: unknown | ||
| try { | ||
| parsed = JSON.parse(line) | ||
| } catch { | ||
| return redactor.redactString(line) | ||
| } | ||
| const redacted = keepReferences(parsed, redactor.redact(parsed), references) | ||
| const text = JSON.stringify(redacted) | ||
| return text === JSON.stringify(parsed) ? line : text |
There was a problem hiding this comment.
Numeric passwords survive archive cleanup
If an earlier test captures the response body 123456 and a later test types that password, cleanup leaves the raw body readable under resources/. JSON.parse('123456') returns a number, which the redactor leaves unchanged. The inline body may be clean while the separate body file still exposes the password.
Treat raw resource files as text rather than guessing their format from each line.
How this was verified: Response bodies are stored as raw UTF-8 bytes, and cleanup parses numeric text into a number before applying a walker that skips numbers.
The step that types the demo password is titled with it, and secret redaction now replaces it in the trace, so the smoke expectation looks for the group by its redacted title.
What & why
Closes #573.
A trace zip and the live dashboard recorded everything a run typed. #530 masks password fields in the replayed page, but the typed value still showed in command rows, step titles,
transcript.md, network and console. Measured before this change on the WebdriverIO login example: the demo password appeared 41 times in its two trace zips.Redaction is now automatic, in all four adapters, live and in the trace:
<input type="password">is learned before that typing command's row is sent, by one field-type read per typing command (skipped for values under 4 characters, values already known, and native apps). From then on it is replaced everywhere: command rows, step titles, transcript, network URLs/headers/bodies, console, the DOM stream, element and a11y snapshots, and the trace zip.Authorization,Proxy-Authorization,CookieandSet-Cookievalues inheaders,requestHeadersandresponseHeaders, plus the values indocument.cookiestrings and cookie objects, with names kept.secretsoption for values nothing marks as secret (API keys, tokens): literal values or{ env: 'NAME' }. Python:enable(secrets=...),--devtools-secret-env,devtools_secret_envs,DEVTOOLS_SECRET_ENVS.maskInputs: falseturns off page masking, typed-password and header redaction together;secretsstill applies.Everything is replaced with the fixed placeholder
••••, which hides the length.Type of change
Packages touched
shared(types and contracts)core(framework-agnostic capture/reporting)elements(published element/snapshot API —@wdio/elements)service(WebdriverIO adapter)nightwatch-devtools(Nightwatch adapter)selenium-devtools(Selenium adapter)selenium-devtools-py(Selenium Python adapter)backend(server)app(UI)script(page-injected runtime)trace(Trace mode)Capability matrix
packages/conformance/src/features.tsupdated, and tables regenerated withpnpm docs:capabilities, if this adds or changes user-facing behaviourThe masking row is now "Typed passwords and credential headers masked and redacted", backed by two new conformance rules (
typed-password-never-sent,credential-headers-redacted) that all four adapters pass in all three BiDi modes.Notes for reviewers
core: the redaction walk and the rules are inshared(so Python runs the samemirror-vectors.jsoncases), the run's redactor andnoteTypedInputare incore, and it is applied at the two places data leaves an adapter:SessionCapturer.sendUpstream(live) andwriteTraceZip(archive); Python atWSClient.send_json. Each adapter only supplies how to read the typed field's type.elementSendKeysbeforeCommandwithout awaiting (WDIO drops other commands' hooks while one is pending) and awaits only before recording the outer row; Selenium readsgetProperty('type')beforesendKeys; Nightwatch queues aperformahead of the typing command; Python reads beforesendKeysToElementwith a 2 s ceiling. None of these reads records a row.••••in Run-all/Rerun; a Python--devtools-secretliteral not reaching dashboard reruns.headers(real rows userequestHeaders/responseHeaders), and a keystroke-prefix rule rewrote unrelated strings such astype="password". The prefix rule is removed; the page's own password masking already covers the field's keystrokes.pnpm build,pnpm lint(0 errors),pnpm test(312 files, 4247 passed),pnpm docs:capabilities --check, the Python wire-type sync check, and the Python suite under CI's command (953 tests) are green; the bundle leak grep finds nothing.••••and the username row keepstomsmith; and in trace mode with per-test archives, where a test written before a later one typed the password holds no copy of it.To re-check live mode with no secret set:
pnpm build, thenpnpm demo:wdio:mocha,DEVTOOLS_MODE=live pnpm demo:nightwatch,pnpm demo:selenium,PYTHONPATH=packages/selenium-devtools-py/src pnpm demo:python:pytest. The password row and step title show••••and the username row keepstomsmith; Network tab credential header values show••••.Screenshots / recordings
Not included: no UI change. Rows show
••••in place of the value.