Safeguard
Developer Tools•

How do you allowlist secret scanner false positives safely?

Suppress false positives with narrow, reviewed, expiring exceptions instead of broad path rules, so the allowlist does not become a hiding place.

Safeguard Security Team
3 min read

Make every exception narrow, give it a reason, have someone review it, and give it an expiry. Allow one exact value or one line, not a whole directory. An allowlist with no reasons and no owner is where real leaks quietly hide.

Why allowlists go wrong

Developers want the red build to go away. The quickest fix is a broad rule: ignore the whole test folder, ignore this file type. Months later a real key sits in that folder and nothing alerts. Each broad exception is a permanent blind spot.

Exception types, narrowest first

TypeScopeRisk
Inline comment on one lineOne lineLow
Exact value allowlistOne string everywhereLow if the value is truly fake
File levelOne fileMedium
Path or folderMany filesHigh
Rule disabledEverywhereHighest

The detect-secrets project supports an inline pragma, for example, that excludes a single line or the next line from detection without regenerating its baseline, and a mode for listing all such exceptions for review. Other tools have equivalent features under other names.

Rules for a healthy allowlist

  1. Reason required. Each exception explains why the value is not a secret, for instance "documented example token".
  2. Owner named. Someone answers for it.
  3. Review in pull requests. Treat allowlist changes as security relevant changes.
  4. Expiry. Add a review date. Stale exceptions get re-checked.
  5. Prefer fixing the cause. Replace realistic fake values with obviously fake ones.
  6. Standard test values. OWASP recommends using standard test secrets across the organisation to reduce false positives. Publish a short list teams can copy.
  7. List and count exceptions monthly. A rising count is a signal.

A review checklist for exceptions

  • Is the value truly not a credential? Test it against the issuer if unsure.
  • Could the exception hide other values nearby?
  • Is the file shipped to customers or only used in tests?
  • Is there a safer fake value that would not trigger the rule?

Tune the rule instead, when the pattern repeats

If the same kind of false positive appears across teams, fix the rule: require a keyword nearby, raise a threshold, or exclude generated files such as lockfiles. Read what entropy means in secret scanning. For fixture design, see fake credentials in test fixtures.

Quick check

Is it OK to allowlist a whole test directory?

Usually not. Test directories can hold real keys that developers pasted for convenience. Prefer line level exceptions or fix the fixture values.

Who approves exceptions?

The code owner for the file, with security reviewing changes to shared rules. Keep the approval in the pull request history.

Safeguard policies and gates can be set to block new findings on pull requests, and you can try a free scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.