TruffleHog vs Gitleaks: which secret scanner to use, and what both leave open

TruffleHog and Gitleaks both find API keys and passwords in Git repositories and their history. TruffleHog (AGPL-3.0) also calls the provider to tell you whether a key still works. Gitleaks (MIT) matches patterns fast and suits a pre-commit hook, and its maintainer now calls it feature complete. Both scan what you point them at, usually the repository. A key can also sit in the JavaScript your live app serves.

The team behind Keybrum's attacksUpdated 9 min read

In short

  • TruffleHog verifies: for more than 700 kinds of credentials it calls the provider's API and marks each result verified, unverified or unknown. Its licence is AGPL-3.0.
  • Gitleaks detects with regular expressions, entropy and keywords, under the MIT licence. Its README says it is feature complete and that future releases will be security patches only.
  • GitHub secret scanning runs for free on public repositories and scans the whole Git history on all branches. Private repositories of an organization need GitHub Secret Protection.
  • All three read repositories. A key injected at build time by your host or your AI builder never enters the repository, and still ends up in the bundle every visitor downloads.
  • Whichever you choose, also scan the built files, and rotate any real key you find. Deleting it from the code does not un-leak it.
On this page

TruffleHog vs Gitleaks: the short answer

Use TruffleHog when you want to know which leaked keys are still live. Use Gitleaks when you want a small, fast check that blocks a commit before a key leaves your laptop. Many teams run both: Gitleaks in the pre-commit hook, TruffleHog over the full history. If your code is on GitHub, GitHub secret scanning is a third layer that costs nothing on a public repository.

All the facts below were read on each project's GitHub repository and documentation on 13 November 2026.

TruffleHogGitleaksGitHub secret scanning
LicenceAGPL-3.0 since version 3.0MITA GitHub feature, not a download
Latest releasev3.99.9, 12 November 2026v8.30.1, 21 March 2026Runs on GitHub's side
How it detectsDetectors per credential typeRegular expressions, entropy thresholds and keywords, set in a config filePartner and provider patterns, optional generic and custom patterns
Checks that a key is liveYes. The README counts over 700 detectors that verify against the provider's APIThe README describes no live checkOptional validity checks
What it scansGit, GitHub (with issue and pull request comments), Docker images, S3, GCS, files and folders, stdin, and moreGit history, files and folders, stdinThe whole Git history on all branches, plus issues, pull requests, discussions and wikis
Where it runsCLI, GitHub Action, pre-commit hookCLI, pre-commit hook, GitHub ActionOn GitHub, with push protection to block a push
Project statusActive, with a paid Enterprise editionFeature complete, security patches only; the author now works on BetterleaksMaintained by GitHub
Sources: the README of each repository, the GitHub releases API and GitHub Docs, 13 November 2026.

What TruffleHog does

TruffleHog's distinctive feature is verification. When a detector finds something shaped like a key, TruffleHog can call the provider to see whether it works. The README gives the AWS example: the detector performs a GetCallerIdentity call to learn whether the credential is active. Each result gets one of three statuses:

  • verified: confirmed valid and active by testing it against the API;
  • unverified: detected but not confirmed, because it is invalid, expired, or verification was turned off;
  • unknown: the check could not complete, for example because of a network error.

That turns a list of two hundred maybes into the five keys you must rotate today. A separate analyze command goes further for common credential types and reports what a key can access.

bash
# Your own repository, full history, live keys first
trufflehog git file://. --results=verified,unknown

# A folder of files, for example a build output
trufflehog filesystem ./dist --results=verified,unknown
Commands from the TruffleHog README. Verification sends each candidate key to its provider, so run it on your own code only.

Two things to know before you adopt it. The licence is AGPL-3.0, which some companies restrict: check your policy if you plan to build it into a product. And the open source tool scans when you run it. Continuous monitoring of Git, Jira, Slack and other places is the paid Enterprise edition, whose revenue funds the open source project according to its README.

What Gitleaks does

Gitleaks is a single Go binary under the MIT licence. It has three modes: git reads the history, dir reads files and folders, and stdin reads a stream. Rules are regular expressions with optional entropy thresholds and keywords, kept in a config file you can extend. You can allow known false positives with an inline gitleaks:allow comment, a .gitleaksignore file or a baseline report, so that only new findings fail the build.

bash
# Your own repository, full history
gitleaks git -v .

# A folder or a single file
gitleaks dir -v ./dist
Commands from the Gitleaks README. Exit code 1 means leaks were found, which is what makes it easy to use in a hook or a pipeline.

Its README describes detection only. A match is a string that looks like a key. You decide whether it is real. That is the price of speed and of working offline, and it is the reason Gitleaks fits a pre-commit hook so well.

One detail on the official GitHub Action: its README says a licence key is required for repositories owned by an organization, and that the key is free. Personal accounts need none.

Where GitHub secret scanning fits

GitHub's secret scanning needs no install. GitHub Docs say it runs automatically for free on public repositories, and that it scans your entire Git history on all branches, as well as issues, pull requests, discussions and wikis. For private and internal repositories owned by an organization it requires GitHub Secret Protection, on GitHub Team or Enterprise Cloud.

Push protection blocks a push that contains a detected secret before it lands. For individual users it is on by default and stops you from pushing secrets to public repositories. When a provider is a GitHub partner, GitHub also reports the leak to the provider.

GitHub's own advice on cleanup is worth repeating: rotate the credential first. Removing a secret from Git history is time-intensive and often unnecessary once the credential is revoked.

The gap all three share: the bundle your app serves

