Skip to content

integrity/fake-auth-overlay: model more of the CSS that styles an overlay iframe #1409

Closed

Description

@nc9

Follow-up to #784 (PR #1399). The overlay detector resolves an iframe's geometry from inline style and simple iframe, .class and #id rules in <style> blocks. Gaps found in review, none a regression (main had no CSS support):

  • geometry inside @media all, @layer, @supports, @container and CSS nesting is not applied (at-rules are skipped whole)
  • a comment inside a declaration or selector (position:fixed/**/;), and a } inside a comment, truncate the rule body
  • escapes (position:\66ixed), descendant (main iframe) and attribute (iframe[id]) selectors, inset-block and inset-inline longhands
  • specificity is not modelled: candidates apply in key order, so .c{position:static} beats #id{position:fixed}, the opposite of a browser; source order is lost across keys

Acceptance Criteria

  • Geometry written inside @media all, @media screen, @layer and @supports blocks that apply unconditionally is detected, with a test each
  • A comment inside a declaration or a selector, or a } inside a comment, does not change the rule that is read, with tests
  • CSS escapes in a property or value are decoded before matching, with a test
  • Descendant and attribute selectors that name the iframe by id or class are matched, with tests
  • The cascade follows specificity then source order, with a test where an id rule beats a class rule written later
  • The scan stays linear: the existing 4 MB hostile CSS cases and the 5,000-rule case still run in milliseconds

nik

Activity

  1. added
    size: M
    rules
    security
    on Oct 31, 2026
  2. added theissue type on Oct 31, 2026
  3. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against main 7c31d5b (first released in v0.0.160, included in v0.0.161):

    # Criterion Result Evidence
    1 Geometry inside @media all, @media screen, @layer, @supports PASS packages/rules/src/integrity/overlay-style.ts; overlay-css-1409.test.ts "rules inside the at-rules that apply to a screen": one case each for @media all, @media screen, named and anonymous @layer, @supports, plus @container, @scope and nested at-rules; print-only and speech-only @media stay unread (negative control)
    2 Comment inside a declaration or selector, } inside a comment PASS same file, "a comment, an escape or a logical longhand is still read"
    3 CSS escapes decoded PASS same test: position:\66ixed and \70osition
    4 Descendant and attribute selectors by id or class PASS "descendant and attribute selectors name the iframe by its last compound": every operator, plus non-matching negatives
    5 Specificity then source order PASS "the cascade": "an id rule beats a class rule written later" (and the reverse case)
    6 Scan stays linear PASS integrity-adversarial-784.test.ts (36 pass), and I timed the 8 existing 4 MB soup shapes and the 5,000 iframe{} rule case directly: 16 to 159 ms each. The new file adds 5 MB and 10 MiB shapes with a 6 s ceiling (119 tests pass)

    Ticked all six. Not closing yet: follow-up hardening of the same reader landed on main after the v0.0.161 tag (selector-list syntax errors, ASCII-only case fold, quirks-mode class and id, commits 581fb48, 5b16a8e and 0cbb42d, issue #1566). It ships in v0.0.162, so I will close this once that tag is out.

    nik

  4. nc9 commented on Nov 4, 2026

    @nc9
    ContributorAuthor

    Acceptance check against v0.0.162 (7c31d5b, release). The reader landed in v0.0.160 (f56ac8e, ced8484, 1e7e28e) and its follow-up hardening (581fb48, 5b16a8e, 0cbb42d, issue #1566) is in v0.0.162. I re-ran the tests on the v0.0.162 tag: packages/rules/tests/overlay-css-1409.test.ts 119 pass, integrity-adversarial-784.test.ts 36 pass.

    # Criterion Result Evidence
    1 @media all, @media screen, @layer, @supports PASS overlay-css-1409.test.ts "rules inside the at-rules that apply to a screen": one case each (also @container, @scope, nested); print-only, speech-only and not all stay unread
    2 Comment in a declaration or selector, } in a comment PASS "a comment, an escape or a logical longhand is still read"
    3 CSS escapes decoded PASS same test (position:\66ixed, \70osition)
    4 Descendant and attribute selectors PASS "descendant and attribute selectors name the iframe by its last compound" with non-matching negatives
    5 Specificity then source order PASS "the cascade": "an id rule beats a class rule written later", equal specificity falls to source order
    6 Scan stays linear PASS the 4 MB hostile cases and the 5,000 iframe{} rule case in integrity-adversarial-784.test.ts are unchanged since #784 and pass; I timed them directly: 11 to 121 ms for the eight CSS soup shapes, 35 ms for the 5,000-rule case with 20,000 frames; the new file adds 5 MB and 10 MiB shapes with a 6 s ceiling

    All six boxes are ticked. Closing.

    nik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    rulessecuritysize: M

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions