Skip to content

Fix false secret matches in source maps - #655

Merged
sandstream merged 25 commits into
mainfrom
fix/build-sourcemap-false-positive
Oct 30, 2026
Merged

sandstream merged 25 commits into
mainfrom
fix/build-sourcemap-false-positive

Conversation

@sandstream

@sandstream sandstream commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Problem

The built-output secret scan can treat escaped source-map code as one opaque credential. This causes a false failure on a generated SvelteKit server source map.

Change

Scan each decoded source-map source separately. Preserve duplicate fields and decode metadata for the scan. Invalid maps, ambiguous keyed values, source maps over 5 MiB, maps with more than 100,000 source entries or string tokens, and maps with excessive nesting produce an explicit incomplete result. The scan retains credentials found before it reached a limit. The command, check summary, JSON output, handoff and scan comparison distinguish an incomplete scan from a confirmed finding.

The direct build scan excludes known test artifact paths, matching the automatic check. Use --include-tests to include them. The documented path rules do not exclude directories named test or tests.

Existing limits: oversized or unreadable build artifacts other than source maps can still be skipped without an incomplete result. Directory read failures and files beyond the traversal limit can also go unreported. This change does not address those behaviors.

Validation

  • Reproduced the false finding with a source-map regression test before the change.
  • Ran the built-output check against the affected local SvelteKit build. The check passed.
  • Ran focused scanner, redaction and reporting tests, including synthetic credentials, duplicate fields, nested sections, malformed maps, and a large source map.
  • Independent review found high memory and CPU use for source maps with many entries. The scanner now processes source contents individually and bounds the number of entries. The updated change is under review.
  • Built Kit and ran the security and review gates locally. Node runtime freshness reported a warning.

This changes a security check. Human review is required before merge.

Decode embedded sources separately so escaped quotes cannot combine code into an opaque secret match. Preserve other fields and duplicate keys for scanning.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Keep source contents separate without retaining every source in memory. Split tests to satisfy the standards gate.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Continue scanning after non-string entries and avoid running credential patterns for strings too short to match.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Report an incomplete check when a source map has too many entries, instead of allowing unbounded per-source work.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Bound nested source-map work and report oversized maps. Keep partial findings in the security check and direct scan command.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Report invalid maps as incomplete and preserve metadata findings when a source limit is reached.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Report non-array source content as incomplete and scan decoded source text without treating it as metadata.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Inspect decoded strings in malformed objects and retain detected credentials while marking the scan incomplete.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Keep key-value context for opaque credentials while scanning decoded source strings separately.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Inspect decoded text separately to avoid false positives and retain recognizable findings from incomplete maps.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Avoid treating encoded code as a credential when a keyed value cannot be safely classified.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Retain later findings and exclude incomplete test artifacts from the automatic bundle check.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Apply the test-artifact exclusion to the source maps of compiled tests and specs.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Report scan coverage and confirmed findings separately across CLI, JSON, handoff, and scan comparisons. Keep scanner tests within project gates.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Comment thread src/ci.test.ts Fixed
Comment thread src/ci.test.ts Fixed
Comment thread src/ci.test.ts Fixed
Exclude test artifacts by default in the direct scan and allow explicit inclusion. Verify the compiled flag surface.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Detect provider credentials in unfinished JSON strings and treat newly confirmed findings as regressions.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Limit raw fallback to safe credential patterns and avoid counting the same decoded finding twice.
Read string tokens in one pass so unfinished escaped strings cannot stall the build scan.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Decode a valid partial JSON string to retain credential findings, and document the test exclusion scope.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Retain findings before a dangling backslash in an unfinished source-map string.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Distinguish the string-token limit from the number of source entries.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Only treat a new finding as a regression after an incomplete scan, not an ordinary skipped check.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

Use a private temporary directory for CI fixtures and separate invalid map reporting from the main scan.
@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@github-actions

Copy link
Copy Markdown

Docker image built, scanned, and smoke-tested in CI. The PR image is local to this run and is not published.

@sandstream

Copy link
Copy Markdown
Owner Author
{
  "schema": "kit-independent-review/v1",
  "repository": "sandstream/kit",
  "pull_request": 655,
  "base_branch": "main",
  "base_tip": "e0317417a862e696b3ce14f5704a298584526c2c",
  "base": "58cdbb6d3bc4249a21d5246f31ed2f5f6abc9524",
  "head": "71b44ea105747fec78d43af1d544af6b9c2064bc",
  "verdict": "pass",
  "checks": [
    {"area":"correctness","status":"pass","evidence":"Reviewed source-map parsing, incomplete results, test exclusions, and the direct command. The current merge tree retains both documentation changes."},
    {"area":"security","status":"pass","evidence":"Isolated tests covered credential findings, incomplete scans, malformed source maps, limits, and test artifacts. Existing non-map and traversal limits are documented."},
    {"area":"tests","status":"pass","evidence":"The reviewer ran 144 targeted tests on the merged tree in a network-disabled container. GitHub build-and-test succeeded on the same merged tree, including the full test suite and command contract."},
    {"area":"public-hygiene","status":"pass","evidence":"The clean checkout passed git diff --check. GitHub Gitleaks succeeded on the reviewed head."},
    {"area":"adr","status":"pass","evidence":"The isolated merged-tree ADR gate checked 8 decisions, including 4 enforced decisions, with no violations or gaps. The GitHub ADR gate also passed."}
  ],
  "limits": [],
  "findings": []
}

@sandstream
sandstream marked this pull request as ready for review October 30, 2026 12:30
@sandstream
sandstream merged commit 99840bd into main Oct 30, 2026
29 of 31 checks passed
@sandstream
sandstream deleted the fix/build-sourcemap-false-positive branch October 30, 2026 12:31
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.

2 participants