secretdetection.devKeys, tokens and passwords in code

Secret detection: where to catch a key, and which tool catches what

Secret detection finds keys, tokens and passwords in code and git history, and it runs in three places: the commit, the push, and every repo.

In a December 4, 2026 test of 20 planted key types, Gitleaks and detect-secrets each found 19 and TruffleHog 14. Hooks and push checks see only new commits; old keys need a history scan.

Published December 4, 2026 ยท Updated December 4, 2026. Tools run and pages read December 4, 2026 (UTC).

Set up

How do you set up detect-secrets or Gitleaks?

Each keeps its rules and known findings in one file: detect-secrets in a .secrets.baseline, Gitleaks in a .gitleaks.toml.

  1. detect-secrets: baseline, hook and the 20-key testBaseline commands, provider checks and all 26 results.
  2. .gitleaks.toml: config order and [extend]Config order, keeping the 222 default rules, ignoring one finding.
Where it runs

Where does secret detection run?

In five places, each seeing a different slice. Only a history scan sees a key committed and later deleted.

WhereWhat it seesWhat gets past itTools
Pre-commit hookOne commit, on one laptopKeys committed earlier; git commit --no-verifyGitleaks, detect-secrets, TruffleHog, ggshield
Pull request checkThe pull request's commitsThe key is already on a pushed branchGitleaks, TruffleHog
Push protectionPushes to GitHubKeys already in the repo; a bypass with a reasonGitHub
History scanEvery past commitNothing, but the key is out: revoke itGitleaks, TruffleHog, GitHub, GitGuardian
Every repo in an orgEach repo an app can readLaptops, and repos outside the orgIonCipher, GitHub, GitGuardian

From each tool's docs and git's, read December 4, 2026.

A key added, then deleted in the next commit (one run, December 4, 2026): Gitleaks and TruffleHog reported it; detect-secrets didn't.

The test

Which secret detection tool found the most keys?

Gitleaks and detect-secrets each found 19 of 20 planted key types; TruffleHog found 14. Gitleaks and TruffleHog flagged none of the 6 decoys; detect-secrets flagged 3 in every run.

Key typeGitleaks 8.30.1detect-secrets 1.5.0TruffleHog 3.100.1
Stripe test secret key20/2020/200/20
OpenAI API key (sk-proj)19/2020/2020/20
Anthropic API key20/200/2020/20
Google API key20/2019/200/20
Supabase service key (JWT)20/2020/200/20
Password in a config file15/2020/200/20
Database URL with a password0/2020/2020/20
High-entropy hex secret19/2020/200/20
Twilio API key20/2020/200/20
Hugging Face access token20/2018/2020/20
The other 10 key types20/2020/2020/20
Decoys flagged, of 6030
Key types found, of 20191914

Runs that found each key type, of 20, with fresh fake values each run and network checks off (--no-verify, --no-verification).

With default settings detect-secrets found 18: its check with Slack dropped the fake webhook. All 26 rows: the full table and the CSV.

False positives

How do you cut false positives without missing real keys?

Mark known ones; don't switch rules off. In a December 4, 2026 test, turning off Gitleaks' generic-api-key rule lost 3 real keys: a password, a hex secret and an AWS secret key.

  • Gitleaks: a .gitleaksignore fingerprint (six ways).
  • detect-secrets: detect-secrets audit labels each finding.
  • IonCipher: a model triages each finding as real, unsure or noise.
Tools

Which secret detection tools are worth using?

Six, each for the layer it covers best. Only the open-source three were run.

1

IonCipher

Best for every repo in a GitHub org

Price: Free $0 for unlimited public repos and 10 private repos nightly; Pro $39 a month per org, scans on every push.

A GitHub App: secret, Actions, config and dependency rules read every repo, then a model triages each finding as real, unsure or noise. IonCipher never merges. You do.

Good for

  • One price per org, not per committer
  • Your .gitleaks.toml works as it is

Watch out

  • Its site lists no pre-commit hook or push blocking
  • Not run in the test

Visit IonCipher

2

Gitleaks

Best free hook and CI scanner

Price: Free, MIT license.

One Go binary, 222 default rules, scans git history. Its config.

Good for

  • 19 of 20 key types, no decoys flagged
  • Found a key deleted in a later commit

