docs(security): document pages that hide a password field from e2e

Merged
SA
4d ago
+30-18

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) at packages/web/src/in-page/read-semantics.ts:598 and :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 inputValue show the value
    • a failed toHaveValue prints the value
    • getAttribute and toHaveAttribute do the same when the HTML value attribute 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 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.mdx
    • docs/decision-models.mdx, which also says the text model then sees the value and type can fill the field
    • skills/e2e/references/agent.md
  • Lines that said a read of a password field is POLICY_DENIED now say secure field, as screen.mdx already does: docs/reference/mcp.mdx and skills/e2e/references/writing-tests.md. The skill edits are synced to plugins/e2e/.
  • Pages that describe what e2e does with a secure field, such as expect.mdx "Secure fields", screen.mdx, and the POLICY_DENIED row, 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>.

Readwithout the scriptwith 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 attributenot run"typed-pw-777" / null
expect(field).toHaveValue('nope')POLICY_DENIEDASSERTION_FAILED, trace.md holds value "gen-Pw-918273"
expect(field).toHaveAttribute('value', 'nope')POLICY_DENIEDASSERTION_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 too1.3% (unmasked, shows the bullets)

🤖 Generated with Claude Code