Skip to content

fix(integrity): dvh, svh, lvh, dvw, svw, lvw, vmax and vmin count as the whole viewport #1496 - #1501

Closed
nc9 wants to merge 8 commits into
mainfrom
fix/overlay-viewport-units-1496
Closed

nc9 wants to merge 8 commits into
mainfrom
fix/overlay-viewport-units-1496

Conversation

@nc9

@nc9 nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1496.

integrity/fake-auth-overlay decided that a frame fills the viewport with includes("100%"), includes("100vw") and includes("100vh") only. The dynamic, small and large viewport units and vmax/vmin were not recognised, so a full-screen fixed frame sized with them was not a cover.

Change (overlay-style.ts)

FULL_WIDTH and FULL_HEIGHT: 100 followed by %, vw/vh and their d/s/l forms, vmax or vmin, not preceded by a digit or a dot, so it works inside calc(), max() and min() and 1100% or 100.5% no longer count. The inset: 0 rule is unchanged (the optional change to stop it counting for an iframe is left out: it needs its own decision).

Tests (integrity-evasions-784.test.ts, 40 pass; 3 of them fail against the unchanged source)

  • Every width unit x every height unit (including calc() and max() forms) makes a fixed #google-auth frame a cover.
  • 50dvw/100dvh, 100dvw/50dvh, 100px, 1100%, 100.5%, a mixed-up axis (100dvh as width) and 300px/100dvh are not.
  • The same from a <style> rule.

Docs and CHANGELOG updated. Skill change: none.

nik

Follow-up: spellings (head c14d0a0)

Accepted: 100.0%, 100.00vw, +100vw, 1e2vw, 1E2%, 101vw/150%/200vh (over-full, up to 1000), calc(50vw + 50vw), calc(100% - 0px), max()/min()/clamp() (numbers of the axis summed), vi/vb (and d/s/l forms), cqw/cqh/cqi/cqb, stretch, fill-available, -webkit-fill-available, -moz-available; inset-block, inset-inline and the inset-*-start/end longhands. Not covers: 10vw, 100px, 1100vw, 0.100vw, 50%, -100vw, wrong-axis units.
Documented limits: var(--w) is not resolved; a fixed length in calc() is not subtracted.
Skill change: none.

Round 2 (auto security review)

  • Length cap no longer decides the verdict: values are comment-stripped, unescaped and whitespace-collapsed (linear passes), a value still over 2,048 chars (or 100,000 raw) counts as filling.
  • No upper bound: 10000vw, 1e5vw, 1e400vw, 1100vw, calc(2000vw - 1900vw), max(-5vw, 100vw) fill; products/quotients of an axis length (calc(100vw * 20)) count as filling (documented, errs toward detection). Negatives are skipped only outside calc/arithmetic (-100vw alone is off-screen).
  • CSS escapes (1\30 0vw, 100v\w, 100\76 w, \31 00vw, escaped property wid\74 h) and comments (incl. width:/*;*/100vw that hid the ;) are undone before parsing.
  • Flipped: 1100vw/1100% are real over-full widths, now covers (previous negatives came from the old digits-before-100 regex).

Round 3 (auto security review): declaration tokenizer

stripComments + split(";") replaced by one linear tokenizer (splitDeclarations): ; splits only outside strings/brackets/parens, /* opens a comment only outside strings (unterminated runs to the end), unquoted url(...) is one token, backslash escapes the next char, a string ends at its quote or an unescaped newline. Escapes are undone per declaration after the structure is split. Tests: content:"/*", '/*', url(data:image/png;base64,AAA), "a;b", {;}, [;], escaped quotes, \/*, width:/*;*/100vw, plus a structured random generator (2,000 mixes with a known answer) and 1 MB hostile inputs under 2 s. Mutation: naive split(";") fails 2 tests.

Round 4 (auto security review): block stack

The tokenizer keeps a stack of expected closers ((->), [->], {->}): a closer pops only if it matches the top, any other closer is an ordinary token, ; splits only with an empty stack outside strings, unclosed blocks end at EOF. Context handled: a declaration list (style attribute, or a rule body already cut out of its braces by scanCss); a top-level unmatched } is an ordinary token. Direction: match the browser (an unclosed block swallows the rest of the list, so nothing after a:(] is read); the shapes that need it are not in real styles. An unquoted url( needs url to be a whole identifier. Tests: shapes a:(], a:[}, a:{), a:( , calc((1), url( , stray closers, balanced blocks; 20,000 random delimiter mixes compared with a differently-structured recursive reference of the spec; mutation (pop on any closer) fails 2 tests.

Round 5 (auto security review): union of readings, fail toward detection

  • Three readings of every declaration list and every <style> rule cut: tokens (CSS Syntax 3: strings, comments, escapes, url(), block stack; one shared lexer walk() for declarations AND the rule cut), naive (complete comments dropped, split on every ;, unterminated comment/string read on), plain (the old split). The frame is a cover when ANY reading says so; the old reading is a floor, nothing main caught is lost (property test over 20,000 random mixes: plain => union).
  • Tokenizer: url( recognised on the decoded identifier (u\72 l(, URL(, \55 RL(; \;url( is not url); CR, CRLF, FF normalised to newline; escapes consume hex digits plus one space.
  • scanCss cut is brace-aware in the tokens reading (#x{content:"}";...}, {/* } */ ...}), the first-} cut stays in the other two.
  • "A block left open swallows the rest" removed from docs/CHANGELOG; known evasions left (var(), @media/@supports/@layer, nested rules, descendant/attribute selectors, external sheets, near-full sizes, min-width/min-height, huge px/rem, transform scale/zoom) and FP limits (fixed lengths in calc not subtracted, products fill, cq/vmin both axes) documented, not chased.
  • Mutants killed: uppercase URL, escaped ) in url(), ident decode, newline preprocess, brace-aware cut, union, (?![\w%]), arithmetic flag, leading-dot number. Tokenizer vs a token-pre-pass recursive reference over 20,000 mixes.

Round 6 (review of 4825783)

  • Superset of the old reading: the (?![\w%]) lookahead is gone (100%x, 100vwx fill, as includes did) and the lookbehind is (?<![\d.]); property test over 460,000 random attribute and stylesheet mixes (NUL, U+2028, BOM, NBSP, lone surrogates, escapes, \<LF>, at-rules): zero lists the old rules flag and the union does not (default 30,000 in the suite; OVERLAY_MIXES=460000 for the big run). One deliberate exception: 0.100vw (0.1 of a viewport) is not a cover, which the old includes rule called one.
  • \<newline> outside a string is a stray token, not an escape; inside a string it continues it.
  • url( quote check uses CSS whitespace (space, tab, newline) only.
  • scanCss tokens reading runs preludes and at-rules through the same lexer: @media print{.x{content:"{"}}, @import "a;b";, @import url(a;b);, @charset "a;b";, [a="{"], garbage; no longer hide the next rule.
  • Tests: geometry written inside a comment is read by plain only (removing plain fails), \<LF> hiding shape, NBSP/U+2028/BOM, .5vw and calc(.5vw + 99.5vw), 99.99vw / 100.0001vw. Mutants killed: no plain, \<LF>, CSS whitespace, leading dot, old scanCss. (>=100 vs >100 is an equivalent mutant: the sum branch also accepts 100.)
  • Docs/CHANGELOG: the "punctuation cannot hide" claim reworded to what holds; &{} nesting listed as a limit.

Round 7 (tests + docs only)

Tests: .5vh leading-dot height, form feed/newline inside a sheet string, comment-to-space in a prelude, { inside brackets (no rule, as in a browser), stray } before a rule, a;#g{...} (over-read: a browser may drop it in nested contexts, we read it; matters only for a fixed, high-z-index, auth-named iframe). Docs: CDO/CDC (<!--, -->) added to the limits. Skill change: none.

nc9 added 8 commits November 1, 2026 17:32
…in/max sums, logical inset #1496

Signed-off-by: Nik Cubrilovic <[email protected]>
…, CSS escapes/comments undone #1496

Signed-off-by: Nik Cubrilovic <[email protected]>
… before splitting declarations #1496

Signed-off-by: Nik Cubrilovic <[email protected]>
… decides; brace-aware rule cut; url() by decoded ident; newline normalisation #1496

Signed-off-by: Nik Cubrilovic <[email protected]>
… escape, CSS whitespace, at-rule/selector preludes via walk, superset property tests #1496

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9 nc9 mentioned this pull request Nov 1, 2026
@nc9

nc9 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.156 as 5f967889, 64473e6b, bdf8c5a9, 01de031a, 3f5da4ea, e1a13ddc, ee4b35fa, 5149d8e4 via #1506.

nik

@nc9 nc9 closed this Nov 1, 2026
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.

integrity/fake-auth-overlay: dvh, svh, lvh and vmax viewport units are not read as filling the viewport

1 participant