Secret scanning tools after the SAP hack: catch a leaked token before an attacker uses it
Gitleaks, TruffleHog, GitGuardian, detect-secrets and GitHub push protection catch leaked tokens at different layers. Here is what each covers, what it costs in November 2026, and what to do first when a token leaks.
Akash Mohapatra · · 10 min read · 3 views
The best secret scanning tools are the ones that catch a token at the layer where your team actually leaks it. A pre-commit hook such as Gitleaks stops a key on the laptop, GitHub push protection blocks it at push, a history scan finds the ones already committed, and TruffleHog tells you which of those still work. Pick by layer first, detector count second.
By the end of this guide you will know which layer each tool covers, what it costs as of November 2026, where the free tiers stop, and what to do in the first hour after a token leaks. Every price and feature below was checked on the vendor's own pricing page, docs or repository on November 29, 2026.
Why the SAP incident sent teams looking for secret scanning
SAP has confirmed only part of the story. The company told SecurityWeek it is investigating a cybersecurity incident and that, based on its investigation to date, it has found no evidence of unauthorized access to customer business data. The detail that matters to engineering teams has not been confirmed by SAP: Der Spiegel, citing an insider, reported that the attackers obtained SAP employees' authentication tokens and used them to copy and alter source code stored on GitHub.
Treat the token theft as reported, not established. The lesson does not depend on it, though. A developer token that works from anywhere is a standing key to your code, and secret scanning is the control that tells you when one has ended up somewhere it should not be. No scanner can stop a token stolen from a running laptop or session, so scanning is one layer, not the whole defense.
Secret scanning tools compared by where they catch a token
Most comparisons rank secrets detection tools by how many credential types they recognize. That number matters less than where in the path from keyboard to attacker the tool runs, because a token caught before it is committed costs nothing to fix, while one found in history has to be revoked.
| Tool | Layer it covers | License or price | Checks if a token is live |
|---|---|---|---|
| Gitleaks | Pre-commit, CI, git history | MIT, free | No |
| detect-secrets | Pre-commit, new secrets only | Apache-2.0, free | No |
| GitHub Secret Protection | Push, history, issues and PRs | $19 per active committer a month | Optional validity checks |
| TruffleHog | Pre-commit, history, many sources | AGPL-3.0, free | Yes |
| GitGuardian | Pre-commit, CI, monitoring | Free up to 25 developers | Yes, weekly on the free plan |
| Trivy | Filesystems, images, repos | Open source, free | No |
A pragmatic stack uses at least two rows: one tool on the laptop or at push to stop new leaks, and one that sweeps what is already in history and tells you what still works.
On the laptop: pre-commit hooks stop a secret before it exists in git
A pre-commit hook runs on the developer's machine before a commit is written. It is the cheapest place to catch a token, because nothing has left the laptop and nothing needs rotating. The catch is that hooks are opt-in per clone, so a developer who never installs them, or who skips them, gets no protection.
Gitleaks pre-commit hook setup
Gitleaks is an MIT-licensed scanner with three scanning modes: git, dir and stdin. Its README shows a pre-commit framework entry that points at the gitleaks/gitleaks repository with the hook id gitleaks, pinned in the example to v8.24.2. For CI, the Gitleaks-Action README says a license key is required for organization repositories but not for personal accounts, and that the key is free from gitleaks.io.
One thing a sceptical buyer should know: the Gitleaks README now says Gitleaks is feature complete, future releases will be security patches only, and the maintainer is shifting focus to Betterleaks. Gitleaks still works, but if you are adopting a scanner for years, look at Betterleaks, which is maintained by the people who made Gitleaks, is MIT-licensed, and can optionally validate credentials. Its own page warns that package managers may still serve v1 until the first stable v2 release.
detect-secrets for big repositories that already contain secrets
Yelp's detect-secrets takes a different approach. It records the secrets already in your repository in a baseline file and then flags only new ones, and its README says this approach avoids the overhead of digging through all git history. That makes it a good fit for a large, old codebase where a full history scan would produce hundreds of findings nobody will triage this week.
Skip detect-secrets if you need to know what is already exposed in history. It is designed not to tell you.
At push: how to stop secrets being pushed to GitHub
GitHub push protection is a server-side check, so it covers developers who never installed a hook. When it finds a supported secret, it blocks the push with a message explaining why, and the docs list pushes from the command line, commits made in the GitHub UI, file uploads and REST API requests among the surfaces it covers.
There are two versions, and the difference is easy to miss:
- Push protection for users is enabled by default, is available only on GitHub.com, and stops you from pushing secrets to public repositories.
- Repository push protection requires GitHub Secret Protection and is disabled by default. A repository administrator, organization owner, security manager or enterprise owner has to turn it on.
The counter-argument deserves its strongest form: push protection is not a hard wall. GitHub's docs say anyone with write access to the repository can bypass push protection by specifying a reason. That is the right design for false positives, but it means you still need someone reviewing bypasses and a scanner behind it.
In git history: scan for leaked tokens you have already committed
Deleting a token in a later commit does not remove it. It stays in every earlier commit, every clone and every fork. History scanning is how you find those.
GitHub secret scanning scans your entire Git history on all branches, plus pull request titles, descriptions and comments, issues, Discussions, wikis and secret gists. That last part matters, because a token pasted into an issue while debugging is as exposed as one committed to code.
Outside GitHub, Gitleaks' git mode uses git log -p under the hood to scan patches, so it reads past commits rather than just the working tree, and TruffleHog scans git repositories, GitHub, S3, Docker images and filesystems among other sources. Trivy, an open source scanner that also covers container and cloud vulnerabilities, has secret scanning enabled by default across container images, filesystems and git repositories. Its docs describe rule-based detection and do not mention checking whether a secret is live, so treat Trivy as a detector, not a triage tool.
TruffleHog verifies live secrets, which is what triage needs
A history scan of an old repository can return a long list. The question that decides what to do first is whether each token still works. TruffleHog answers it directly: its README says that for every secret it can classify, it can also log in to confirm whether that secret is live. Results come back as verified, unverified or unknown, and the --results=verified flag limits output to credentials confirmed as active.
TruffleHog's open-source edition is released under the AGPL-3.0 license and says it classifies over 800 secret types. It also documents use as a pre-commit hook. The catch for some companies is the license: if your organization restricts AGPL software, get TruffleHog cleared before it goes into CI.
GitHub has its own version of this. Its docs describe optional validity checks that help you prioritize by verifying whether a detected secret is still active. GitGuardian does it too, with validity checks made through non-intrusive API calls to the host; its docs say free workspaces recheck open incidents weekly, while Growth and Enterprise recheck daily.
Is GitHub secret scanning free? Only on public repositories
GitHub's docs say plainly that on public repositories, secret scanning runs automatically for free. For organization-owned private and internal repositories, it is available with GitHub Secret Protection enabled on GitHub Team or GitHub Enterprise Cloud. GitHub's plans page lists Secret Protection at $19 per active committer per month as of November 2026.
Before paying, run the free assessment. GitHub's docs say you can run a free check of your organization's code for leaked secrets at any time from the Assessments page in the Security and quality tab. If it comes back clean on a small team, a free tool may be enough.
Free secret scanning for private repos
You have three realistic free routes for private code:
- Open source scanners in CI. Gitleaks, TruffleHog and Trivy all run on private repositories at no cost. You own the false positives and the alert routing.
- GitGuardian's Starter plan. GitGuardian's pricing page lists a $0 Starter plan for up to 25 developers with unlimited real-time scanning, up to 500 historical scan detections and 10,000 API calls a month. Its paid tiers show no public price. Its CLI, ggshield, is MIT-licensed and works as a pre-commit, pre-push or pre-receive hook, but it authenticates against GitGuardian's servers and uses its public API, so your scanned content goes through GitGuardian.
- Semgrep, if you already use it. Semgrep sells Secrets as an add-on on its Teams tier at $15 per contributor a month, with secret validation; its free edition does not list Secrets.
What to do if a GitHub token leaks: revoke and rotate first
Scanners find the leak. The response decides whether it becomes an incident. GitHub's remediation guide says the most important remediation step is revoking the secret with the secret's provider. In order:
- Revoke the token with whoever issued it, then issue a replacement. Deleting the commit does not make a leaked token safe.
- Update every service that used the old token, so the rotation does not cause an outage that tempts someone to restore it.
- Review audit logs for use of the token while it was exposed. GitHub's guide says to review GitHub's audit logs for events relating to the secret and check for unauthorized access.
- Decide whether to rewrite history. GitHub's guide warns that cleaning Git history can be a destructive and disruptive process, so weigh it against your compliance obligations once the token is dead.
- Close the alert and add a hook or push protection rule so the same type of secret is blocked next time.
GitHub does some of step 1 for you: it automatically revokes GitHub personal access tokens leaked in public repositories. Outside that case, assume nobody will revoke the token for you.
We covered the same rotate-first order after a platform breach in our guide to Railway alternatives after the October 2026 security breach.
Which secret scanning tool is best for your team
There is no single best secret scanning tool, but the choice gets simple once you name your situation:
- Small team on GitHub with private repos and no budget: Gitleaks or TruffleHog in CI plus pre-commit hooks, and GitGuardian Starter if you want a dashboard.
- Already on GitHub Team or Enterprise Cloud: GitHub Secret Protection, because server-side push protection and alerts on issues and pull requests are hard to replicate with laptop hooks. Run the free assessment first to see what you would be paying to find.
- Large legacy codebase: detect-secrets with a baseline to stop new leaks now, then a TruffleHog verified-only sweep of history to find the live ones.
- Security team responding to a suspected leak: TruffleHog first. A verified result is the one to rotate today.
Whatever you pick, layer it. A pre-commit hook without push protection trusts every laptop; push protection without a history scan ignores everything committed before you turned it on.
Next step: run one history scan this week
Run GitHub's free secret risk assessment or a TruffleHog verified-only scan on your largest repository, rotate anything live, then add one prevention layer. For the rest of the pipeline, see our guide to open source vulnerability scanners by layer. As of November 29, 2026, Upfynd lists 603 security tools, 2,040 developer tools and 645 open source products, each with pricing and similar products side by side.
Frequently asked questions
What is secret scanning?
Secret scanning is the automated search of code, git history and related content for credentials such as API keys, passwords and access tokens. Tools like Gitleaks, TruffleHog and GitHub secret scanning match known token formats and patterns, and some also check whether a found token still works so teams know what to revoke first.
Is GitHub secret scanning free?
GitHub secret scanning runs automatically for free on public repositories. For organization-owned private and internal repositories it requires GitHub Secret Protection on GitHub Team or Enterprise Cloud, listed at 19 dollars per active committer per month as of November 2026. GitHub also offers a free secret risk assessment for organizations.
What is the best secret scanning tool?
The best secret scanning tool depends on the layer you need. Gitleaks or detect-secrets suit pre-commit hooks, GitHub push protection blocks secrets at push, and TruffleHog is strongest for triage because it verifies whether found credentials are still live. Most teams combine a prevention tool with a history scanner.
How do I find leaked secrets in git history?
To find leaked secrets in git history, run a scanner that reads past commits, not just current files. GitHub secret scanning covers all branches and history, Gitleaks scans patches through git log, and TruffleHog scans repositories and can report only verified, still-active credentials so you can rotate those first.
What should I do if a GitHub token leaks?
If a GitHub token leaks, revoke it immediately and issue a replacement, because deleting the commit does not make it safe. Then update services that used it, review audit logs for activity while it was exposed, and decide whether rewriting git history is worth the disruption for your compliance needs.
Does Gitleaks still get updates?
Gitleaks still works and remains MIT licensed, but its README says it is feature complete and future releases will be security patches only. The maintainer is shifting focus to Betterleaks, a newer MIT-licensed scanner from the people who made Gitleaks that can optionally validate credentials.
Products in this article
About the author
Akash Mohapatra
Director & Co-founder