secretdetection.devKeys, tokens and passwords in code

detect-secrets: how Yelp's scanner works, and what it missed in a 20-key test

detect-secrets is Yelp's open-source scanner for blocking new secrets: a baseline file records today's findings, and its pre-commit hook fails anything new.

In a December 4, 2026 test of 20 planted key types with its network checks off, version 1.5.0 found 19, missed an Anthropic key, and flagged 3 of 6 decoys.

Published December 4, 2026 ยท Updated December 4, 2026. Run and read on December 4, 2026 (UTC). Method and sources below.

How does detect-secrets work?

It reads the files git tracks today, not past commits, with 27 plugins, and writes what it finds to a .secrets.baseline file. Its README says this "avoids the overhead of digging through all git history".

Plugin typeWhat it matchesWhat it caught in the test
Format rules (24)One key format each: AWS, GitHub, Slack, Stripe, private keys, JWTs, URLs with a password and moreAWS, GitHub classic, Slack, Stripe live, Twilio, SendGrid, npm and GitLab keys, the private key, the JWT and the database URL
Entropy (2)Base64HighEntropyString, HexHighEntropyString: any long random-looking string in quotesThe only catch for the GitHub fine-grained token, Stripe test, Google and Hugging Face keys
Keyword (1)KeywordDetector: values assigned to names like password or secretThe password in a config file; backed up the OpenAI and hex keys

Plugin list from detect-secrets scan --list-all-plugins, version 1.5.0. Results from the 20 runs below.

Its OpenAI plugin matched only 2 of 20 new-style sk-proj keys; the entropy and keyword plugins caught all 20. Entropy depends on each random value, which is why some types were found in 18 or 19 runs, not 20.

How do you create and update a .secrets.baseline?

Run one scan, commit the file it writes, then let the hook compare each commit against it. Findings already in the baseline don't fail a commit; new ones do.

ToRun
Record today's findingsdetect-secrets scan > .secrets.baseline
Mark each finding real or falsedetect-secrets audit .secrets.baseline
Update the baselinedetect-secrets scan --baseline .secrets.baseline
Scan files git doesn't trackdetect-secrets scan --all-files
Skip checks with providersdetect-secrets scan --no-verify
List the 27 pluginsdetect-secrets scan --list-all-plugins

From the detect-secrets README, read December 4, 2026. An update adds new findings, removes ones that are gone, and keeps your labels.

How do you run detect-secrets as a pre-commit hook?

Add it to .pre-commit-config.yaml with your baseline:

repos:
-   repo: https://github.com/Yelp/detect-secrets
    rev: v1.5.0
    hooks:
    -   id: detect-secrets
        args: ['--baseline', '.secrets.baseline']

Without the pre-commit framework, scan the staged files yourself:

git diff --staged --name-only -z | xargs -0 detect-secrets-hook --baseline .secrets.baseline

For a value you mean to commit, such as a test fixture, end the line with # pragma: allowlist secret, or put # pragma: allowlist nextline secret on the line above. A hook runs only where it is installed, and git commit --no-verify skips it.

What did detect-secrets find in a 20-key test?

19 of the 20 planted key types with its checks off, the same count as Gitleaks. It caught the database URL with a password that Gitleaks missed, missed the Anthropic API key, and flagged 3 of 6 decoys in every run.

Itemdetect-secrets, checks offIts pluginGitleaksTruffleHog
AWS access key ID and secret access key20/20AWS Access Key20/2020/20
GitHub personal access token (classic)20/20GitHub Token20/2020/20
GitHub fine-grained personal access token20/20Base64 High Entropy String20/2020/20
Slack bot token20/20Base64 High Entropy String; Slack Token20/2020/20
Slack incoming webhook URL20/20Slack Token20/2020/20
Stripe live secret key20/20Base64 High Entropy String; Stripe Access Key20/2020/20
Stripe test secret key20/20Base64 High Entropy String20/200/20
OpenAI project API key20/20Base64 High Entropy String; OpenAI Token; Secret Keyword19/2020/20
Anthropic API key0/20none20/2020/20
Google API key19/20Base64 High Entropy String20/200/20
RSA private key (PEM)20/20Private Key20/2020/20
Supabase service_role key (JWT)20/20JSON Web Token20/200/20
Password in a config file20/20Secret Keyword15/200/20
Database URL with a password20/20Basic Auth Credentials0/2020/20
High-entropy hex secret20/20Hex High Entropy String; Secret Keyword19/200/20
Twilio API key20/20Secret Keyword; Twilio API Key20/200/20
SendGrid API key20/20SendGrid API Key20/2020/20
npm access token20/20NPM tokens20/2020/20
Hugging Face access token18/20Base64 High Entropy String20/2020/20
GitLab personal access token20/20GitLab Token20/2020/20
AWS's documented example key pair (decoy)20/20AWS Access Key0/200/20
Placeholder value (decoy)20/20Basic Auth Credentials0/200/20
UUID request ID (decoy)0/20none0/200/20
Package integrity hash (decoy)0/20none0/200/20
Password read from the environment (decoy)0/20none0/200/20
Git commit SHA (decoy)20/20Hex High Entropy String0/200/20