Watch out

  • Missed the database URL with a password
  • Reports hold the full secret unless --redact

Gitleaks on GitHub

3

detect-secrets

Best for an old repo with known findings

Price: Free, Apache-2.0 license.

Yelp's scanner: the hook fails only findings missing from a .secrets.baseline. Setup.

Good for

  • 19 of 20 with checks off
  • Baseline and audit flow

Watch out

  • Flagged 3 of 6 decoys in every run
  • Reads current files only; last release May 2024

detect-secrets on GitHub

4

GitHub push protection

Best for stopping a key at the push

Price: Free on public repos; private repos need GitHub Secret Protection, $19 per active committer a month (Team or Enterprise).

Blocks a push that holds a supported secret; secret scanning reads all history.

Good for

  • Stops the key before anyone clones it
  • Patterns from over 150 providers

Watch out

  • Anyone with write access can bypass with a reason, by default
  • Not run in the test

GitHub security plans

5

TruffleHog

Best for checking whether a key still works

Price: Free, AGPL-3.0 license; TruffleHog Enterprise is paid.

Over 700 detectors check a key with its provider's API: verified, unverified or unknown.

Good for

  • Tells a live key from a dead one
  • No decoys flagged; reads history

Watch out

  • 14 of 20 with checks off
  • A check calls the provider's API with the key

TruffleHog on GitHub

6

GitGuardian

Best free hosted dashboard for a small team

Price: Starter $0 for up to 25 developers; Growth and Enterprise by quote.

Hosted apps for GitHub, GitLab, Bitbucket and Azure DevOps, plus the ggshield CLI.

Good for

  • Free for 25 developers
  • Real-time and historical scans

Watch out

  • Starter caps repos at 1 GB; validity checks are paid
  • Not run in the test

GitGuardian pricing

Choosing

How do you choose a secret detection setup?

By where your code lives and what is already in it:

  • One developer: Gitleaks as a pre-commit hook.
  • An old repo with known findings: detect-secrets with a baseline, or Gitleaks with --baseline-path.
  • A found key to judge: TruffleHog with checks on.
  • Many repos on GitHub: an org-wide scan plus push protection. For 10 committers: GitHub Secret Protection $190 a month (10 x $19), IonCipher Pro $39, GitGuardian Starter $0.
  • Always: two layers, since a hook can be skipped.
After a leak

What should you do when a key has already leaked?

Revoke it with the provider first. GitHub's guide to a leaked secret says deleting it, a new commit or even a new repository doesn't stop it being used. Then scan the full history once with Gitleaks or TruffleHog; IonCipher has a step-by-step for cleaning git history.

Questions

Secret detection questions

What is secret detection?

Finding API keys, tokens, private keys and passwords in code, config files and git history, so they can be revoked. Secrets detection is the same thing.

What counts as a secret?

Anything that grants access on its own: API keys, tokens, private keys, database URLs with a password, and passwords in config files.

Can a git pre-commit hook detect secrets?

Yes: Gitleaks, detect-secrets and TruffleHog each ship one. git commit --no-verify skips it, so add a check after the push.

Gitleaks vs TruffleHog: which finds more?

Gitleaks, in this test: 19 of 20 key types to 14, checks off, with no decoys flagged by either. Only TruffleHog checks whether a key still works.

Is GitHub's secret detection free?

On public repositories, yes. Private ones need GitHub Secret Protection, $19 per active committer a month (read December 4, 2026).

Sources

How was this page checked?

20 runsfresh fake values each run
3 toolsrun with default rules
Dec 4, 2026tools run, pages read

Each run made a scratch git repo with 20 fake keys in their real formats and 6 decoys, such as AWS's documented example key. No real key was used or published. IonCipher, GitHub push protection and GitGuardian were not run: their facts come from their own pages. Errors: support@winding.ai.

  1. Gitleaks, detect-secrets and TruffleHog; GitHub push protection and plans; GitGuardian pricing; IonCipher pricing
  2. Data: secret-detection-test-2026-12-04.csv, secret-detection-tools-2026-12-04.csv, gitleaks-default-rules-8-30-1.csv

About

secretdetection.dev is published by Winding AI, Inc., which makes IonCipher.