Repository navigation
Detect and fill login fields inside open shadow roots - #348
Open
blacksun80 wants to merge 2 commits into
Open
blacksun80 wants to merge 2 commits into
blacksun80 wants to merge 2 commits into
Conversation
Inputs inside a shadow root are not part of document.forms and are not returned by getElementsByTagName on the document, so login forms built with web components (e.g. the password field of <lux-password> on auth.gmx.net) were never detected. Fields from open shadow roots (including nested ones) now belong to the form containing their outermost shadow host, so username and password are still filled together. Fields whose host is outside of any form go into the pseudo form used for orphaned fields. The DOM mutation observer also observes open shadow roots so fields added to them later trigger a rescan. Closed shadow roots remain inaccessible. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Multi-step login pages (e.g. auth.gmx.net) often show only the username field on the first step, with no password field in the form. Such forms were ignored unless a field had been whitelisted manually. A text field with autocomplete="username" is now preferred as the username field and makes a form interesting even without a password field, as a whitelisted field would. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
Kee finds fields via
document.formsandgetElementsByTagName("input"), so it never sees inputs that live inside a shadow root. More and more login pages are built from web components.A concrete example is the new GMX login at
https://auth.gmx.net/login, a two-step form:<input type="email" autocomplete="username">, noname). Kee ignored this form because it has no password field, unless the user whitelisted the field manually.<lux-password>custom element, which is placed inside the login<form>. Kee never found it.Similar reports on the forum: Chase, auth.max.com, web.de/gmx.de.
Solution
Commit 1: Find and fill fields in open shadow roots
src/page/shadowDom.tsfinds open shadow roots (including nested ones) and the inputs inside them.FormUtils.getFormFieldsalso returns the inputs from shadow roots whose outermost host is inside the form. Username and password are then still detected and filled as one form.MutationObserverinpage.tsalso observes open shadow roots (both those present at startup and those added later), so fields rendered into a shadow root later on still trigger a rescan.Commit 2: Treat
autocomplete="username"fields as login fieldsA text field with
autocomplete="username"is now preferred as the username field and makes a form interesting even without a password field, as a whitelisted field would. This covers the first step of multi-step logins without per-site configuration. It is a separate commit because it is a (small) behaviour change beyond shadow DOM support; it can be dropped on its own if you'd rather not include it.Limitations
TreeWalker).Testing
src/tests/shadowDom.test.tsandsrc/tests/formsUtils.test.ts: open, nested and closed shadow roots, hosts inside and outside forms, a<lux-password>-like form, andautocomplete="username". The existingConfigManager.test.tsfailures are unrelated and also happen onmaster.tsc --noEmitand eslint report no new problems.npm run build-chrome:beta) loaded unpacked in Edge with KeePassRPC onhttps://auth.gmx.net/login: the username is filled on step 1 without any whitelist entry and the password is filled on step 2.🤖 Generated with Claude Code