Skip to content
KeyJar

Gitleaks vs TruffleHog: which secret scanner should you use in 2026?

An honest comparison of Gitleaks, TruffleHog and Betterleaks: what each scans, how they detect secrets, live verification, licences, pre-commit and CI setup.

By Keshav Melnad

7 min read

Cover for Gitleaks vs TruffleHog: the title beside two terminal windows, one showing a gitleaks finding for an OpenAI key, one showing a TruffleHog verified AWS result

Short answer

Use TruffleHog when you need to know which leaked secrets still work: it classifies 800+ secret types and logs in to check them. Gitleaks is a fast MIT regex scanner, but it now gets security patches only; its author moved to Betterleaks, which adds live validation. Run any of them in pre-commit and CI.

If you only read one line: TruffleHog is the better default for most teams in 2026, because it tells you which secrets still work. Gitleaks is still a fine, fast scanner, but it is in maintenance mode, and its successor is Betterleaks.

The rest of this post is the detail behind that line. Every number comes from the projects' own READMEs and docs, checked on 25 November 2026.

What is the difference between Gitleaks and TruffleHog?

Both are open-source command-line tools, written in Go, that look for secrets such as API keys, tokens and passwords in code and git history. They differ in three ways that matter:

  • Verification. TruffleHog can log in with each secret it finds to see if it is live. Gitleaks only matches patterns.
  • Sources. Gitleaks scans git history, a directory, or stdin. TruffleHog also scans GitHub organisations, S3 and GCS buckets, Docker images, Postman, Jenkins, Elasticsearch and Hugging Face. (Betterleaks, below, covers a similar range.)
  • Maintenance. Gitleaks says it is feature complete and will ship security patches only. TruffleHog ships often; v3.100.1 came out on 23 November 2026.

Gitleaks vs TruffleHog at a glance

GitleaksTruffleHogBetterleaks
LicenceMITAGPL-3.0MIT
Maintainergitleaks org (original author has moved on)Truffle Security Co.Former Gitleaks maintainers, incl. the original author
Latest releasev8.30.1, March 2026v3.100.1, November 2026v1.10.1, November 2026
GitHub starsabout 31.3kabout 29.6kabout 3.1k
Detection222 regex rules, optional entropy800+ secret typesRegex rules, Gitleaks-style
Live verificationNoYes, by defaultYes, with --validate
Scansgit, dir, stdingit, GitHub, filesystem, S3, GCS, Docker, stdin and moregit, filesystem, GitHub, GitLab, Hugging Face, S3, containers, stdin
Report formatsjson, csv, junit, sarif, templatejson, sarifNot listed in the README
StatusSecurity patches onlyActiveActive

Star counts change daily; these are from the GitHub API on 25 November 2026.

How does Gitleaks detect secrets?

Gitleaks runs a list of regular-expression rules over text. Its default config has 222 rules. A rule can also require a minimum Shannon entropy, so a random-looking string scores higher than password123, and it can list keywords that must appear nearby before the regex even runs.

When you scan a repository, Gitleaks reads git log -p and looks at the lines each commit added. That makes it fast, and it means a secret that was added and later deleted is still found.

Three commands cover most use:

bash
gitleaks git -v path_to_repo
gitleaks dir -v path_to_directory_or_file
cat some_file | gitleaks -v stdin

Older guides use gitleaks detect and gitleaks protect. Those were deprecated in v8.19.0; they still run but are hidden from --help.

The catch: Gitleaks is in maintenance mode

The Gitleaks README now opens with a notice from its author: it is feature complete, new features will not be merged, and future releases will be security patches only. The same author now works on Betterleaks, an MIT-licensed successor maintained by former Gitleaks maintainers.

That does not make Gitleaks unsafe to use today. Its rules and its pre-commit hook still work. But if you are choosing a scanner for the next few years, it is worth knowing that new secret formats will land in Betterleaks or TruffleHog first.

How does TruffleHog detect and verify secrets?

TruffleHog classifies over 800 secret types. Each detector knows the shape of one provider's credentials, and most can also check the credential against that provider. In the README's words, for every secret it can classify, "it can also log in to confirm if that secret is live or not". For an AWS key, for example, it calls GetCallerIdentity.

Every finding gets one of three results:

  • verified: the provider accepted the secret. Treat it as an incident.
  • unverified: it looks like a secret, but the provider rejected it.
  • unknown: the check could not run, for example because of a network error.

That is the main reason to pick TruffleHog. A scan of an old monorepo can return hundreds of hits. Knowing that six of them are live tells you where to start.

bash
trufflehog git file://. --results=verified,unknown
trufflehog filesystem path/to/dir
trufflehog github --org=your-org --results=verified
trufflehog docker --image your/image --results=verified

Two things to know before you turn verification on:

  • Verification means TruffleHog uses the secret. To check a key, it sends that key to the provider's API from the machine running the scan. That is usually what you want. If you need a scan that makes no outbound calls, add --no-verification.
  • AGPL-3.0 licence. Running TruffleHog as a tool is fine for almost everyone. If you plan to modify it and offer it as a network service, read the licence first.

Gitleaks vs TruffleHog in pre-commit and CI

Both work as a pre-commit hook, which is the cheapest place to catch a secret: before it ever reaches a remote.

Gitleaks with the pre-commit framework:

yaml
repos:
  - repo: https://github.com/gitleaks/gitleaks
    rev: v8.30.1
    hooks:
      - id: gitleaks

The README example still pins an older version, so run pre-commit autoupdate after adding it. To skip it once, the docs use SKIP=gitleaks git commit -m "...".

TruffleHog with the pre-commit framework, as its PreCommit.md shows it:

yaml
repos:
  - repo: local
    hooks:
      - id: trufflehog
        name: TruffleHog
        description: Detect secrets in your data.
        entry: bash -c 'trufflehog git file://.'
        language: system
        stages: ["pre-commit", "pre-push"]

TruffleHog's pre-commit docs also cover a plain git hook and Husky. In CI, add --fail: TruffleHog then exits with code 183 when it finds something, which is what fails the job.

In GitHub Actions, TruffleHog publishes trufflesecurity/trufflehog@main; check out with fetch-depth: 0 so it can see history. Gitleaks publishes gitleaks/gitleaks-action@v3, but note its licence: since v2 the action needs a free GITLEAKS_LICENSE key for repositories owned by an organisation, which you get by filling in a form. Running the gitleaks binary yourself in a workflow step avoids that.

What about GitHub secret scanning?

If your code lives on GitHub, you already have a scanner:

  • Public repositories: secret scanning runs automatically and for free. Push protection, which blocks a push that contains a known secret, is on by default for your own pushes to public repositories.
  • Private repositories: you need GitHub Secret Protection, which costs $19 per active committer per month on GitHub Team or Enterprise Cloud.
  • Partner revocation: for many providers, including OpenAI, Anthropic, AWS, Google and Stripe, GitHub tells the provider when their secret shows up in a public repo, so the provider can revoke it.

GitHub's scanner is a safety net, not a replacement. It only sees what you push to GitHub. A local tool catches the secret before the push, and in places GitHub never sees.

Other secret scanners worth knowing

  • [detect-secrets](https://github.com/Yelp/detect-secrets) (Yelp, Apache-2.0, Python) works from a baseline file: you record today's findings once, then only new ones fail. Releases are slow; the last was in 2024.
  • [git-secrets](https://github.com/awslabs/git-secrets) (AWS Labs, Apache-2.0, shell) adds git hooks that block commits matching AWS-style patterns. It still works, but it is effectively dormant.

Which one should you use?

  • You want to know which secrets are live: TruffleHog.
  • You want a permissive licence and no outbound calls: Gitleaks today, and plan a move to Betterleaks.
  • You want live checks with an MIT licence: try Betterleaks; it is young, so test it on your repos first.
  • You are on GitHub: keep push protection on as well, whichever you choose.

Many teams run two: a fast regex scanner in pre-commit, and TruffleHog with verification in CI.

What none of these scanners look at

All of these tools are built around repositories. They answer one question well: did a secret get into code or history?

They are not built for the copies of a key that never go near a repository. When I scanned my own laptop, one Anthropic key turned up in 138 files: .env files in old projects, a backup folder, notes, config files. I wrote that up in I scanned my laptop for API keys.

You can point gitleaks dir or trufflehog filesystem at your home folder, and they will list findings file by file. What they will not do is tell you that 138 of those findings are the same key, or help you get the key out of those files.

That gap is why I built KeyJar. kj scan ~ groups every copy by key and changes nothing. kj import then moves each key into one encrypted vault on your laptop and leaves a kj:// reference in the .env file, so there is no plaintext left for any scanner, or any coding agent, to find. It complements a secret scanner rather than replacing one: keep your scanner in pre-commit and CI.

If a scan finds a live secret

Do not start by rewriting git history. Revoke the key at the provider first, then clean up. The order matters, and the steps are in Leaked an API key? What to do in the first 15 minutes.

Keshav Melnad

Solo founder of KeyJar, building from Egypt. The scanner started as a check of one laptop, which turned up a single Anthropic key copied into 138 files.

More about KeyJar and its maker

Keep reading