Skip to content

fix(tech-detect): inline loaders under litespeed/rocket-loader types and in large Next.js flight scripts are read again #1435 - #1436

Closed
nc9 wants to merge 3 commits into
mainfrom
fix/tech-markup-regression-1435
Closed

nc9 wants to merge 3 commits into
mainfrom
fix/tech-markup-regression-1435

Conversation

@nc9

@nc9 nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1435

v0.0.149's pageMarkup (#1431) kept an inline <script> body only when it was at most 16 KB and its type was a JavaScript MIME type. That lost real loader installs: Clarity on 29 corpus sites (16 Next.js App Router layouts whose next/script snippet sits in a self.__next_f.push script over 16 KB, 3 litespeed/javascript, 1 Cloudflare Rocket Loader <hash>-text/javascript) and the same loaders of other vendors.

Change

  • A script is read unless its type is a data type: JSON (JSON-LD, __NEXT_DATA__, __nuxt_data__), import maps, speculation rules, templates, text/html|css|markdown|csv|xml. Any other type is read: litespeed/javascript, Rocket Loader's <hash>-text/javascript, Partytown, a consent tool's text/plain. A deny-list of data types instead of an allow-list of JS types, so the next cache wrapper is not a regression.
  • The 16 KB cap stays for ordinary inline scripts (it is what keeps inlined bundles out). A Next.js flight script (self.__next_f / self.__next_s at its start) is read up to 2 MB. 8 MB of inline text is read per page in total.
  • Unchanged: text between tags, comments, <a>, <meta> (a CSP meta included) are not read.

Tests

script-url-wrappers-1435.test.ts (9): LiteSpeed, Rocket Loader, other executable types, a 16 KB+ flight script with the layout snippet (with and without script bodies attached), a non-flight 16 KB+ script is not read; negatives: CSP meta, prose, link, JSON-LD, __NEXT_DATA__, __nuxt_data__, import map, template, and a data type with a wrapper-like prefix; cost and per-page cap. The #1430 tests stay green.

Checks

  • 22 real library bundles (react, vue, sentry, clerk, stripe, firebase, ...), inlined and external, with and without bodies attached, against v0.0.149 main: no differences, none added.
  • Cost on a 5.3 MB tag-heavy page, bodies attached: 517 ms on main, 533 ms here; script-heavy 4.8 MB and a 1.6M-tag worst case unchanged (the data block is skipped at no cost).
  • All tech-detect suites and the CLI tech-detect parity, limits and fit tests pass.
  • Review round: type deny-list extended (x-tmpl|mustache|handlebars|jquery-tmpl|jsrender|underscore|ejs, shader, octet-stream); a leading comment no longer hides a flight script; a flight script over 2 MB is cut at 2 MB, not dropped; the secret-scan fixture hex is built at run time.
  • Known: a Next.js flight script carries the page's rendered content as strings, so a vendor URL that is only content (JSON-LD sameAs, meta description, CSP meta, link, prose) matches inside it, as it did before fix(tech-detect): script-url signatures always read the page markup #1430 #1431. Docs and CHANGELOG say so; narrowing the flight read is filed as tech-detect: a Next.js flight script re-opens the prose, link and metadata false-positive classes for script-url signatures #1437.

Docs: cloud/technologies.mdx. Skill change: none.

nik

ReDoS audit (automated flag, #1436)

Every regex in pageMarkup and its helpers, driven with adversarial 1 MB and 5 MB inputs (script-markup-redos-1435.test.ts, 17 shapes, each under 3 s): repeated <script openers with no >, unbalanced and alternating quotes, <a x='> repeated, a 5 MB type value, an unterminated type, hex and dashes before -text/javascript, a run of spaces before =, many type words, many self.__next_f.push( openers, many small flight scripts, comment prefixes, scripts that never close, runs of < and >.

  • Found: the flight-start pattern I added in the previous round (^\s*(?:\/\*[\s\S]{0,200}?\*\/\s*|\/\/...)*...) had a nested quantifier: 512 characters of /* x */ repeated took about a second per script, so a page of many such scripts hung the scan (a 5 MB page did not finish in 120 s). It is replaced by a linear scan (startsAsFlightScript, no regular expression). The shape is a test and fails on the old pattern.
  • Not a risk: the data-type list (plain alternation of literals, now applied to the first 256 characters of the type), the tag-name and type attribute patterns (anchored or single-pass, the tag text bounded to 64 KB), </script search (one forward scan), the quote-aware tag end (bounded to 64 KB then the first >).
  • Unrelated and unchanged: some detectors outside this change take 5 s on a 5 MB run of <img alt="; the same input takes 5.4 s on v0.0.147, so it is not from fix(tech-detect): script-url signatures always read the page markup #1430 #1431 or fix(tech-detect): inline loaders under litespeed/rocket-loader types and in large Next.js flight scripts are read again #1435 #1436.

…and in large Next.js flight scripts are read again #1435

Signed-off-by: Nik Cubrilovic <[email protected]>
…tion, flight cut not dropped, runtime fixture hex, flight caveat in docs #1435

Signed-off-by: Nik Cubrilovic <[email protected]>
Comment thread packages/tech-detect/src/detect.ts Fixed
…ntifier pattern backtracked); ReDoS tests for every pageMarkup shape #1435

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.150 as d88f1724 404efa2a b9c44002 via #1438. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.150. Closing this original.

nik

@nc9 nc9 closed this Oct 31, 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.

Tech detection: inline loaders behind LiteSpeed, Rocket Loader or a large Next.js flight script are no longer read (Clarity −29 sites since v0.0.149)

2 participants