fix(electron): keep a password field's length out of accessible names
What
On an Electron target, no accessible name says how long a password is anymore. Chromium builds some names from a password field's value, one bullet (•) per character. These now keep the rest of the name and drop the bullets:
| Element | Was | Now |
|---|---|---|
<td>Key <input type="password" value="hunter2"></td> | Key ••••••• | Key |
<button>Btn <input type="password" value="hunter22"></button> | Btn •••••••• | Btn |
<button aria-labelledby="secret"> where #secret is a password field, or holds one | ••••••••••••• | no name |
A name the page wrote with aria-label is kept as written, bullets and all: <td aria-label="Key • Backup"> stays Key • Backup, and so does a button aria-labelledby points at a group with that aria-label, though the group holds a password field.
Why
A secret's length reached the agent's observation, the trace, and role locator text through these names. The web engine gives a password field no part in a name. AGENTS.md lists this under the security invariants: secret values never reach model input as text, and a length is part of the value.
How it works
DomSnapshotmarks each password field and every element that holds one, from the DOM snapshot, across shadow trees (packages/electron/src/snapshot.ts:264,holdsSecureFieldat:292).- When
TreeProjectionnames a node, it takes Chromium'slabelledbyrelation (AXValue.relatedNodes, the nodes Chromium resolved, so an id repeated in another shadow tree is not mistaken for it). A name is "from a secret" when the node holds a password field, or when it is labelled by an element that is one or holds one. An element with its ownaria-labellends none, since Chromium takes that label in place of its content (lendsSecret,packages/electron/src/tree.ts:303). Such a name loses its bullets (packages/electron/src/tree.ts:263-267). - The reference's security list says how such a name reads.
tests/integration/launch.test.tsreads a page with each case in both projections, checks that no bullet or value is left, and checks that each affected element is still there under the rest of its name.
Verified
Ran it locally: yes, on macOS (Apple Silicon) with Electron 45.5.0.
- At this head, the Electron package's unit and integration tests, typecheck, and oxlint pass. The Electron testbed run through the built CLI (
pnpm --filter @e2e-dev/electron-testbed test) andpnpm checkpassed before the bot-review commits and were not rerun locally after them. - main against this branch: this branch's tests run against
origin/main'spackages/electron/src. These tests fail there and pass here:
| Suite | Test | main | this PR |
|---|---|---|---|
| integration | a password field lends no name, not even its length, to an element aria-labelledby names it for | fails | passes |
- Benchmark:
pnpm bench:ab --suite electron-testbed(main against this branch) is still running; its table replaces this line when it finishes. - Video: none attached. The change is in what the engine reads and when it acts, which the tests above pin down; a recording would show the same window either way.
- Local macOS runs, on both sides, started Electron with
-ApplePersistenceIgnoreState YESfrom #2500, applied without committing it. Without it, an Electron the tests killed makes macOS ask to reopen its windows, and the next launch waits out its timeout. The Linux and Windows CI jobs do not need it.
Fresh-context review (Codex gpt-6.2-sol, read-only, on this branch's diff):
- Fixed: a name the page wrote with
aria-labellost its bullets when the element held a password field (48d4851b2, with a test). - Fixed: the test now checks that each affected element is still there (
3297b48e5). - Fixed: the reference and the changeset are added.
Bot review:
- Fixed: an element
aria-labelledbypoints at that holds a password field and has its ownaria-labellent that label with its bullets stripped (1dd5e2acd, with a test). - Fixed: the password-field check parsed every element's attributes a second time;
indexFactsnow parses them once (7b7ec2caf). - Fixed: the changeset and the reference name a cell and a button as examples, not as the only elements affected (
b624297d8).
🤖 Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Password values and their masking bullets are no longer exposed in accessibility names, including names derived through labels. Other name text is preserved, as are names explicitly provided with
aria-label.
- Password values and their masking bullets are no longer exposed in accessibility names, including names derived through labels. Other name text is preserved, as are names explicitly provided with
- Documentation
- Clarified how password-related accessible names are redacted. The existing note about withholding screenshots when password fields in closed shadow roots cannot be masked remains.