fix(security): stop Gitleaks allowlist from suppressing real localhos… - #1272
Merged
hman38705 merged 2 commits intoAug 1, 2026
Conversation
…t credentials
The global [allowlist].regexes list contained bare, unanchored `localhost`,
`127.0.0.1` and `example.com` patterns. Gitleaks matches allowlist regexes
against the finding's secret, so any finding merely *containing* one of those
substrings was suppressed -- including a genuine leak such as
`postgres://user:RealLeakedPassword@localhost:5432/db`.
Replace all three with a single anchored (^...$) pattern that matches only a
complete connection string whose password is a well-known placeholder token
(password, changeme, postgres, your_password, xxx, ...) on a loopback or
example.* host. It can therefore only ever suppress a non-secret: a real
credential on localhost is now reported, and a placeholder password on a real
host (postgres://postgres:postgres@prod-db.internal:5432/db) still is too.
Two supporting rule fixes were required to make this work:
- `postgres(ql)?` -> `postgres(?:ql)?`. Gitleaks reports capture group 1 as the
finding's secret, so `postgresql://` URLs reported a secret of literally ql
while `postgres://` URLs reported the full match. The allowlist was thus
unreachable for the former and over-broad for the latter. This also clears
two long-standing false positives on the CI placeholder DSN in
.github/workflows/performance.yml.
- Broaden the password character class from [a-zA-Z0-9_-] to accept punctuation,
since real passwords contain it and `...Password123!@localhost` previously did
not match the rule at all. `$ < > { } ` are excluded so shell and Terraform
interpolations are not reported as leaks.
Verified with gitleaks 8.30.1:
- 15-case fixture: all 8 real-credential cases flagged, all 7 placeholder cases
allowlisted.
- Working tree: 12 findings -> 10, zero new findings; the 2 removed are the
performance.yml false positives.
- Full history (483 commits): 361 -> 357, zero new findings.
- Scratch file with postgres://user:RealLeakedPassword123!@localhost:5432/db is
flagged; postgres://user:password@localhost:5432/db is allowlisted.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
@lemarjohnny781 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
…t credentials
The global [allowlist].regexes list contained bare, unanchored
localhost,127.0.0.1andexample.compatterns. Gitleaks matches allowlist regexes against the finding's secret, so any finding merely containing one of those substrings was suppressed -- including a genuine leak such aspostgres://user:RealLeakedPassword@localhost:5432/db.Replace all three with a single anchored (^...$) pattern that matches only a complete connection string whose password is a well-known placeholder token (password, changeme, postgres, your_password, xxx, ...) on a loopback or example.* host. It can therefore only ever suppress a non-secret: a real credential on localhost is now reported, and a placeholder password on a real host (postgres://postgres:postgres@prod-db.internal:5432/db) still is too.
Two supporting rule fixes were required to make this work:
postgres(ql)?->postgres(?:ql)?. Gitleaks reports capture group 1 as the finding's secret, sopostgresql://URLs reported a secret of literally ql whilepostgres://URLs reported the full match. The allowlist was thus unreachable for the former and over-broad for the latter. This also clears two long-standing false positives on the CI placeholder DSN in .github/workflows/performance.yml....Password123!@localhostpreviously did not match the rule at all.$ < > { }are excluded so shell and Terraform interpolations are not reported as leaks.Verified with gitleaks 8.30.1:
Description
Type of Change
Testing Done
Bundle Size
Checklist
docs/architecture.mdRelated Issues
Closes #1217