Skip to content

fix(rules): ignore credential key-name constants - #1241

Closed
WilliamK112 wants to merge 4 commits into
squirrelscan:mainfrom
WilliamK112:codex/leaked-secrets-key-name-1228
Closed

WilliamK112 wants to merge 4 commits into
squirrelscan:mainfrom
WilliamK112:codex/leaked-secrets-key-name-1228

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • recover the complete bounded configuration key before the generic-assignment detector compares a value with its key
  • preserve syntax-aware hyphen handling and avoid suppressing a finding when the bounded prefix cannot be recovered safely
  • add the reported negative fixtures plus deterministic random alphanumeric and hexadecimal positive controls
  • document the accepted key-name constant form and update the changelog and secret-scan baseline location

Validation

  • bun run scripts/test-suites.ts --run rules (8,118 passed, 25 existing todos)
  • focused leaked-secret suite (2,409 passed, 25 existing todos)
  • bun test packages/rules/tests/security/leaked-secrets-precision.test.ts (23 passed)
  • bun run --filter @squirrelscan/rules typecheck
  • bun run docs:check
  • bash scripts/test-changelog-extraction.sh
  • detect-secrets-hook --baseline .secrets.baseline
  • git diff --check

Fixes #1228

Docs: updated the leaked-secrets rule page. Skill: none.

nc9 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: e8f7d90

Verdict: looks good. Thanks for this. CI is green, the DCO sign-off is present, there is no new runtime dependency, and the CHANGELOG bullet is under [Unreleased]. The findings below are minor.

Low

  • completeKeyOf walks back at most SECRET_KEY_LOOKBEHIND_SIZE * 2 characters and returns only the matched suffix when the budget runs out, so a truncated prefix cannot suppress a real secret. The loop is bounded, so there is no blowup risk on hostile input. Worth one test with a key longer than the budget and a value equal to its truncated form, to lock in that fallback.
  • A value that equals its own key after case and separator folding is now suppressed whichever key it sits under. That is the intent of security/leaked-secrets: generic assignments flag key-name constants whose value is the name itself #1228, and the positive controls (random alphanumeric and hex values) still report.

Notes for the maintainer

  • The .secrets.baseline change is a line-number shift plus a timestamp, as expected for an edit above the allowlisted line.

@nc9 nc9 added bug Something isn't working rules packages/rules — audit rule definitions security Security hardening labels Oct 28, 2026 — with Claude

nc9 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: cab862f

Thanks @WilliamK112. Verdict: no code change since the last review; ready for a maintainer merge decision.

The only new commit on this branch is a merge of main (cab862fd, which brings in #1240). The #1228 change itself is identical to the head reviewed earlier (e8f7d90d), so the earlier findings stand:

  • Correctness and input safety: the key lookbehind in completeKeyOf is bounded, so there is no blowup risk on hostile input. Values equal to their own key after case and separator folding are suppressed, and the positive controls still report.
  • Conventions: DCO sign-off is present on every commit, there is no new runtime dependency, and the CHANGELOG bullet sits under [Unreleased].
  • CI on this head: every finished check is green; CLI tests and the audit engine golden tests were still running when I looked, so wait for those before merging.

Still open from the earlier pass (low, optional): one test with a key longer than the lookbehind budget and a value equal to its truncated form, to lock in the fallback.

Verdict: pending maintainer review (this PR changes secret-detection behaviour).

@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Reviewed head: cab862f

Confirmed: a merge of main only. The #1228 patch is byte-identical to e8f7d90, which was reviewed clean. Good to merge.

nc9 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 3f2bc70

Thanks @WilliamK112. Verdict: pending maintainer review, because this changes secret-detection behaviour. No code change since the last reviewed head.

The only new commit is a merge of main (3f2bc702, which brings in #1243 and touches only tech-detect). The #1228 patch is unchanged from e8f7d90d, so the earlier findings stand: the key lookbehind is bounded, values equal to their own key are suppressed, and the positive controls still report.

Still open from the first review (low, optional): one test with a key longer than the lookbehind budget and a value equal to its truncated form, to lock in the fallback.

Conventions: DCO is present on every commit, no new runtime dependency, CHANGELOG bullet is under [Unreleased]. CI on this head: all checks green.

@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@WilliamK112 this is approved and ready to merge, but v0.0.140 just shipped and the PR now conflicts with main, almost certainly in CHANGELOG.md: the old [Unreleased] bullets moved into the v0.0.140 section. Could you merge main once more and keep your bullet under the new ## [Unreleased] heading? Please leave the released sections untouched. If the only new commit is that merge, it goes straight in with no further review round.

@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Update-branch (merge of main, no rebase): head e8a3b5b = merge commit, parents 3f2bc70 (approved) and 660dcfc (main tip). Non-CHANGELOG patch unchanged: git patch-id --stable a40e180f0df9c7a821836c473baf5119c43efc35 for both, same file list. CHANGELOG bullet under [Unreleased]; released sections equal their tags. Pin for merge once checks are green: e8a3b5b.

@nc9
nc9 force-pushed the codex/leaked-secrets-key-name-1228 branch from e8a3b5b to 67c1d88 Compare October 29, 2026 12:26
@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Update-branch (merge of main, no rebase): head 67c1d88 = merge commit, parents 3f2bc70 (approved) and 421dbf0 (main tip). Non-CHANGELOG patch unchanged: git patch-id --stable a40e180f0df9c7a821836c473baf5119c43efc35 for both, same file list; CHANGELOG bullet under [Unreleased]. Pin for merge once checks are green: 67c1d88.

@nc9 nc9 mentioned this pull request Oct 29, 2026
@nc9

nc9 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Landed, thank you @WilliamK112. Your commit is on main under your name as 37fe29f, shipped in v0.0.141 via the stacked release PR #1272 (the stack was rebase-merged, which is why this PR shows as closed rather than merged). Ignoring credential key-name constants removes a whole class of false positives from the leaked-secrets check. (Nik)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working rules packages/rules — audit rule definitions security Security hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security/leaked-secrets: generic assignments flag key-name constants whose value is the name itself

2 participants