What is entropy-based secret detection and why does it cause false positives?

IntermediateConceptGitleaks
Answer

Short answer

Entropy measures how random a string looks. Real secrets (API keys, tokens) are long random strings with high entropy, so scanners flag high-entropy strings even when no known pattern matches. But hashes, UUIDs, base64 images and test fixtures are also random-looking — that's where many false positives come from.

Example

password = "hunter2"                                   # low entropy — caught only by keyword rules
token    = "x9Fq2LmZ7vR4tP0aK8sW3nY6bE1cD5gH"          # high entropy — flagged
sha256   = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"   # also high — usually a false positive

How Gitleaks balances it

Rules combine a regex, keywords and an entropy threshold — e.g. only flag api_key = "<value>" when the value's entropy is above ~3.5. Tune per rule and allowlist known noisy paths (lockfiles, test fixtures).

What to say in the interview

"Entropy detection flags random-looking strings, catching unknown key formats but also hashes and fixtures. Gitleaks combines regex, keywords and entropy thresholds per rule, and we allowlist known noisy files like lockfiles."

All Security Tools questions Roadmap: Gitleaks — secret scanning

More on Gitleaks