Repository navigation
fix(tech-detect): bound unbounded fingerprint patterns (requirejs 70 s on hostile page) #1244 - #1245
Merged
Merged
Conversation
nc9
marked this pull request as ready for review
October 29, 2026 00:06
|
Reviewed the diff. The pattern bounds look correct, and I found nothing blocking.
Tests, changelog and the |
|
Review of #1245: no blocking issues. The bounds look correct and each rewrite keeps the original match shape.
I did not run the tests. This review is based on reading the diff. |
…ttern on hostile input #1244 Signed-off-by: Nik Cubrilovic <[email protected]>
…atrace window, 200 KB bound test #1244 Signed-off-by: Nik Cubrilovic <[email protected]>
…und budget for CI headroom #1244 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/tech-detect-unbounded-patterns
branch
from
October 29, 2026 01:11
529e470 to
bd74c42
Compare
|
Reviewed the diff. The bounds look correct and I found nothing blocking. Every rewritten pattern now has a finite window, so worst-case work per start position is capped. I did not run the tests locally.
|
5 tasks
nc9
added a commit
that referenced
this pull request
Oct 29, 2026
…ally from the same bytes (#1256) Closes #1254 ## What - Tech detection reads the first 64 KB of each first-party script bundle, from the bytes the crawl already fetched for the secret rules (`assets.scripts`). No refetch, no extra request. - Caps: 64 KB per bundle (`[tech_detect] bundle_bytes`, 0 to 262144, 0 = off), 512 KB per page, 1 MB per audit. A bundle body is attached to the first page that references it; later pages list its URL only. - New `inCode` flag on `script-content` detectors (`packages/tech-detect/src/js-scan.ts`): the match must start in code, not inside a comment or string literal. Used for Supabase (`createClient` on a 20-char `*.supabase.co` ref), Firebase (`authDomain`, `storageBucket` config) and Clerk (`publishableKey`). Placeholder, short-ref, look-alike-host, comment, docs-string and HTML-only cases are negative tests. - `detectTechnologies` slices every script body to 64 KB and takes a per-page time budget (default 5 s, `onBudgetExceeded`), on top of the #1245 bounded patterns. A 1 MB hostile bundle test asserts it finishes inside the budget. - One shared builder (`buildTechInputs` in audit-engine, `buildTechPageInputs` in the CLI) feeds both the local scan and the cloud payload, so a signed-in and a signed-out audit read the same bytes. Previously the local scan passed non-home page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1244.
Detection scans every stored page with every fingerprint, so a pattern with an unbounded run after a repeatable literal is quadratic on a page that repeats the literal and never closes it.
requirejstook about 70 s on 1 MB of<scriptrepeats (1 MB flood now 114 ms for the whole fingerprint set).Beyond
requirejs(the issue), a scan of every html and script-url pattern, each run on 100 KB to 200 KB (the test now uses 200 KB with a 250 ms budget) built from its own leading literal, found 14 more that took seconds: bulma, foundation-sites, semantic-ui, materialize-css, animate-css (<link[^>]+href="[^"]*/x.css), plausible and fathom (data-domain=.*plausible), facebook-pixel, rudderstack, didomi, ensighten, yotpo (.*/.+in URLs), dynatrace-rum ([_a-z0-9]*), userway. All now have bounded windows (200 to 600 chars; the link patterns also require whitespace beforehref).Where:
data/research-fingerprints.json, the input ofscripts/generate-tech-fingerprints.ts, is not in the repo (the last generated.ts change, #872, also edited it by hand), so the fixes are edits togenerated.tsand toanalytics.ts/ads.ts. Anyone regenerating from an external copy of that data must carry these bounds over.Test:
tests/pattern-bounds.test.tsbuilds hostile input from every pattern's own leading literal (and each top-level alternative), plus repeated tag openers per fingerprint, with a 250 ms budget; it fails on the old patterns (plausible 758 ms, fathom 1037 ms, ...) and passes now. A second block checks the rewritten patterns still match real markup.Gates: tech-detect tests by path (52 pass), audit-engine tech tests by path (22 pass),
test-suites.ts --check, tsgo clean. Agent skill: no change.