What the entropy plugins measure#
detect-secrets runs three kinds of plugins. Its README at v1.5.0 describes the entropy detector as one that "searches for "secret-looking" strings through a variety of heuristic approaches. This is great for non-structured secrets, but may require tuning to adjust the scanning precision." The two entropy plugins, Base64HighEntropyString and HexHighEntropyString, look only at quoted strings made entirely of their character set and report one when its Shannon entropy passes a limit. The README gives the defaults: the base64 limit "defaults to 4.5" and the hex limit "defaults to 3.0", in bits per character.
Both defaults sit at three quarters of their alphabet's maximum: a hex character carries at most 4 bits and a base64 character at most 6. Random hex at the lengths digests and IDs use clears 3.0 easily; the 32- and 64-character values below score 3.562 and 3.829. SHA-256 digests, UUIDs written without dashes, commit SHAs, nonces and HMACs are all random by design. They clear the limit for the same reason a real key does, which is why an entropy finding cannot settle the question on its own.
The entropy plugins judge the value alone. Regex plugins such as MailchimpDetector or AWSKeyDetector work the other way: they match a provider's key shape and ignore entropy. The finding's type field tells you which kind fired, and that changes what evidence you need.
A scan with four findings#
This constructed repository has four quoted values: a SHA-256 of a vendored tarball, a tenant UUID stored without dashes, a webhook signature in a test fixture and a list-sync key. Every value was generated locally for the fixture. Scanned with detect-secrets 1.5.0 (pip install detect-secrets, Python 3.11):
$ detect-secrets scan --all-files . > baseline.json
$ python3 -c '...print each result...' baseline.json
app/mailer.py:3 Mailchimp Access Key
app/settings.py:3 Hex High Entropy String
deploy/artifacts.toml:3 Hex High Entropy String
tests/fixtures/webhook.json:3 Base64 High Entropy String
Each result in the baseline carries a type, a file, a line and a hashed_secret (a SHA-1 of the value), with "is_verified": false. The baseline does not hold the value itself, so you read it from the file. A short script computes the Shannon entropy of each flagged value the same way the plugin does:
$ python3 entropy.py deploy/artifacts.toml:3 app/settings.py:3 tests/fixtures/webhook.json:3 app/mailer.py:3
deploy/artifacts.toml:3 len= 64 hex H=3.829 bits/char
app/settings.py:3 len= 32 hex H=3.562 bits/char
tests/fixtures/webhook.json:3 len= 44 base64 H=5.050 bits/char
app/mailer.py:3 len= 36 base64 H=3.896 bits/char
The checksum scores higher than the UUID, and the test fixture has the highest entropy of the four. The one value that is a credential does not clear the base64 limit at all; a format rule reported it. Ranked by how far each value clears its limit, the credential would come last.
Collect the fact that identifies each value#
A hash is a hash if you can reproduce it from its input. The sha256 line in artifacts.toml is checked against the file it names:
$ sha256sum vendor/libfoo-1.2.0.tar.gz
86b74674f4fd...4a4ebba1 vendor/libfoo-1.2.0.tar.gz
$ grep sha256 deploy/artifacts.toml
sha256 = "86b74674f4fd...4a4ebba1"
An identifier is an identifier if the code parses and uses it as one. The tenant value parses as a version 4 UUID and is never sent as a credential:
$ git grep -n DEFAULT_TENANT
app/settings.py:3:DEFAULT_TENANT = "142e...b5cf"
app/settings.py:4:TENANT_UUID = uuid.UUID(hex=DEFAULT_TENANT)
$ python3 -c 'from app.settings import TENANT_UUID as t; print(t.version, t.variant)'
4 specified in RFC 4122
The same UUID with its dashes is not reported at all, because the built-in is_potential_uuid filter "Ignores uuid looking secret values" (filters documentation) and its pattern requires the dashes. Storing UUIDs in their dashed form removes this class of finding.
Test data is test data if it is derived from a test-only key and only tests read it. The fixture signature is an HMAC that the test recomputes from a key named in the test file:
$ git grep -n TEST_SIGNING_KEY
tests/test_webhook.py:3:TEST_SIGNING_KEY = b"test-only-signing-key"
tests/test_webhook.py:7: mac = hmac.new(TEST_SIGNING_KEY, fx["event"].encode(), hashlib.sha256).digest()
$ python3 -c 'import tests.test_webhook as t; t.test_signature_matches(); print("match")'
match
Confirm, too, that the production signing key is a different value held outside the repository. If the fixture had been captured from a real webhook, the signature would be harmless but the key that produced it would not.
When the value that looks like a hash is a token#
The fourth finding is the disconfirmation. LIST_SYNC_KEY starts with 32 lowercase hex characters, the length and alphabet of an MD5 digest, and a reviewer skimming the line could call it a checksum. Two facts contradict that. Its suffix matches the shape the scanner's Mailchimp rule encodes, [0-9a-z]{32}-us[0-9]{1,2} (mailchimp.py at v1.5.0), and the code sends it as a password to the API host whose data center number matches that suffix:
$ git grep -n LIST_SYNC_KEY
app/mailer.py:3:LIST_SYNC_KEY = "f18e...-us6"
app/mailer.py:8: auth=("anystring", LIST_SYNC_KEY),
$ detect-secrets scan --string "f18e...-us6"
Base64HighEntropyString : False (3.896)
HexHighEntropyString : True (3.629)
MailchimpDetector : True (unverified)
(The --string run used the full value; it is shortened here.) The 32-character prefix on its own clears the hex limit with 3.629 bits per character, close to the UUID's 3.562, so nothing in the entropy separates it from an identifier. The usage does. A value passed as auth=, a bearer header or a connection-string password is a credential, and the response is to revoke it with the provider, move the replacement into a secret store and only then remove it from the code.
(unverified) means the scan did not call the provider. detect-secrets can verify some formats against the live API, but sending a found credential to a service is a decision for whoever owns it, not a triage step. The format match and the call site are enough to act.
The scanner's own caveat applies in the other direction: it "merely implements several heuristics to try and prevent obvious cases of committing secrets" (README, Caveats), and it lists login = "hunter2" as something it does not find. A clean entropy scan does not show that a file holds no credentials.
Decide each finding#
| Finding | Evidence to collect | Decision |
|---|---|---|
Hex string next to a file name or sha256 key | Recompute the digest of the named file | Dismiss as a checksum if it matches; record the command |
| Hex string the code parses as a UUID or ID | git grep the name; confirm it is never sent as a credential | Dismiss as an identifier, or store it dashed so the filter skips it |
| High-entropy value in a test fixture | Whether a test-only key derives it and only tests read it | Dismiss as test data; add # pragma: allowlist secret with the reason |
Any value passed to auth=, a header or a DSN | The call site and the provider's key format | Treat as a secret: revoke, replace, then remove |
Regex-plugin type such as Mailchimp Access Key | The prefix or suffix the rule matches and who issued it | Treat as a secret unless the provider's documentation lists it as an example |
When a format rule matches a value that a vendor publishes in its own documentation, the guide to documented example credentials covers the evidence for that dismissal. If the value was a real credential and has since been deleted, removing it from the latest commit does not close the finding.