Skip to content

fix(rules): noscript content, implicit ARIA roles and CSP host wildcards (#434, #435, #427) - #438

Merged
nc9 merged 3 commits into
mainfrom
fix/rules-noscript-aria-csp
Oct 1, 2026
Merged

nc9 merged 3 commits into
mainfrom
fix/rules-noscript-aria-csp

Conversation

@nc9

@nc9 nc9 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #434, #435 and #427: three rule false positives reported from real sites. Thanks to @deniskern for the reports and the exact repros, which are the fixtures below.

Changelog: Rules no longer report content inside <noscript> as markup that loads or renders (tracking pixels, GTM iframes, fallback images and stylesheets), a11y/aria-required-children accepts native elements' implicit roles such as <input type="radio"> in a radiogroup, and security/csp no longer calls a host wildcard like https://*.example.com a bare *.

#434: <noscript> content treated as live DOM

Cause. A browser with scripting enabled parses <noscript> content as raw text, so nothing in it loads or renders. linkedom parses it as markup, and rules ran plain querySelectorAll over it.

Fix: one shared mechanism, applied where a rule describes what a browser loads or renders.

  • @squirrelscan/utils: isInsideNoscript(el) and querySelectorAllOutsideNoscript(root, selector), plus stripNoscriptMarkup(html) for the two rules that regex the raw source (perf/js-libraries markers, the CWV @font-face scan). The stripper is a small linear tokenizer: comments, quoted attributes and script/style/textarea content are passed over, so a "<noscript>" in a JS string is not a tag.
  • Parser extractors: extractImages (both copies), extractScripts and extractStylesheets skip <noscript> content. That covers parsed.images (alt-text, dimensions, broken-images) and the same-domain resource fetches behind the file-size rules. extractLinks deliberately still reads <noscript> anchors: link discovery is a crawl question.
  • Rules switched to the helper: a11y/frame-title, meta-refresh, image-redundant-alt, aria-required-children; images/aspect-mismatch, filename-quality, lazy-loading, modern-format, offscreen-lazy, optimized, picture-element, responsive-size, srcset; perf/cwv (lcp-hints, cls-hints, inp-hints, render-blocking, preconnect, font-loading), critical-request-chains, carousel-hidden-eager, lazy-above-fold, lcp-fetchpriority, animated-content, duplicate-js, font-delivery, js-libraries, legacy-js, total-byte-weight, unminified-css, unminified-js; security/sri, third-party-cookies, mixed-content; adblock/blocked-links (script attribution and the blocklist URL list).
  • integrity/fingerprint: the template cluster key now pins only live assets. Without this, template fan-out stays unsound for the template-scoped rules above (sri, third-party-cookies, js-libraries, ...): a page whose tracker sits only in a fallback would share a key with one that loads it, and get its verdict. This was visible on the hub fixture before the change (sri still fired on the noscript page, fanned out from its template twin).

Checked and kept reading <noscript> content, with the reason:

  • Link rules (links/*, extractLinks): crawl discovery, as above.
  • Text rules already exclude <noscript> text (content/text-content, reading-level, keyword-stuffing, hidden-text, date-agreement, unrendered-markup).
  • Head metadata rules (core/, crawl/canonical-chain, pagination, i18n/hreflang, social/og-, mobile/viewport, a11y/zoom-disabled, local/geo-meta, ax/noai-signals, social/asset-divergence): read the first matching tag; no <noscript> pattern in the wild puts these there.
  • Presence detectors, where reading more is the lenient direction for a "missing X" finding: analytics/gtm-present, security/form-captcha (reCAPTCHA ships a documented <noscript> iframe fallback), legal/*, schema/rating-scope, integrity/signals, social/share-buttons, social-profiles.
  • The remaining a11y rules (aria-, names, labels, headings, landmarks, tables, lists, color-contrast, object-alt, input-image-alt, video-captions), mobile/, video/*, images/figure-figcaption (info only) and images/svg-inline: <noscript> payloads in the wild are pixels, iframes and stylesheets, not these elements. Switching any of them is a one-line change if a case turns up.
  • perf/source-maps: left for a separate change that reworks that rule.
  • Outside the rules: the crawler's seed redirect resolution follows a <noscript> meta refresh. Filed as Crawler follows a <noscript> meta refresh when resolving the seed URL #437.

Evidence: the issue's repro, squirrel audit <page> --http -m 1 -f json --refresh, CLI from source

Findings on noscript.html that control.html does not have:

Rule main this branch
a11y/frame-title 1 iframe(s) without title attribute gone
images/alt-text 1 image(s) missing alt text gone
images/responsive-size 1 small image(s) may be serving oversized files gone
perf/critical-request-chains 2 critical request chain(s) found (/noscript.css, /style.css) 1 ... (/style.css), as control
perf/lcp-hints 1 likely-LCP image loaded without preload gone
security/sri 1 cross-origin resource without Subresource Integrity gone
security/third-party-cookies 2 known tracking domain(s) detected gone
Health score 29 (control 31) 31 (control 31)

On the branch the two reports differ only in page-identity items (the URL in meta-title and word-count). control.html reports identical findings on main and the branch.

Evidence: true positives still fire (6-page hub fixture)

The hub serves the repro, its control, live.html (the same pixel, iframe, script and stylesheet as live markup), and an extended pair: lazy-load fallback images, a loadCSS Google Fonts fallback, a <style> with @import, a polyfill script, a LinkedIn pixel and a GTM iframe, once inside <noscript> and once live.

  • noscript.html: the 7 rows above gone.
  • noscript-extended.html: 15 rows gone (frame-title, alt-text, dimensions, offscreen-lazy, optimized, responsive-size, cls-hints, critical-request-chains, font-delivery, font-loading, lcp-fetchpriority, lcp-hints, preconnect, sri, third-party-cookies).
  • live.html and live-extended.html: every finding unchanged; live-extended.html keeps all 15 of the rows its <noscript> twin lost, including frame-title, alt-text, sri, third-party-cookies, critical-request-chains with /noscript.css, dimensions, cls-hints, font-delivery and preconnect.
  • Health score 47 both runs; checks 448 pass / 131 warn / 22 fail on main, 458 / 114 / 18 on the branch.

#435: aria-required-children ignored implicit roles

Cause. The rule only matched [role="radio"] for a radiogroup (and a short list of native tags for a few other roles).

Fix. New a11y/implicit-role.ts maps native elements to their HTML-AAM / ARIA in HTML roles (input types, li, tr, td/th with grid and scope variants, option, thead/tbody/tfoot, fieldset/details/optgroup, select, img, a[href], landmarks, ...). Each candidate's role is the first valid explicit token, else the implicit role; none/presentation is ignored on a focusable element or one with a global ARIA attribute. The rule follows aria-owns (with cycle protection) and skips <noscript> content. A native wrapper (fieldset, details, optgroup, tbody) satisfies a container only through the items inside it; an explicit role="group" still counts on its own, as before.

Evidence

Fixture main this branch
issue repro (/) fail: div[role="radiogroup"]: needs child with role=radio pass
implicit.html fail: radiogroup of label > input[type=radio], tree of a bare fieldset fail: the tree only (a fieldset wraps treeitems, it is not one)
violations.html fail, 5 elements: 3 radiogroups (labels only, checkboxes, a radio with role="menuitemradio"), tablist of buttons, menu of li fail, 6 elements: the same 5 plus div[role="list"] whose only li has role="none"

#427: csp-wildcard fired on host wildcards

Cause. scriptSrc.includes("*") matched the * inside https://*.posthog.com.

Fix. Sources are lowercased whole tokens, split on whitespace and on the commas of a joined policy list. csp-wildcard fires for a source whose host is a bare * (*, https://*, *:443), which still covers every "any host" form the substring match caught; keywords match case-insensitively.

Evidence (CSP set in the response header)

script-src main this branch
'self' https://*.posthog.com https://*.googletagmanager.com csp-wildcard nothing
'self' * csp-wildcard csp-wildcard
'self' https://*.example.com 'UNSAFE-INLINE' data: csp-wildcard csp-unsafe-scripts (CSP allows 'unsafe-inline')

Real-site smoke

squirrel audit https://squirrelscan.com/ -m 20 --http -f json --refresh before and after: identical findings, score 79, 2366 pass / 100 warn / 22 fail on both. That site has no <noscript>, no CSP header and no ARIA containers, so this is a no-change check only.

Tests

  • packages/rules/tests/noscript-content.test.ts (94): per touched rule, the snippet inside <noscript> reports exactly what the page without it reports, and the same snippet live adds a warn/fail/info finding. Plus nested cases (picture with a <noscript> fallback img, a <noscript> WebM source), the template-key vs font-loading verdict agreement, the helpers and the stripper's tokenizer edge cases.
  • packages/rules/tests/aria-required-children.test.ts (56), packages/rules/tests/csp.test.ts (18), packages/parser/tests/noscript-resources.test.ts (5).
  • On main: 38 of the noscript cases fail (every <noscript> case, the true-positive cases pass), 13 aria/csp cases fail, 4 of 5 parser cases fail.
  • Existing suites re-run green: sri, cwv-reuse, font-delivery, lazy-above-fold, lcp-fetchpriority, carousel-hidden-eager, unminified-css/js, aspect-mismatch, blocked-links, integrity, integrity-cloaking, js-libraries-prefilter, script-loading, rule-verdict-scope, ws4-rule-batches, template-verdict-page-independence; parser attribute-case and headings; audit-engine template-cluster-key-golden, template-fanout-equivalence-golden, template-fanout-parity-golden, cloud-prefetch.
  • tsgo --noEmit clean in apps/cli, packages/rules, parser, utils, audit-engine; bun run lint and format:check clean in apps/cli; tangly check --strict passes; detect-secrets clean.

Docs

docs/rules/index.mdx gains a "Content inside noscript" section listing the affected rules, each affected rule page says so in "What squirrel checks", and the aria-required-children and csp pages describe the new matching, with message templates rather than filled examples.

nc9 added 3 commits October 2, 2026 08:41


A browser with scripting enabled parses <noscript> content as raw text, so
the tracking pixels, GTM iframes and fallback stylesheets sites put there
never load or render. Rules read them as live DOM and reported markup that
never runs.

- utils: isInsideNoscript, querySelectorAllOutsideNoscript and
  stripNoscriptMarkup (a linear tokenizer for the raw-source scans).
- parser: image, script and stylesheet extractors skip <noscript> content;
  link extraction keeps it.
- rules: the image, perf (incl. the shared CWV hints), sri,
  third-party-cookies, mixed-content, frame-title, meta-refresh and
  image-redundant-alt rules select through the helper.
- integrity/fingerprint: the template key pins only live assets, so
  template-scoped rules that now skip <noscript> stay sound under fan-out.
- audit-engine: blocklist URL collection skips <noscript> scripts.

Signed-off-by: Nik Cubrilovic <[email protected]>
A native <input type="radio"> is a radio; the rule only accepted an explicit
role="radio" and failed role=radiogroup groups of native radios.

New a11y/implicit-role.ts maps native elements to their HTML-AAM roles
(input types, li, tr, td/th, option, rowgroups, groups, ...). The rule now
resolves each owned element's role as the first valid explicit token, else
the implicit role, with presentational-role conflict resolution. It follows
aria-owns (with cycle protection), skips <noscript> content, and a native
wrapper (fieldset, details, optgroup, tbody) counts only through the items
inside it.

Signed-off-by: Nik Cubrilovic <[email protected]>
csp-wildcard used a substring match, so the * in https://*.posthog.com read
as "any host". Sources are now lowercased tokens (split on whitespace and
the commas of a joined policy list); csp-wildcard fires for a source whose
host is a bare * (*, https://*, *:443), and keywords match case-insensitively.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the fix/rules-noscript-aria-csp branch from bffbccf to fa001d9 Compare October 1, 2026 22:41
@nc9
nc9 merged commit e4255c0 into main Oct 1, 2026
14 checks passed
@nc9
nc9 deleted the fix/rules-noscript-aria-csp branch October 1, 2026 22:50
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.

Rules treat <noscript> content as live DOM (frame-title, sri, alt-text, lcp-hints, critical-request-chains, ...)

1 participant