Skip to content

fix: redact typed text when its field cannot be checked for a password - #616

Open
vishnuv688 wants to merge 2 commits into
mainfrom
fix/600-redaction-fail-closed
Open

vishnuv688 wants to merge 2 commits into
mainfrom
fix/600-redaction-fail-closed

Conversation

@vishnuv688

Copy link
Copy Markdown
Member

What & why

Closes #600.

With maskInputs on (the default), each adapter reads a field's type before keys are sent and, for a password field, adds the typed value to the run's redaction set. When that read failed, timed out or could not be issued, the value was treated as "not a password" and reached the dashboard and the trace in clear, with nothing logged.

This makes the read fail closed on all four adapters: an unanswered read counts as a password field, so the typed value is redacted, and the run logs one warning that never names the value. A read that answers with no type (an element that is not a form control) still keeps the text.

  • Shared: redactsTypedText(text, fieldType, answered) in typed-secrets.ts is the one decision. FIELD_TYPE_SCRIPT now returns '' for a match with no type and null only when nothing matched, so a reader can tell the two apart.
  • Core: noteTypedInput distinguishes an unanswered read (rejected, timed out, or no reader) from an answered one, and configureSecretRedaction takes an optional warning callback, which the WebdriverIO service, Selenium and Nightwatch pass their logger to.
  • Nightwatch: the raw transport answers every failure with null rather than rejecting, so its reader treats null as no answer. setPassword is taken as a password without a read; a field located by neither CSS nor XPath, or with no selector, counts as unanswered.
  • WebdriverIO service: the Appium mobile-web direct probe answers a failed read with undefined, which now counts as no answer.
  • Python: redacts_typed_text mirrors the shared decision. A failed read is no longer indistinguishable from a field with no type, and a session that stopped reading after a timeout redacts what it types afterwards.

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

No matrix change: the existing "Typed passwords and credential headers masked and redacted" feature covers it, and no cell's support level changes.

Notes for reviewers

  • Trade-off: a value typed into a field whose read does not answer is redacted everywhere it appears in the trace, even when the field was not a password (a username on a slow page). That over-redaction is the deliberate choice over leaking a password.
  • Broad on Nightwatch page objects: a selector such as @password is not CSS, so the script matches nothing and the value is redacted. Supporting page-object selectors in the read is a separate change.
  • Appium mobile web (WebdriverIO): the direct probe cannot tell a failed read from an element with no type, so on that path text typed into a non-form element is redacted too.
  • Why the adapters change too: the decision and the unanswered handling are in shared and core; each JS adapter only passes its logger, and Nightwatch and the service adapt their transport's failure value to a rejection, which only they know about. Python cannot import core, so it mirrors the decision, held to the typedSecret vectors.
  • Tests: pnpm build, pnpm test (345 files, 4714 tests, conformance rules included) and pnpm lint (0 errors) pass. The Python suite passes except two weak-reference tests in test_instrumentation.py that fail the same way on main under local Python 3.12.
  • No live browser run: the failure paths (a read that times out or a transport that drops) are not reproducible on demand against a real driver, so they are covered by unit tests on each adapter's reader.
  • The matching docs-site change for webdriverio/webdriverio is prepared separately.

Screenshots / recordings

Not a UI change.

🤖 Generated with Claude Code

Input masking learns a password by reading the field's type before the keys are sent. A read that failed, timed out or could not be issued counted as "not a password", so the typed value went to the dashboard and the trace in clear, with nothing logged. Every adapter now treats an unanswered read as a password field, by one shared decision (redactsTypedText, mirrored in Python and held to the typedSecret vectors), and warns once without naming the value. Redacting a value that was not a password is the safer error.

Nightwatch and the WebdriverIO service's Appium direct probe answered failures with null or undefined rather than rejecting, so FIELD_TYPE_SCRIPT now returns '' for a match with no type and null only for no match, and both readers treat that null or undefined as no answer. Nightwatch's setPassword is taken as a password without a read, and a field located by neither CSS nor XPath counts as unanswered. Python, after one timed-out read, still stops reading on that session, and now redacts what it types there.

Closes #600
@vishnuv688 vishnuv688 self-assigned this Nov 26, 2026
@vercel

vercel Bot commented Nov 26, 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 26, 2026 9:39am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the latest test change matches the field-type script.RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; the latest test change matches the field-type script.

Summary

The PR redacts typed text when a field-type read fails, times out, or cannot be issued.

  • Typed text is redacted when its field check does not answer.
  • Python redacts typed text when a field check does not answer.

Reviews (2) · Last reviewed commit: "Let the fake field omit its type in the ..." · Reviewed by Greptile

vishnuv688 added a commit to webdriverio/webdriverio that referenced this pull request Nov 26, 2026
…cted

A typed value whose field-type read fails, times out or cannot be issued is now redacted rather than left as typed, with one warning that names no value, and Nightwatch's setPassword is taken as a password without a read. Matches webdriverio/devtools#616.
The test for a match that is not a form control passes a field with no
type, which the FakeField interface rejected, so pnpm typecheck failed
in the build job.

Addresses review comments on #616

Copy link
Copy Markdown
Member Author

The build check failed at pnpm typecheck: packages/shared/tests/typed-secrets.test.ts passes a field with no type to the FakeField helper, whose type was required (TS2741). Made type optional in 5618286; all checks are now green.


Generated by Claude Code

vishnuv688 added a commit to webdriverio/webdriverio that referenced this pull request Nov 26, 2026
#16503)

* docs(devtools): document secret redaction and the new maskInputs scope

* docs(devtools): align the limitations and Python variables with secret redaction

* docs(devtools): a field that cannot be checked for a password is redacted

A typed value whose field-type read fails, times out or cannot be issued is now redacted rather than left as typed, with one warning that names no value, and Nightwatch's setPassword is taken as a password without a read. Matches webdriverio/devtools#616.

This branch has not been deployed

No deployments
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.

Typed-password redaction fails open when the field-type read does not answer

1 participant