Skip to content

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

Merged
okwasniewski merged 3 commits into
e2e-inc:mainfrom
samanyudas:docs/security-dom-method-limit
Nov 21, 2026
Merged

okwasniewski merged 3 commits into
e2e-inc:mainfrom
samanyudas:docs/security-dom-method-limit

Conversation

@samanyudas

@samanyudas samanyudas commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

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

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

On the web engine, e2e decides in the page's main world whether a field is
secure. A page script that replaces `Element.prototype.matches` makes a
password field count as a plain field. The observed screen then shows its
value, `inputValue` and `getAttribute` return it, and a failed
`toHaveValue` or `toHaveAttribute` prints it. Configured secrets are still
redacted, and screenshots still mask the field outside a closed shadow
root.

The places that say password fields are masked or never reach the model
link the limit: the security reference's model-input table, the
agent-steps and decision-models guides, and the e2e skill's agent
reference.

Refs e2e-inc#2010

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 21, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

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.

All reported issues were addressed across 5 files

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

Comment thread docs/decision-models.mdx Resolved
Comment thread docs/reference/security.mdx Resolved
samanyudas and others added 2 commits November 21, 2026 13:07
…attribute

`getAttribute` and `toHaveAttribute` read the element's HTML attributes,
not its live value, so they expose a hidden password field's value only
when the `value` attribute holds it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eld leaks

- The MCP `POLICY_DENIED` row and the e2e skill's writing-tests reference
  say a read of a secure field is denied, as `screen.mdx` does, since a
  password field a page hides from e2e is not one.
- decision-models says the text model sees a hidden field's value and
  `type` can fill it, and that only `typeSecret` fills a configured secret.
- The security reference names the limit in its model-input table link,
  and says a closed shadow root loses its screenshot mask only when the
  page also replaces `querySelectorAll`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

0 issues found across 5 files (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

@samanyudas

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of @samanyudas

Ready for human review at 9a5401a. All 28 checks pass, and both cubic threads are fixed and resolved. This account can't add the Ready for Human Review label, so this comment stands in for it.

One call for @okwasniewski: your triage comment asked only for the reference/security.mdx item. This PR also links that item from the places that said password fields are always masked (agent-steps.mdx, decision-models.mdx, the security page's model-input table, and the skill's agent.md). It also changes "password field" to "secure field" in two places that said a read is always POLICY_DENIED (reference/mcp.mdx and the skill's writing-tests.md). Without those edits, those sentences are false on a page that hides a field. If you'd rather keep the change to the one item, I'll drop the rest.

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[claude-opus-5-5] automated review on behalf of @okwasniewski

Checked at 9a5401a (docs only, mergeable clean, all checks green, both cubic threads fixed and resolved).

Every claim in the new "Where redaction stops" item matches main (3e7d19d):

  • Screen and inputValue: the only secure checks are el.matches(options.secureFieldSelector) in packages/web/src/in-page/read-semantics.ts:598 (embedded name) and :1618 (the node's secure flag). With matches replaced the node is a plain textbox, so observation.ts:207 keeps its value and locator/engine.ts:54 no longer refuses the read or the toHaveValue / toHaveAttribute assertions.
  • Attributes: the value attribute is dropped only if (secure) (read-semantics.ts:1639), and getAttribute reads el.attributes, not the live value, so "when the HTML value attribute holds it" is right.
  • Screenshots: secureFieldMasks (packages/web/src/observe.ts:32) uses Playwright's own CSS engine for light DOM and open roots, so the mask holds. The closed-root mask goes through e2e-closed, which calls the page's querySelectorAll in the main world (closed-shadow.ts:94, :98), so the closed-root exception is right too.
  • Text model: decision/src/elements.ts:163 offers type only when neither inputPurpose === 'password' nor secure is set, so a hidden field gets type. A configured password still can't go into it because its purpose is none. "Only typeSecret fills a configured secret" holds.
  • The "password field" to "secure field" renames in reference/mcp.mdx and the skill's writing-tests.md match screen.mdx and what locator/engine.ts actually checks. The skill copies under plugins/e2e/ are identical.

Must fix

  • None.

Nits

  • docs/reference/security.mdx:272: "and the page also replaces querySelectorAll" names one internal method. Replacing WeakMap.prototype.get (closed-shadow.ts:87) breaks the closed-root mask the same way. "unless it is in a closed shadow root and the page replaces other DOM methods too" stays true without listing internals.
  • docs/decision-models.mdx:136: type is offered only when the field also has no autocomplete="current-password" / "new-password". "can fill it" already covers this, so no change is needed unless you want it exact.

Verified by reading the code paths above on main. I did not rerun the testbed, because the PR changes no code and the author's main-vs-script table matches each path. CI: 28 checks, all green or skipped.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 21, 2026
@okwasniewski
okwasniewski merged commit 34d5d74 into e2e-inc:main Nov 21, 2026
30 checks passed
@samanyudas
samanyudas deleted the docs/security-dom-method-limit branch November 21, 2026 12:49
kblok added a commit to hardkoded/e2e-dotnet that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants