Skip to content

fix(rules): integrity bounds give a signal or are read: style attribute, CSS rule bounds, base href #1423 - #1526

Closed
nc9 wants to merge 5 commits into
mainfrom
fix/1423-integrity-bounds
Closed

nc9 wants to merge 5 commits into
mainfrom
fix/1423-integrity-bounds

Conversation

@nc9

@nc9 nc9 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1423.

Three integrity-rule bounds could be passed with cheap padding and gave no signal.

  • Style attribute. It was read to 8,192 characters, so a hidden decoy <span style="[8.4 KB of a:b;]display:none"> inside a label was read as visible and broke the phrase. It is now read to 1 MB, once per element (cached, so a control nested around a big one does not re-read it); a control with a longer style attribute is counted in controlsUnread.
  • CSS rule bounds. A rule with a body over 4,000 characters or a selector over 300 was skipped whole, hiding an overlay rule behind padding. A selector list is now read per comma part (2,048 characters each, prelude up to 256 KB) and a body up to 256 KB (a padded rule is read for the overlay geometry). An oversized part, prelude or body that could match an iframe on the page makes the CSS cssTruncated; an oversized rule that may hide a class or id gives hiddenCssTruncated on brand-impersonation when controls exist and nothing was found. A larger rule for something else is still skipped, since it cannot match.
  • <base href>. A link or form action was always resolved against the page URL. The first <base href> (as a browser reads it) now decides: a relative link under a base on another host is judged by that host, a plainly local link is no longer skipped as the site's own while the base moves it, an empty form action still goes to the page, an empty link href goes to the base, links rank as off-site under a moved base (so node floods cannot push them out of the longer read), a <base> inside svg, math, noscript or template is ignored, and a relative iframe src in fake-auth-overlay resolves against the base too. A data:/javascript: base, a base without href, and a second base are ignored.

Acceptance criteria

  • a hidden decoy after more than 8,192 characters of style attribute is read as hidden (and a style past 1 MB reports the control as not fully read)
  • a rule past the old bounds is read for the overlay geometry, or reported through cssTruncated
  • a link resolved against a <base href> on another host is judged by that host
  • one test per case: the behavioural cases in integrity-bounds-1423.test.ts fail on main and pass here
  • the docs state the remaining bounds and the signal each one gives

Base resolution is linear (review round 2): documentBase was called per iframe and scanned the document each time (10,000 iframes with a password form: 4.4 s before, 13 ms now; main 13 ms), and documentBaseHref walked every ancestor of every <base> (4,000 nested <g> with 16,000 bases was seconds; 20,000 <g> with 80,000 bases and the same inside a deep <noscript>: 34 ms, 27 ms brand, main 25 ms). The base is now found once per document (cached) in one iterative pass in document order with no depth bound: a depth cap fails in both directions (a deep ignored <base> in noscript, template or svg read as honoured can false-flag, or hide a finding when it is a plain-local decoy placed before the real base; a cap that reads deep as ignored hides a real deep base), so nesting never decides which base wins. Probes at depths 63, 64, 65, 200 and 2,000 inside noscript, template, svg and foreignObject, with decoys, are tests; the capped version failed them. 20,000 nested <g> with 80,000 bases: 48 ms overlay, 34 ms brand (main 31 and 26); 30,000 iframes: 75 ms (main 36); 200,000 flat nodes: 82 and 77 ms (main 70 and 72). A <base> inside <svg><foreignObject> is an HTML element and is honoured.

Notes: hiddenCssTruncated appears on the info note when nothing is found and in the finding's details; it is also emitted on a clean page with such a rule and a sign-in label, and the docs say so.

Linear: the style cache and the bounded CSS scans keep the hostile cases (a megabyte of separators, ; plus 900 KB of spaces, 300 nested controls around one 800 KB style) in seconds.

Skill change: none.

nc9 added 5 commits November 2, 2026 09:03
…te to 1 MB, CSS rule bounds with cssTruncated, base href #1423

Signed-off-by: Nik Cubrilovic <[email protected]>
…class signal, rank under moved base, base placement, empty link href #1423

Signed-off-by: Nik Cubrilovic <[email protected]>
…ancestor walk; foreignObject base honoured; notes and tests #1423

Signed-off-by: Nik Cubrilovic <[email protected]>
…cap; nesting cannot decide which base wins #1423

Signed-off-by: Nik Cubrilovic <[email protected]>
…nnot flip them; math base cases #1423

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

nc9 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.159 as 33c28bd8, 0cbaecee, 2710f1bc, 87e8d1cc, 9c2b9ffe via #1531 (the commits were re-created by the rebase-merge; matched by their cherry-pick trailers). Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.159

nik

@nc9 nc9 closed this Nov 2, 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 rules: oversized style attribute, oversized CSS rule and <base href> still bypass without a signal

1 participant