Fix(DOM): Exclude Password Field Values from DOM Snapshots sent to LLM#4388
Merged
sauravpanda merged 3 commits intoMar 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Collaborator
|
Oh thanks for bringing this to our attention. Can you sign the CLA so that I can merge this? |
Contributor
Author
Done 🫡 |
sauravpanda
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why do we need this PR?
When the agent types a password into an
<input type="password">field (viasensitive_dataor programmaticfill()), the DOM serializer extracts the real value from the browser's accessibility tree and includes it in the text representation of the page sent to the LLM on every subsequent step.This means the plaintext password is visible in the LLM's context window, where a prompt injection on a later page (e.g. a malicious email body, a crafted form, an ad) can instruct the agent to exfiltrate it.
How it works
_build_attributes_string()in the DOM serializer has three paths that extract field values. None of them check fortype="password":valueattribute included if inDEFAULT_INCLUDE_ATTRIBUTESvaluetext/valuefrom the accessibility tree<input>,<textarea>,<select>After the fix, the serialized DOM for a filled password field looks like:
The LLM still sees it's a password field (so it can interact with it), but never sees the value.
Why existing mitigations don't fully cover this
_filter_sensitive_data()catches values from thesensitive_datadict via string replacement, but doesn't protect passwords filled programmatically (e.g.onepassword.py'sfill_fieldaction wheresensitive_dataisn't set on the Agent)fill+clickhappen in the same step, but this isn't guaranteed since the LLM controls the batching, multi-action sequences break early on page changes, and login failures re-expose the value on retryDemo
Changes
browser_use/dom/serializer/serializer.py- Detecttype="password"inputs and skipvalue/valuetextfrom all three extraction paths (HTML attributes, AX properties, form element value lookup)tests/ci/security/test_sensitive_data.py- 4 new tests: AX tree value stripping, HTML attribute value stripping, non-password input backward compatibility, inputs without explicit type unaffectedTest plan
test_password_field_value_excluded_from_dom_snapshot— AX tree password values are strippedtest_password_field_value_excluded_even_from_html_attributes— HTMLvalueattr is strippedtest_text_input_value_preserved— backward compat: non-password inputs still show valuestest_password_field_without_type_attribute— inputs without explicittypeare not affectedSummary by cubic
Prevent password leakage by removing values from
<input type="password">in DOM snapshots sent to the LLM. Keeps field metadata so the agent can interact, but never includes the secret value.type="password"and strip values from HTML attributes, AX properties, and form value extraction.value; keeptype="password". Non-password inputs unchanged; inputs without explicittypeunaffected.rufflint fixes.Written for commit 624c040. Summary will update on new commits.