Skip to content

Redact typed passwords, credential headers and listed secrets everywhere capture sends them - #589

Merged
vishnuv688 merged 11 commits into
mainfrom
feat/573-secret-redaction
Nov 25, 2026
Merged

vishnuv688 merged 11 commits into
mainfrom
feat/573-secret-redaction

Conversation

@vishnuv688

@vishnuv688 vishnuv688 commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

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:

  • Typed passwords. A value typed into an <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.
  • Credential headers and cookies. Authorization, Proxy-Authorization, Cookie and Set-Cookie values in headers, requestHeaders and responseHeaders, plus the values in document.cookie strings and cookie objects, with names kept.
  • secrets option 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.
  • One switch: maskInputs: false turns off page masking, typed-password and header redaction together; secrets still applies.

Everything is replaced with the fixed placeholder ••••, which hides the length.

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Polish (an improvement to an existing feature)
  • Breaking change (existing behavior changes for users)
  • Documentation
  • Internal (build, CI, dependencies, tooling)

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.ts updated, and tables regenerated with pnpm docs:capabilities, if this adds or changes user-facing behaviour

The 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

  • Why all four adapters, and what is in core: the redaction walk and the rules are in shared (so Python runs the same mirror-vectors.json cases), the run's redactor and noteTypedInput are in core, and it is applied at the two places data leaves an adapter: SessionCapturer.sendUpstream (live) and writeTraceZip (archive); Python at WSClient.send_json. Each adapter only supplies how to read the typed field's type.
  • Field-type read per adapter: WDIO starts it in the elementSendKeys beforeCommand without awaiting (WDIO drops other commands' hooks while one is pending) and awaits only before recording the outer row; Selenium reads getProperty('type') before sendKeys; Nightwatch queues a perform ahead of the typing command; Python reads before sendKeysToElement with a 2 s ceiling. None of these reads records a row.
  • Copy on write: a frame is copied only along the path to a change, so a run with nothing to redact sends the same objects as before.
  • Not covered (in the README): pixels (screenshots, screencast, video); frames a live run sent before the password was typed (the spec source, the page's own text), though the zip is written at the end and is clean; keys sent with no target element; values in non-password fields unless listed; native apps; base64 and binary fields; object keys; a JavaScript command-line secret showing as •••• in Run-all/Rerun; a Python --devtools-secret literal not reaching dashboard reruns.
  • Review history: four review rounds. Two critical bugs were found and fixed: header redaction matched only a key named headers (real rows use requestHeaders/responseHeaders), and a keystroke-prefix rule rewrote unrelated strings such as type="password". The prefix rule is removed; the page's own password masking already covers the field's keystrokes.
  • Checks: 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.
  • Measured on a real run (Chrome 157, WebdriverIO login example, with the password listed): 41 occurrences before, 0 after, with the same actions and page captures in each trace. Also verified by hand in live mode with no secret configured (WebdriverIO Cucumber login on the-internet.herokuapp.com): the password row, the login POST body and credential headers show •••• and the username row keeps tomsmith; and in trace mode with per-test archives, where a test written before a later one typed the password holds no copy of it.
  • The webdriver.io docs mirror follows in webdriverio/webdriverio.

To re-check live mode with no secret set: pnpm build, then pnpm 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 keeps tomsmith; Network tab credential header values show ••••.

Screenshots / recordings

Not included: no UI change. Rows show •••• in place of the value.

…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
@vishnuv688 vishnuv688 self-assigned this Nov 24, 2026
@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
devtools Ready Ready Preview Nov 25, 2026 3:20am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 1/5

[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.

Findings

  1. P1 Security Passwords can leave before learning ▶
  2. P1 Security Numeric passwords survive archive cleanup ▶

Summary

The PR adds automatic password and credential redaction, plus a secrets option across all four adapters.

  • Captured passwords and credential values are replaced before they reach the dashboard or trace.
  • Runs can add literal secrets or environment values to the redaction list.

Reviews (12) · Last reviewed commit: "Expect the redacted step title in the We..." · Reviewed by Greptile

@vishnuv688 vishnuv688 added the no-autofix PR Review Fixer routine skips this PR label Nov 24, 2026
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
@vishnuv688 vishnuv688 removed the no-autofix PR Review Fixer routine skips this PR label Nov 24, 2026
…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
Comment thread packages/shared/src/redaction-walk.ts Resolved
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
Comment thread packages/shared/src/redaction-walk.ts Resolved
vishnuv688 pushed a commit that referenced this pull request Nov 24, 2026
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
@linux-foundation-easycla

linux-foundation-easycla Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

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
@vishnuv688
vishnuv688 force-pushed the feat/573-secret-redaction branch from ddb98e7 to f83c83d Compare November 24, 2026 06:42
Comment thread packages/shared/src/typed-secrets.ts Resolved
Comment thread packages/core/src/spec-trace-helpers.ts Resolved
…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
Comment on lines +24 to +29
this.#pending.push(
noteTypedInput(args[1], () =>
direct
? direct.getElementType(elementId)
: browser.getElementProperty(elementId, 'type')
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security 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!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This arrived as #589 merged, so the fix is in #591 (3974efe): frames sent while a typing read is in flight are held, at most for the read's 2 s ceiling, and sent in order once it settles, redacted with what it learned. The hook is not held.

Comment on lines +85 to +93
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This arrived as #589 merged, so the fix is in #591 (3974efe): a line that is not a JSON record or list, such as a raw `123456` body, is now redacted as text rather than walked.

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.
@vishnuv688
vishnuv688 merged commit e0173f3 into main Nov 25, 2026
17 checks passed
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.

Redact secret values from traces, the transcript, network and console

2 participants