docs(security): document pages that hide a password field from e2e
Merged
SA
4d ago+30+30+01234567890123456789-18-18-01234567890123456789
Issue
Refs #2010. This is option 3 from the triage comment. Option 1, saving Element.prototype.matches in the context init script, waits for #1503, so the issue stays open.
Why
- On the web engine, e2e decides whether a field is secure inside the page's main world:
el.matches(options.secureFieldSelector)atpackages/web/src/in-page/read-semantics.ts:598and:1618. - If a page script replaces
Element.prototype.matches, e2e reads a password field as a plain textbox, and the docs said that can't happen.
What changes
docs/reference/security.mdx, "Where redaction stops": a new item covers the case:- the observed screen and
inputValueshow the value - a failed
toHaveValueprints the value getAttributeandtoHaveAttributedo the same when the HTMLvalueattribute holds the password- configured secrets stay
<secret:name> - screenshots still mask the field, unless it is in a closed shadow root and the page also replaces
querySelectorAll
- the observed screen and
- The places that said password fields are always masked now link to that item:
- the "The screen" row of the security reference's model-input table
docs/agent-steps.mdxdocs/decision-models.mdx, which also says the text model then sees the value andtypecan fill the fieldskills/e2e/references/agent.md
- Lines that said a read of a password field is
POLICY_DENIEDnow say secure field, asscreen.mdxalready does:docs/reference/mcp.mdxandskills/e2e/references/writing-tests.md. The skill edits are synced toplugins/e2e/. - Pages that describe what e2e does with a secure field, such as
expect.mdx"Secure fields",screen.mdx, and thePOLICY_DENIEDrow, stay as they are. They remain true, because the hidden field no longer counts as secure.
Verified
Ran it locally: yes
The testbed ran with the CLI built from main (3e7d19de1). The branch changes no code, so main and the branch behave the same. Each case loaded <label>Password <input type="password" value="gen-Pw-918273"></label>, once as is and once with <script>Element.prototype.matches = () => false;</script>.
| Read | without the script | with the script |
|---|---|---|
inputValue() | POLICY_DENIED | "gen-Pw-918273" |
getAttribute('value') | POLICY_DENIED | "gen-Pw-918273" |
inputValue() / getAttribute('value') after fill('typed-pw-777'), no value attribute | not run | "typed-pw-777" / null |
expect(field).toHaveValue('nope') | POLICY_DENIED | ASSERTION_FAILED, trace.md holds value "gen-Pw-918273" |
expect(field).toHaveAttribute('value', 'nope') | POLICY_DENIED | ASSERTION_FAILED, the message holds the value |
inputValue() on a configured secret (admin-pass) | POLICY_DENIED | <secret:admin.password> |
| Share of the field's screenshot pixels that are black (masked) | 100% | 100% |
Same, closed shadow root, querySelectorAll replaced too | 1.3% (unmasked, shows the bullets) |
🤖 Generated with Claude Code