Repository navigation
feat(rules,engine): leaked-secrets scans comments, framework payloads, same-origin source maps and config endpoints #362 - #2259
Merged
Conversation
nc9
force-pushed
the
boat/leaked-secrets-sources-362
branch
2 times, most recently
from
November 22, 2026 22:18
40adeea to
b77b07f
Compare
4 tasks
nc9
marked this pull request as ready for review
November 23, 2026 02:14
…, same-origin source maps and config endpoints #362 Signed-off-by: Nik Cubrilovic <[email protected]>
…es URLs with credentials #362 Signed-off-by: Nik Cubrilovic <[email protected]>
… a token never reaches a label #362 Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
boat/leaked-secrets-sources-362
branch
from
November 23, 2026 20:32
b77b07f to
ec0589a
Compare
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.
Summary
security/leaked-secretsnow reads the places a repository scanner cannot see. Closes #362.html-comment.serializeChildrengained comment replacement for this.__NEXT_DATA__, Nuxt__NUXT__/__NUXT_DATA__, Remix__remixContextor SvelteKit__sveltekit_*/data-sveltekit-fetchedreports atframework-payload. The item label names the framework and the loader to fix, andmeta.frameworkcarries the name. These count as browser-served, so a server-only key there is critical (as it was atinline-script).packages/audit-engine/src/secret-sources.ts) runs after the script fetch. A pure planner in the rules package (security/secrets/sources.ts) picks same-origin source maps (theSourceMap/X-SourceMapheader, else thesourceMappingURLcomment) and same-origin config literals (/config.json,/env.js,*-config.json,/api/config,/.well-known/...). The bodies reach the rule assite.secretSources. A map'ssourcesContentis scanned atsource-map (<map url>), skippingnode_modulessources. A config is scanned atconfig-endpoint (<url>), unless the response is an HTML shell.SECRET_SOURCE_FETCH_LIMITS.MAX_FETCHES), the two kinds taken in turn. Each URL costs exactly one request: the new script-fetcher optionsmaxRetries: 0andfollowRedirects: falsemean no retry and no redirect followed. The step uses the sharedFetchBudget, the own-site egress policy and the script size cap. It only runs while the rule is enabled. Cross-origin URLs are never planned.Design notes for review:
shared/framework-payload.ts(perf rule) tallies payloads page-wide. This PR uses its own per-element classifier because the scanner labels each script it reads.Acceptance criteria
sourcesContentof a same-origin source map reports atsource-map (<map url>):leaked-secrets-sources-362.test.ts(rules) "a key in a source map's sourcesContent reports at source-map ()". The corpussource-mapcontext also passes for every generator.__NEXT_DATA__or__NUXT__reports atframework-payload, with the framework named in the message: rules test "framework-payload (security/leaked-secrets: scan the sources a repo scanner cannot see (source maps, config endpoints, framework payloads, comments) #362)" (Next.js, Nuxt x2, Remix, SvelteKit; the label contains "the Next.js NEXT_DATA payload", andmeta.framework). The corpusnext-data/nuxt-payloadcontexts moved toframework-payload.config-endpoint (<url>): rules test "a key in a same-origin config reports at config-endpoint ()". The engine test "same-origin maps and configs are fetched" covers the fetch side, and the corpusconfig-endpointcontext passes.html-comment: rules tests "a key inside an HTML comment reports at html-comment, once" and "the HTML pass no longer reads the comment's text". The corpushtml-commentcontext moved tohtml-comment.tests/leaked-secrets-sources-362.test.tscovers four cases with a local server that counts hits. (1) 40 referenced targets produce exactly 10 requests. (2) A spentFetchBudgetsends nothing. (3) Cross-origin maps and configs get 0 hits on the other origin. (4) A same-origin 302 to another origin is not followed: 1 request, 0 hits there. Planner unit tests cover the cross-origin,data:and cap-of-10 cases.contexts.tsaddssource-mapandconfig-endpointand relabelshtml-comment,next-dataandnuxt-payload.expected.jsonwas regenerated: the diff is only location relabels (204inline-scripttoframework-payload, 102htmltohtml-comment) plus 204 new rows for the two new contexts.Gates (local; no CI dispatched)
packages/rules: format:check, lint, typecheck clean.bun run scripts/test-suites.ts --run rules: 12866 pass, 26 todo, 0 fail (416 files).packages/audit-engine: format:check, lint, typecheck clean.bun run scripts/test-suites.ts --run audit-engine: 2423 pass, 3 skip, 0 fail (256 files).packages/utils: format:check, lint, typecheck clean.docs/:make validateclean (74 script tests pass).bun scripts/changelog.ts checkOK.followRedirects: falsefails the redirect test. Unblanked comments would report athtml. Expected values are literals (10, labels), not imported constants.Agent skill
The squirrelscan agent skill may want to mention the four new locations when it explains leaked-secrets findings. The maintainer can file a
skillsissue for this.Hold-list (security, new outbound requests): draft for planning review.