These tools scan what you point them at, and in practice that is the repository. Apps built with Lovable, Bolt, v0, Cursor or Claude Code often leak somewhere else: in the JavaScript files the browser downloads.

  • Build-time variables. Your host or your builder holds environment variables outside the repository. Frameworks copy any variable with a public prefix, such as NEXT_PUBLIC_ or VITE_, into the bundle. If a server key was given that prefix so that "it works", the repository stays clean and the key ships to every visitor.
  • The build folder is ignored. dist and .next are in .gitignore, so a scan of the history never reads the built files.
  • Source maps. A published source map hands out your original source, comments included.
  • Apps with no repository. An app built entirely in a browser-based builder may have no Git repository for a scanner to read.
  • Keys in data. A key stored in a database table that anyone can read is a leaked key. No file contains it.

The guide to API keys exposed in the frontend explains which keys are designed to be public (a Supabase anon or publishable key, a Firebase API key, a Stripe publishable key) and which never are. A pattern scanner flags by shape. Knowing which one matters is still your job.

How to check your live bundle

You can close most of this gap with the tools above, by pointing them at what is served instead of what is committed.

  1. 1

    Scan the build output

    Build the app the way production does, then run gitleaks dir -v ./dist or trufflehog filesystem ./dist on the output folder. Use .next or build if that is where your framework writes.

  2. 2

    Scan what is really served

    Open your published app, open the browser's developer tools, and look at the Network tab for the .js files. Save them, or paste their content into the API key leak checker, which runs in your browser and says which keys are secret.

  3. 3

    Look for source maps

    In the same Network tab, add .map to the address of a JavaScript file. If it downloads, your source is public. Turn source maps off for production builds or keep them private.

  4. 4

    Rotate, then remove

    For every real server key found: create a new key at the provider, deploy it on the server side, revoke the old one, then check the provider's logs for use you do not recognise. The leaked API key guide gives the order per provider.

bash
# Your own app only: download one served file and scan it
curl -s -o bundle.js https://your-app.example/assets/index-abc123.js
gitleaks dir -v bundle.js
Replace the address with a JavaScript file from your own Network tab.

Which one should you use?

Your situationUseWhy
Solo, code on GitHub, public repositoryGitHub secret scanning and push protectionAlready on, no setup
You want to stop keys before the commitGitleaks, or Betterleaks, as a pre-commit hookFast, offline, MIT
You inherited a repository and need to know what is liveTruffleHog over the full history with --results=verified,unknownVerification sorts real keys from old noise
Your company restricts AGPL softwareGitleaks or BetterleaksMIT licence
Your app was built in an AI builder and you rarely touch GitA scan of the served bundle firstThat is where the key is, if there is one

TruffleHog is the better choice for triage, Gitleaks for prevention. Neither is a mistake. The mistake is to run one on the repository, see green, and conclude that the app leaks nothing.

What Keybrum checks, and what it leaves to these tools

Keybrum works from the other side: it reads what your live app serves. During an attack run it searches the JavaScript files the browser downloads, published source maps, exposed files such as .env and config files, the answers of your API routes, and the rows of any Supabase table or Firebase document a stranger can read. Its detectors cover keys of AI providers (OpenAI, Anthropic and others), Stripe, AWS, GitHub, mail and messaging services, database connection strings, private keys and the Supabase service role key.

For most of these providers, Keybrum then makes one read-only call to see whether the key still works, and reports it as live, restricted or rejected. The stored proof keeps neither the key nor the account's data: the key is redacted. Each finding comes with the rotation steps and a fix for your coding agent, and it closes only when the same check fails on the live app.

What Keybrum does not do: walk your Git history. A key committed two years ago and removed since is invisible from outside, and it is exactly what TruffleHog and Gitleaks find. Keep one of them on the repository. Keybrum only attacks apps whose owner proved ownership. A one-time report costs €49, and plans from €29 a month excluding VAT attack every deploy, so a key that slips into next week's build is caught next week.

Questions

Is TruffleHog free?

The open source TruffleHog is free under the AGPL-3.0 licence. Truffle Security also sells an Enterprise edition that monitors Git, Jira, Slack, Confluence and other sources continuously. The AGPL has conditions that some companies restrict, so check your policy before building it into a product.

Is Gitleaks still maintained?

Its README says Gitleaks is feature complete: no new features, security patches only. The latest release on 13 November 2026 is v8.30.1, from March 2026. The maintainer now works on Betterleaks, an MIT-licensed scanner from the same people.

Does Gitleaks verify that a secret is valid?

The Gitleaks README describes detection by regular expressions, entropy and keywords, and no check against the provider. TruffleHog verifies by default, and Betterleaks can validate when you pass its validate flag.

Is GitHub secret scanning enough?

It is a strong default: free on public repositories, the whole history on all branches, and push protection. It reads what is on GitHub. It does not read the bundle your deployed app serves or a key that your host injects at build time.

Can TruffleHog or Gitleaks scan a website?

Not by address. Both scan files, folders and Git history, so you can download the JavaScript files your own app serves, or build the app locally, and scan that folder. Do it on your own app only.

I found a key in my bundle. Is deleting it enough?

No. Anyone who loaded the page may have copied it. Create a new key, move its use to server code, revoke the old key at the provider, and review the provider's usage logs.

Sources

  1. 1.TruffleHog: README, Truffle Security
  2. 2.TruffleHog documentation, Truffle Security
  3. 3.Gitleaks: README, Gitleaks
  4. 4.Gitleaks Action: README, Gitleaks
  5. 5.Betterleaks: README, Betterleaks
  6. 6.About secret scanning, GitHub Docs
  7. 7.About push protection, GitHub Docs

Your app is public. So are its mistakes.

Check what any attacker can already see in it, free, in ten seconds. The full attack, with proof and fixes: €49 once, or €29 a month on a plan.

or continue with Google or GitHub