Runs that reported each item, of 20; for a decoy, 0/20 is right. The three decoys it flagged: AWS's documented example key, a placeholder database URL and a git commit hash.

Method. 20 runs on December 4, 2026 (UTC). Each run made a scratch git repo with one commit: 20 fake keys in their real formats, with fresh random values, and 6 decoys. Commands: detect-secrets -c 1 scan --no-verify in the repo, gitleaks git <repo> and trufflehog git file://<repo> --no-verification, with default rules. Versions: detect-secrets 1.5.0, Gitleaks 8.30.1, TruffleHog 3.100.1. A run counts when the tool reported the item's file. No real key was used.

Download: secret-detection-test-2026-12-04.csv (26 rows, with each tool's rule names and a column for detect-secrets with default settings) and secret-detection-tools-2026-12-04.csv (six tools: where each runs, price, license, live-key checks).

Does detect-secrets check whether a key works?

Yes, for 9 of its 27 plugins, and it is on by default: AWS, Slack, Stripe, Mailchimp, Telegram, Cloudant, IBM Cloud IAM, IBM COS HMAC and SoftLayer. A match the provider rejects is dropped from the results.

With default settings, the Slack and Stripe plugins reported none of the fake keys. The fake Slack webhook went unreported in all 20 runs (all 20 found with --no-verify). A scan with checks on sends those matches to the provider. Add --no-verify to keep a scan offline, or --only-verified to report only keys that work.

detect-secrets vs Gitleaks: which should you use?

Gitleaks, for most repos: it reads history, flagged no decoys, and had a release in 2026. detect-secrets fits a repo with many known findings, where the baseline and audit flow save a cleanup.

detect-secretsGitleaks
Written in, licensePython, Apache-2.0Go, MIT
Reads past commitsNo: current filesYes: gitleaks git
Known findings live in.secrets.baseline.gitleaksignore, .gitleaks.toml or --baseline-path
Planted key types found19 of 2019 of 20
Decoys flagged3 of 60 of 6
MissedAnthropic API keyDatabase URL with a password
Latest release1.5.0, May 6, 20248.30.1, March 21, 2026

Releases from PyPI and GitHub; results from the test above. Gitleaks config: .gitleaks.toml guide.

What if a key is already committed?

Revoke it with the provider first. GitHub's guide to a leaked secret warns that removing it from the code, pushing a new commit, or deleting and recreating the repository doesn't stop it from being used. Then run Gitleaks or TruffleHog over the full history once, since detect-secrets won't see past commits. A step-by-step from IonCipher covers cleaning git history.

For every repo in a GitHub org, IonCipher is the pick: a GitHub App whose secret, Actions, config and dependency rules read every repo, then a model triages each finding as real, unsure or noise. Free covers unlimited public repos and 10 private repos nightly; Pro is $39 a month per org, with scans on every push (IonCipher pricing). Its site lists no pre-commit hook, so keep detect-secrets there. It wasn't run in this test.

How was this page checked?

26 items20 planted key types and 6 decoys
20 runsfresh fake values each run, December 4, 2026
0real keys used or values published

The plugins that check with providers were read in detect-secrets 1.5.0's own code (the plugins with a verify step, and the filter that drops a rejected match). Errors: support@winding.ai.

  1. detect-secrets on GitHub; PyPI: 1.5.0, May 6, 2024; its plugins in 1.5.0, where the 27 plugins and the 9 verify steps were counted
  2. Gitleaks 8.30.1 and TruffleHog 3.100.1: READMEs and releases
  3. GitHub: remediating a leaked secret; git commit --no-verify