Safeguard
Security Guides•

What is entropy in secret scanning, and why does it cause false positives?

Entropy checks flag random looking strings as possible secrets. Learn what the score means, why hashes trip it, and how to tune it without going blind.

Safeguard Security Team
3 min read

Entropy is a measure of how random a string looks. Secret scanners use it to flag strings that resemble generated keys, even when no known pattern matches. It catches unusual secrets, but it also flags hashes, identifiers and encoded data, so it is the noisiest detection method and needs tuning.

What entropy means here

Shannon entropy, in this context, scores how evenly the characters in a string are spread. A word like "password" scores low because few distinct characters repeat in a predictable way. A 40 character string of mixed letters and digits scores high.

Real keys are usually random, so they score high. That is the whole idea: if a string is long, random looking and sitting next to a name like "token", it might be a secret.

Two ways scanners find secrets

MethodHow it worksStrengthWeakness
Pattern rulesMatch known formats, such as a fixed prefix and lengthFew false positivesMisses formats it has no rule for
Entropy checksFlag high randomnessFinds unknown formatsMany false positives

Most good setups use both. Patterns give precise alerts for popular services. Entropy is the safety net for internal or custom secrets.

Why entropy flags harmless strings

Plenty of legitimate content is random looking:

  • commit hashes and file checksums
  • UUIDs and database identifiers
  • base64 encoded images or fixtures
  • lockfile integrity values
  • minified or generated code

Entropy cannot tell a checksum from a password, because both look random. Context can: a variable named api_key is more suspicious than one named checksum.

How to tune it

The detect-secrets project documents separate detectors for base64 and hex strings, with default thresholds of 4.5 and 3.0. Raising a threshold means fewer alerts and a higher chance of missing a real key. Lowering it does the opposite. There is no right number, only a tradeoff you choose on purpose.

Practical steps:

  1. Exclude generated paths such as lockfiles, vendor folders and build output.
  2. Require a keyword nearby, such as key, secret, token or password, before alerting on an entropy hit.
  3. Use a shared set of obvious test values so fixtures are recognised. OWASP suggests standard test secrets across an organisation to cut false positives.
  4. Review a sample of alerts monthly and adjust.
  5. Keep pattern based detectors for the services you actually use at full strength.

Try it yourself

Click through it at your own pace, or open it full screen. Notice how ongoing checks surface new findings over time, which is why tuning noise matters.

Quick check

Is a high entropy string always a secret?

No. Hashes, identifiers and encoded data are high entropy too. Treat it as a lead to check, not a verdict.

Can I turn entropy detection off?

You can, but you will lose coverage of custom secrets with no known format. Tuning is usually better than switching it off.

For fixtures, see fake credentials in test fixtures without scanner noise. You can also run a free Safeguard scan to see how findings are grouped.

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.