Repository navigation
fix(tech-detect): derive search literals for unhinted detectors and share the window budget #1420 - #1433
Closed
nc9 wants to merge 6 commits into
Closed
fix(tech-detect): derive search literals for unhinted detectors and share the window budget #1420#1433nc9 wants to merge 6 commits into
nc9 wants to merge 6 commits into
Conversation
nc9
added a commit
that referenced
this pull request
Oct 31, 2026
…st of a small script whole, merge the tail span #1420 #1433 corpus losses (tiktok, facebook, posthog loaders in small scripts): - the tail is a span merged with the windows, so nothing between them is dropped and a rest that fits is sent whole - a hit or cut inside a long string, regex or comment is no longer skipped or jumped past: the cut stays and carries the opener, so the scan reads the span as the whole file does - tests: three corpus shapes at cloud and 24 KB caps, whole-rest, single tail, and an inlined-script string that must not match Signed-off-by: Nik Cubrilovic <[email protected]>
…he extras across hints round by round, reserve the tail #1420 Signed-off-by: Nik Cubrilovic <[email protected]> (cherry picked from commit f8cfd44) Signed-off-by: Nik Cubrilovic <[email protected]>
… fold U+0130, pick selective literals, skip escape arguments #1420 Review fixes for the derived-literal sampler: - an inCode detector's window qualifies only when its match starts in code (whole-file string, regex and comment spans), so string mentions no longer use up the 8 windows kept per hint - declared hints get their first 2 windows before any derived hint's first - U+0130 is folded to I before lower-casing, so one dotted capital I no longer disables every case-insensitive literal - the most selective required run is used, not the longest; common words (config, init, account...) are never a literal (GA4 gtag(, Yandex ym(, MailerLite ml() - \x, \u, \c, \k, \p and digit escapes no longer leak their arguments into the literal - soundness test generates strings from every pattern and checks the literal against them - CHANGELOG and docs no longer claim every detector has a literal or a 256 KB start Signed-off-by: Nik Cubrilovic <[email protected]>
…st of a small script whole, merge the tail span #1420 #1433 corpus losses (tiktok, facebook, posthog loaders in small scripts): - the tail is a span merged with the windows, so nothing between them is dropped and a rest that fits is sent whole - a hit or cut inside a long string, regex or comment is no longer skipped or jumped past: the cut stays and carries the opener, so the scan reads the span as the whole file does - tests: three corpus shapes at cloud and 24 KB caps, whole-rest, single tail, and an inlined-script string that must not match Signed-off-by: Nik Cubrilovic <[email protected]>
…kip long regex literals instead of reopening them #1420 Review of #1433: the opener put before a cut inside a long string or regex let quoted text read as code (an escaped quote at the cut closed the reopened string; a / inside a regex class ended it). A cut backs up one char after an odd backslash run, and a long regex is skipped as before. Tests per exploit, tail merge test, harness separator fixed to a real NUL. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/tech-extras-budget-1420-r2
branch
from
October 31, 2026 13:28
6ff784e to
4447b39
Compare
…o in-code pattern #1420 Review of #1433: the opener is a quote and the matcher reads a quote as code, so a cut on the first char after a quote inside a long string completed a quote-initial in-code pattern (Supabase, Firebase, Clerk) with quoted text. Every opener cut (window and tail) now moves on, past an escape pair whole, up to 16 starts, and is dropped when none is clean. Tests: every alignment for a quoted URL, authDomain and publishableKey in ', " and template strings; tail-cut escape, regex and budget cases that kill the surviving mutants. Signed-off-by: Nik Cubrilovic <[email protected]>
| } | ||
|
|
||
| test("a long regex at the tail cut is skipped, not reopened", () => { | ||
| const content = withTail(long("/["), `x/${FAKE}${"z".repeat(600)}]/;\n`).replace("var s=/[", "var s=/["); |
…400 chars #1420 Review of #1433 round 5: the in-code patterns have whitespace runs of any length, so a config padded past 400 chars after a quote hid from the opener check. settle() now probes up to the window end, or the end of the file for the tail. Tests: whitespace-padded Firebase, Clerk and Supabase text with the tail cut on it (1 to 800 spaces, ' and " strings), window moves on instead of dropping. Signed-off-by: Nik Cubrilovic <[email protected]>
Merged
nc9
added a commit
that referenced
this pull request
Oct 31, 2026
…st of a small script whole, merge the tail span #1420 #1433 corpus losses (tiktok, facebook, posthog loaders in small scripts): - the tail is a span merged with the windows, so nothing between them is dropped and a rest that fits is sent whole - a hit or cut inside a long string, regex or comment is no longer skipped or jumped past: the cut stays and carries the opener, so the scan reads the span as the whole file does - tests: three corpus shapes at cloud and 24 KB caps, whole-rest, single tail, and an inlined-script string that must not match Signed-off-by: Nik Cubrilovic <[email protected]> (cherry picked from commit 5fb1418)
nc9
added a commit
that referenced
this pull request
Oct 31, 2026
…kip long regex literals instead of reopening them #1420 Review of #1433: the opener put before a cut inside a long string or regex let quoted text read as code (an escaped quote at the cut closed the reopened string; a / inside a regex class ended it). A cut backs up one char after an odd backslash run, and a long regex is skipped as before. Tests per exploit, tail merge test, harness separator fixed to a real NUL. Signed-off-by: Nik Cubrilovic <[email protected]> (cherry picked from commit 4447b39)
nc9
added a commit
that referenced
this pull request
Oct 31, 2026
…o in-code pattern #1420 Review of #1433: the opener is a quote and the matcher reads a quote as code, so a cut on the first char after a quote inside a long string completed a quote-initial in-code pattern (Supabase, Firebase, Clerk) with quoted text. Every opener cut (window and tail) now moves on, past an escape pair whole, up to 16 starts, and is dropped when none is clean. Tests: every alignment for a quoted URL, authDomain and publishableKey in ', " and template strings; tail-cut escape, regex and budget cases that kill the surviving mutants. Signed-off-by: Nik Cubrilovic <[email protected]> (cherry picked from commit 9cb84fc)
nc9
added a commit
that referenced
this pull request
Oct 31, 2026
…400 chars #1420 Review of #1433 round 5: the in-code patterns have whitespace runs of any length, so a config padded past 400 chars after a quote hid from the opener check. settle() now probes up to the window end, or the end of the file for the tail. Tests: whitespace-padded Firebase, Clerk and Supabase text with the tail cut on it (1 to 800 spaces, ' and " strings), window moves on instead of dropping. Signed-off-by: Nik Cubrilovic <[email protected]> (cherry picked from commit 33fe7e7)
Contributor
Author
|
Landed in v0.0.151 as nik |
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.
Supersedes #1421 (the original author lane stalled). The cherry-picked commit is f8cfd44 rebased onto v0.0.149; the second commit applies the independent review's required fixes.
Refs #1420
What it does
A bundle bigger than its byte cap is read as its first 16 KB, windows around the literals the detectors look for, and the end of the file, in 24 KB. Detectors with no hand-written
hint(Sentry, React, PostHog, Stripe, GA4...) only had whatever the windows left. Now they get a literal derived from their pattern (hint-derive.ts), windows are shared out round-robin (at most 8 qualified windows per hint) and the tail keeps a reserve of min(6 KB, budget / 4).Review findings fixed
inCodedetector only when a match starts in code (whole-file string, regex and comment spans), so string mentions no longer count against the 8 windows (a real Firebase/Supabase/Clerk config after 8 or more mentions was lost). Declared hints also get their first 2 windows before any derived hint's first round.Ibefore lower-casing (the only code point whose lower case changes length, checked over all code points), so one dotted capital I no longer disables the case-insensitive literals.config,init,account,install,window[...) are never a literal. GA4 now usesgtag(, Yandexym(, MailerLiteml(, AppDynamicsadrum-, Swiftype_st(. Measured over 40 built bundles (react, vue, svelte, stripe-js, sentry, posthog, firebase, supabase, clerk, antd, lodash, jquery, jquery-ui, moment, d3, chart.js, zod, core-js...): the most frequent literal now matches 38 times in one bundle (was 610 forconfig); none over 100.\x,\u,\c,\k,\pand the digits after a digit escape no longer leak their arguments into the literal. New unit cases, and a soundness test that generates strings from everyscript-contentpattern (small generator, no new dependency) and checks the literal occurs in each (over 3,000 matches checked).adobe-analyticshas none), no longer say "past the first 256 KB" (sampling starts past the 16 KB head), and say "up to 6 KB (at most a quarter of the budget)". The benefit text is "found past the head in capped scans", with no Sentry-loss claim.Checks
confignoise, PostHog in compA.make validatein docs, scripts/check-released-changelog.sh, tech-detect tests (bundle, pattern-bounds, fingerprints, vibe, local-stack, inline script url, extras, soundness), audit-engine tech tests (incl. supabase and real-build), cli tech tests.No skill change needed (internal sampling, no CLI or output change).
Update 6ff784e: corpus losses vs v0.0.149 (#1433 corpus re-run, 13 sites)
Cause: the tail started after the last kept window, so a loader the window logic had dropped was lost between them (v0.0.149 sent the whole rest of a small script). The window was dropped because the string tracker (a heuristic: a quote in a regex after
}or), a nested template literal) read the loader as part of a long string, which was skipped.ttq.load(at 21 KB, 121 KB withfbq(2 KB from the end, 34 KB withposthog.initat 19 KB) at the cloud and 24 KB caps, rest-whole, tail sent once, and an inlined-script string that must not match.Update 4447b39: review of 6ff784e (rebased onto v0.0.150 816cf28)
/in a class ended it early). Applies to the tail cut and the hit-inside-long-span window cut. Tests per exploit (escaped'and backtick at the cut,[x/in a long regex) fail without the fix.Update: round 4 review of 4447b39
authDomainandpublishableKeyin',"and template strings (fail without the fix); tail-cut cases for the escape back-up, a long regex and the opener plus backed-up char at the exact budget edge (each kills its mutant).Update: round 5 review of 9cb84fc
settlenow probes the text that will be sent (the window end for a window, the end of the file for the tail).'and"strings), and the window and tail move on a char instead of being dropped. Mutants killed: old 400-char probe, no check on the tail, one try.