Skip to content

fix(extension): check card frames like login frames, fill shadow-DOM and Dutch addresses, and rest the idle corner offer - #365

Merged
kitlangton merged 7 commits into
devfrom
ext-sandbox-hotpaths
Dec 2, 2026
Merged

kitlangton merged 7 commits into
devfrom
ext-sandbox-hotpaths

Conversation

@kitlangton

@kitlangton kitlangton commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Card and address fills now skip sandboxed frames, fill fields inside web components, and read Dutch postcodes right. The corner save and sign-in offers also stop rewriting their style and hit-testing themselves 60 times a second.
Four small fill bugs and two hot paths, all in the extension. Login autofill is unchanged.

❌ Before

  1. ❌ A card or address field in a frame got values even when the frame element was <iframe sandbox>, and no visibility reading was taken for the frame. Login frames already refused both.
  2. ❌ Card or address fields that a web component renders inside the page's <form> were found by the scan, then skipped at fill ("The page changed").
  3. ❌ Prinsengracht 1, 1012 AB Amsterdam split into postcode 1012 and city AB Amsterdam.
  4. ❌ The Record popup said "Recorded 38 steps" when it meant 38 timeline events.
  5. ❌ A focused login field got two full page scans in a row (the page scan, then another before opening the menu), and every focus scanned before checking whether a menu could open at all.
  6. ❌ The corner save or sign-in offer rewrote its style (forcing style and layout work) and hit-tested itself every frame for up to 5 minutes, even when it sat still.

✅ After

  1. Card and address frames get the same frame checks as login frames: no sandboxed frame element, a fresh visibility reading on approval and re-check, and Deadbolt's own menu isn't counted as covering the field when it's placed. Callers now have to pass these checks explicitly, so none can be left out by accident, and every policy refuses a sandboxed frame element, including the popup's login fill into a frame. Payment provider frames (Stripe, Braintree) don't set sandbox, so they still fill.
  2. Those fields count as in place and fill, and one below the fold is scrolled to and filled like any other field of its form.
  3. Postcode 1012 AB, city Amsterdam. US state codes and Australian addresses parse as before.
  4. The popup counts recorded steps.
  5. One scan, and no scan at all when no menu can open.
  6. The style is written only when it would change or the page changed it. Once the offer has landed and nothing is moving, it hit-tests itself every 250 ms instead of every frame. It still asks for every frame, so it stays ahead of any frame the page asks for later, and a page restyle is put back on the next one. Linking a provider after a sign-in now depends on a typed result, not on the words "Signed in" shown on the page.
- boxesInTop(frame, boxes)                       // forms: no sandbox or visibility check
+ boxesInTop(frame, boxes, LOGIN_FRAME)          // policy required
- (el.form ?? el.closest("form")) === field.form // stops at the shadow root
+ formOf(el) === field.form                      // crosses it, like the scan
- position(): write style, hit-test, requestAnimationFrame(position)  // always
+ position(): write style only if changed; settled corner surface -> hit-test every 250 ms; next frame always

📊 Proof

Case Before After
Card frame in <iframe sandbox> ❌ filled ✅ nothing
Card field in a shadow root under <form> ❌ skipped ✅ fills
1012 AB Amsterdam ❌ city "AB Amsterdam" ✅ postcode "1012 AB"
Record popup ❌ events ✅ steps
Scans before a menu on an autofocused field ❌ 2 ✅ 1
Style writes by a resting corner offer (unit test) ❌ every frame ✅ 0
Hit tests by a resting corner offer in 600 ms (unit test) ❌ every frame ✅ ≤ 3 rounds

Each new test fails without its change and passes with it; the full unit suite passes (1,047).

👀 Read: content/inline.ts position(). A resting corner offer skips its style write and throttles its hit test, but never stops asking for frames: an earlier version that let it sleep between checks lost its place ahead of a page's own frames and failed the security suite's "late restyle" cases. A write the page makes during ours forces a rewrite every frame, as before. The other fixes are one or two lines each. Overlaps #364 (bg/forms.ts, content/forms.ts, content/inline.ts): if #364 merges first, this should rebase onto it.

🔍 Found in a code audit · no user reports · frame counts from the unit test's requestAnimationFrame counter in happy-dom, not measured in a browser

Checks run
  • bun run typecheck (extension): pass
  • bun test (extension): 1047 pass, 0 fail
  • bun corpus/score.ts --gate: gate pass
  • bun run build: built 5 entries
  • bash scripts/file-size.sh: 0 errors (content/inline.ts 1,373 lines, warning only)
  • E2E: CI passed on bff60fa4, security and sharded suites included; CI reruns on 33b90dd3 (rebased on dev, review polish). The earlier sleeping version failed the save and sign-in left/translate/scale "late restyle" cases; this version keeps the per-frame loop those cases rely on.

@kitlangton
kitlangton force-pushed the ext-sandbox-hotpaths branch from c2a6bfa to bff60fa Compare December 2, 2026 09:52
@kitlangton
kitlangton marked this pull request as ready for review December 2, 2026 10:03
…nd identity frames as login frames are

Forms' placement, approval and re-check passed no policy, so a sandboxed
frame element got card and identity values and no visibility reading was
taken. They now pass LOGIN_FRAME_PLACE and LOGIN_FRAME. Every policy now
refuses a sandboxed frame element, the login popup fill's included
(UNSANDBOXED_FRAME), and `how` is required.
…a form

The in-place check, the below-the-fold reach check and the scroll keeper
stopped at the shadow root, unlike the scan, so such fields were skipped
at fill, or never scrolled to.
An autofocused field got a second full scan right after the page scan
(refreshMenu), and every focus scanned before the cheap checks that keep
any menu shut (no gesture, a query in flight, dismissed, learning).
…hit-testing every frame

A corner save or sign-in offer rewrote the host's style and hit-tested it
60 times a second for its whole life. The style is now written only when
it would change or the page changed it (a write the page makes inside ours
forces a rewrite next frame), and once the surface has landed with nothing
moving, it hit-tests itself every 250 ms. Its frame is still asked for
every time, so it stays ahead of any frame the page asks for later.
@kitlangton
kitlangton force-pushed the ext-sandbox-hotpaths branch from bff60fa to 33b90dd Compare December 2, 2026 21:12
@kitlangton
kitlangton merged commit fc2acd9 into dev Dec 2, 2026
13 checks passed
@kitlangton
kitlangton deleted the ext-sandbox-hotpaths branch December 2, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant