Buyer’s Guide

Best Secret Scanning Tools

Written by Govind Kumar Lohar. Reviewed for technical accuracy by Deepak Gupta and Bhaskar Suthar on · Review panel

  • security
  • secrets
  • appsec
  • git
  • devsecops

Independent buyer’s guide. No vendor paid to be included, ranked or described a particular way. Written for engineers, architects and the people who sign off on their tooling budget. Editorial policy.

Secret scanning is the highest-signal control in application security and the one most teams configure wrong. High signal because a live cloud credential in a repository is not a theoretical weakness, it is an unauthorised access path that works right now. Configured wrong because teams install one tool, point it at one place, and believe they are covered.

They are not, because this is three separate jobs. Stopping a secret from being committed is a job. Catching the ones that get committed anyway is a different job with different latency requirements. Finding the ones that leaked eighteen months ago and are still valid is a third job that touches every commit you have ever made. One tool can do all three, but it will not do all three unless you configure all three, and the default configuration of almost everything covers only the middle one.

The other half that gets botched is remediation. There is a strong instinct, when someone finds a key in the repository, to make it disappear: delete the line, force push, rewrite the history, and feel better. That instinct is the wrong order of operations and it can convert a small incident into a large one.

What follows is the mechanism behind detection, the three jobs and where each tool fits, why custom patterns matter more than the vendor pattern count, and the remediation sequence in the only order that is safe.

Key takeaways

  • Pre-commit, CI and history scanning are three jobs. Pre-commit prevents, CI catches, history scanning finds what already leaked. Configure all three or you have covered one.
  • Detection is pattern matching plus entropy plus verification. Verification, actually calling the provider to see if the credential is live, is what separates an actionable alert from a queue of maybes.
  • Your highest-value secrets are internal ones no vendor ships a pattern for. Custom pattern support is the capability to evaluate, not the number of built-in detectors.
  • Rotate first, rewrite history second. A pushed secret is already copied into clones, forks, caches and CI logs. Rewriting history without rotating destroys the evidence and leaves the credential valid.

How detection actually works

Three techniques, layered, and knowing which one produced an alert tells you how much to trust it.

Structured pattern matching is the workhorse. Many credential formats are deliberately recognisable: a fixed prefix, a defined length, a known character set, sometimes a checksum in the value itself. A provider that issues tokens with a distinctive prefix has made them trivially greppable, which is the entire point, and modern providers do this specifically so that scanners can find their credentials. Pattern matching on those formats is close to zero false positive, because nothing else in your codebase looks like that.

Entropy analysis covers everything else. Compute the randomness of string literals and flag the ones dense enough to be a key. This is how you find credentials with no recognisable format: a database password, a private signing key, an internal service token somebody generated with a random byte generator. It is also where the noise comes from, because a base64-encoded test fixture, a content hash, a minified asset, a UUID and a lockfile integrity digest all look like high-entropy strings. Entropy alone is a hint, not a finding.

Verification is the step that changes the economics. The scanner takes the candidate credential and makes a harmless authenticated call to the issuing provider. If it returns success, the credential is live and this is an incident. If it fails, it is expired, revoked or fake, and you can treat it as hygiene rather than as a page.

Verification is the single most important capability in this category and it is the clearest dividing line between tools. A queue of unverified maybes is triaged once and then ignored. A queue of confirmed-live credentials gets worked, because every row is a real access path. Ask specifically how many providers a tool verifies against, not how many patterns it matches.

Two refinements sit on top. Contextual filtering suppresses candidates in test fixtures, example files and documentation, which is where most of the remaining noise comes from, and it has to be configurable because your repository layout is not theirs. And validity tracking re-checks previously found credentials over time, so you can tell the difference between a leak you rotated and one still sitting live in a public fork.

The three jobs

These have different latencies, different failure modes and different owners. Treating them as one setting is the most common configuration error here.

Job one: prevention, at the developer’s machine

A pre-commit hook scans staged changes and refuses the commit if it finds a candidate secret. The value is that the secret never enters git at all, which means there is nothing to rotate and nothing to rewrite. That is worth far more than catching it thirty seconds later, because the remediation cost difference is enormous.

The constraints are real. It must run in well under a second on a staged diff or developers will bypass it, and there must be a bypass, because a false positive that makes it impossible to commit at a bad moment is how the entire hook gets uninstalled. Provide the bypass, and log it or make it visible in review.

The structural weakness of client-side hooks is that they are advisory. They live in each developer’s working copy, they need installing, and a new laptop does not have them. Managed hook frameworks help, but do not treat this as a control you can attest to. It is a convenience that saves you incidents, not a guarantee.

Server-side push protection is strictly stronger and is the capability worth prioritising. The check runs when a push arrives, either as a pre-receive hook on a self-hosted server or as a platform feature, and rejects the push before the object is accepted. It cannot be skipped by a developer who did not install anything, it applies uniformly, and it still stops the secret before it reaches shared history. If your platform offers this, turn it on today and treat pre-commit as the fast local echo of it.

Job two: detection, in CI

CI scanning catches what prevention missed: commits made without hooks, merges from outside, and anything pushed before you turned protection on. It scans either the diff for the branch or the whole working tree, and fails or reports accordingly.

Two configuration decisions decide whether this works. Scan the full commit range of the branch, not the final diff, because a secret added in one commit and removed in a later commit of the same branch is invisible in the squashed diff and entirely present in history. And decide deliberately whether it blocks, which is a rare case where blocking is justified, because unlike almost every other class of finding a verified live credential is unambiguous and urgent.

CI is also the wrong place to rely on exclusively, because by the time it runs, the secret is already in a shared repository. It is the safety net, not the net.

Job three: history, once and then periodically

Everything committed before you started is still there. Git keeps every object, so a credential deleted in a later commit remains fully retrievable in the earlier one, and this is the population most likely to contain a long-lived credential nobody has rotated in years.

A full history scan walks every commit on every branch across every repository. It is slow, it is a one-off, and it is the scan most likely to find something genuinely serious. Run it when you adopt any tool in this category, before you do anything else, and expect it to find things.

Three things people miss. Scan every branch and every tag, not just the default branch, because abandoned feature branches are where experiments with real credentials go to be forgotten. Scan forks and archived repositories, because they have their own copies and their own exposure. And re-run history scanning periodically rather than once, because detection patterns improve and a scan today finds credential formats last year’s scanner did not know about.

Needs first-hand data: Run a full history scan across every repository, branch and tag you own, then verify every candidate against its provider. Record how many are still live and how old the oldest one is. That age, the interval between a credential leaking and anybody noticing, is the number that describes your actual exposure, and it is invariably worse than the team expects.

Custom patterns are the capability that matters

Vendors compete on built-in detector counts. That number is close to irrelevant, for a simple reason: the credentials with published formats mostly belong to providers who already scan for their own tokens, and several of them will revoke a leaked key automatically when a scanner reports it. Those are the leaks most likely to be caught by somebody other than you.

The credentials that will actually hurt you are the ones no vendor has a pattern for. Your internal service-to-service tokens. Your signing keys. Your database connection strings with the password inline. Your partner API credentials from a small vendor nobody writes detectors for. Nothing ships a pattern for those, so if you cannot write one, they are invisible.

So evaluate custom pattern support properly, on these dimensions:

Can you define a pattern at all, and where does it live? A pattern in a file in your repository, reviewed and versioned like code, is a different thing from one configured in a vendor console by whoever has admin access. The former is maintainable.

Can you define a verifier, not just a matcher? The high-value capability is teaching the tool to make a harmless authenticated call against your own internal service to determine whether a candidate token is live. Very few tools let you do this, and it is the difference between your internal credentials being first-class and being a noisy entropy alert.

Can you scope patterns and exclusions by path? You need a way to say that this directory is test fixtures and those strings are fake, without disabling detection globally.

Do custom patterns work across all three jobs? A pattern that works in CI but not in the pre-commit hook or the history scan covers a third of the problem, and this inconsistency is common.

The practical starting point is to enumerate every credential format your own systems issue, and write a pattern for each. It is an afternoon, it is the highest-value configuration work in this category, and almost nobody does it. While you are there, the durable fix is to make your own tokens recognisable: give internal credentials a distinctive fixed prefix, so that detecting them becomes trivial pattern matching rather than entropy guesswork.

Remediating a leaked key: rotate first, rewrite second

This is the part that gets done in the wrong order under pressure, so here is the sequence and the reasoning.

Step one: rotate the credential. Before anything else.

The moment a secret is pushed to a shared remote, you have lost control of every copy. It is in every clone anybody has made. It is in forks, including ones you cannot see. It is in your CI system’s cached checkouts, in build logs, in artefact metadata. It is in the platform’s own storage, potentially reachable by object identifier even after the branch is gone. If the repository is public, assume automated scrapers had it within minutes, because scanning public pushes for credentials is an actively automated activity.

Nothing you do to git history changes any of that. The only action that closes the access path is invalidating the credential at the issuer. Revoke it, issue a new one, deploy the new one.

Step two: confirm the old credential is dead. Try to use it. If it still authenticates, you rotated something else or a cached copy is still being honoured. Do not proceed on the assumption that revocation worked.

Step three: check what was done with it. Pull the provider’s access logs for the exposure window and look for use from addresses or at times that are not yours. This is the step that turns a hygiene task into an incident response, and skipping it means you never find out whether anything happened. Your own audit logging and log management are where this investigation actually happens.

Step four: now consider rewriting history. This is cleanup, not remediation, and it is genuinely disruptive: rewriting shared history changes every commit identifier from the rewrite point forward, breaks everyone’s local clones, invalidates open pull requests and breaks anything referencing a commit by hash. Do it when the repository is public, when you have a compliance obligation to remove the value, or when you are about to open-source the repository. Do not do it reflexively on a private repository with a rotated credential, because the disruption frequently exceeds the benefit.

If you do rewrite: coordinate a window, make sure everyone has pushed, use a purpose-built history rewriting tool rather than hand-rolled filter commands, force push all branches and tags, ask the platform to garbage collect unreachable objects and clear any caches, and tell every contributor to re-clone rather than pull. A stale clone that gets pushed back reintroduces the object you just removed.

Why the order is not negotiable. Rewriting first feels like fixing it and produces the worst outcome available: the credential is still valid, you have now deleted the commit that tells you when it was introduced and by whom, and everyone’s clones are broken. You have destroyed your own investigation while leaving the access path open.

Step five: fix the cause. A secret in a repository means there was no convenient correct place to put it. That is a workflow problem, not a discipline problem, and it recurs until the correct path is easier than the wrong one. Give the application a real secret store and give CI a real injection mechanism, covered in secrets managers and CI/CD secrets management. Short-lived credentials issued per workload change the shape of this problem entirely, because a token that expires in an hour is a much smaller incident than one that never expires.

Needs first-hand data: Time a full rotation drill for your most sensitive credential in a staging environment: revoke, issue, deploy, verify. Record the elapsed time and everything that broke. Teams consistently discover that a credential they believed was rotatable in minutes is wired into several places nobody documented, and you want to learn that during a drill rather than during an incident.

GitGuardian

GitGuardian homepage

GitGuardian is the established commercial specialist, and the breadth of its detector set combined with validity checking is what it sells. It covers the whole lifecycle in one product: pre-commit and pre-receive hooks, CI integration, full history scanning, and monitoring of public activity for credentials belonging to your organisation, which catches the case where an employee leaks a company credential from a personal account.

Pros

  • Very broad detector coverage with live validity checking, so alerts distinguish active credentials from dead ones
  • Public monitoring finds leaks in repositories you do not own, which is a genuine blind spot for every internal tool
  • Covers pre-commit, pre-receive, CI and history in one product with consistent detection across all four
  • Incident workflow with ownership, status and remediation tracking rather than a flat list of findings

Cons

  • Pricing scales with developers and becomes a significant line item for a large engineering organisation
  • Broad detection at default settings is loud, and tuning exclusions for test fixtures is real setup work
  • The hosted model means candidate secrets are evaluated by a third party, which some organisations cannot accept
  • Self-hosted deployment exists but is an enterprise arrangement rather than an easy option

Best for: Organisations that want one managed product covering the whole secret lifecycle, with validity checking and monitoring of exposure outside their own repositories.

Pricing: Free tier for small teams and open source, then per-developer subscription tiers, with enterprise agreements for self-hosted deployment.

TruffleHog

TruffleHog homepage

TruffleHog’s distinguishing feature is that verification is the centre of the product rather than an add-on. It carries a large set of detectors that each know how to make a live check against their provider, so its default output distinguishes verified credentials from unverified candidates. It scans git history, filesystems, container images, buckets and a range of other sources, which makes it useful well beyond repositories.

Pros

  • Verification against a large set of providers is built in, which turns a candidate list into an actionable one
  • Scans far beyond git, including images, object storage and filesystems, so it finds secrets baked into artefacts
  • Open source core runs anywhere with no account, which makes it easy to run a history scan today
  • Verified-only output mode gives a short, high-confidence list that a team will actually work

Cons

  • Verification makes outbound calls to providers, which needs a deliberate decision in restricted network environments
  • Full history scanning on large monorepos is slow enough to need scheduling rather than running inline
  • The open tool has no incident workflow, ownership or history, so tracking is your own build
  • Unverified findings are still noisy, and the filtering to make them useful is your configuration

Best for: Teams who want verification-first detection they can run themselves, particularly for an initial history and artefact sweep.

Pricing: Open source core free to run with no bill. The maintaining company sells a hosted enterprise platform adding management, continuous monitoring and workflow.

Gitleaks

Gitleaks is the lightweight open source scanner that shows up in most pipelines, and its virtue is that it does one thing quickly with configuration you fully control. Rules live in a TOML file: regular expressions, entropy thresholds, path allowlists and exclusions. It scans working directories, staged changes and full git history, and it is fast enough to run as a pre-commit hook without anyone noticing.

Pros

  • Fast enough for pre-commit and cheap enough to run on every CI job with no argument about build time
  • Rule configuration is a file in your repository, so custom patterns are reviewed and versioned like code
  • Covers all three jobs, with consistent rules across pre-commit, CI and history scanning
  • No account, no service dependency and no data leaving your environment

Cons

  • No verification, so it cannot tell you whether a found credential is live, which leaves every finding a manual check
  • Regular expression and entropy detection means noise, and building a good allowlist takes iteration
  • No workflow, ownership or deduplication, so managing findings across many repositories is your problem
  • Detector set is community-maintained and narrower than the commercial products

Best for: Teams who want free, fast, fully self-contained scanning with rules they own, and who will handle verification themselves.

Pricing: Free and open source with no vendor and no bill. The cost is CI time and the effort of maintaining rules and allowlists.

GitHub secret scanning

The dominant code host scans repositories for known credential formats, and its structural advantage is that it is wired into the provider ecosystem: partner providers receive notification when one of their credential formats is found, and several of them revoke automatically. The more valuable feature is push protection, which rejects a push containing a recognised secret before the object is accepted, so the credential never reaches shared history.

Pros

  • Push protection blocks at the server, which is stronger than any hook a developer has to install
  • Partner notification means some leaked credentials are revoked by the issuer before you have read the alert
  • Zero setup and nothing to operate, since it is a platform setting rather than a tool
  • Custom pattern support with dry-run evaluation across the organisation before enabling a pattern

Cons

  • Covers repositories on that platform only, so artefacts, images, logs and other systems are out of scope
  • Detection is limited to recognised formats and your custom patterns, with weaker generic entropy coverage
  • Advanced capabilities are gated behind the paid security add-on rather than included
  • Bypass handling on push protection needs a policy, or developers will click through the block

Best for: Any team on the platform, as the baseline layer to turn on first regardless of what else you run.

Pricing: Free for public repositories. On private repositories the fuller capability is part of the platform security add-on, metered per active committer.

Semgrep Secrets

Semgrep Secrets brings secret detection into the same engine and workflow as its code and dependency scanning, which is the main argument for it: one tool, one policy model, one place findings appear. Because it uses a code-aware engine rather than plain text matching, it can reason about context, such as whether a high-entropy string is assigned to a variable that looks like a credential or passed to a function that authenticates, and it supports validation to check whether a candidate is live.

Pros

  • Code-aware matching reduces the fixture and test-data noise that plain text scanners generate
  • Consolidates with code and dependency scanning, so engineers meet one tool rather than four
  • Validation support distinguishes live credentials from dead strings
  • Custom rules use the same readable pattern syntax as the rest of the product, so authoring is familiar

Cons

  • Secret detection is a commercial component, so the open engine alone does not cover this
  • Detector breadth is narrower than the dedicated specialists in this category
  • No monitoring of exposure outside your own repositories
  • Consolidation means a single vendor decision across several scanning categories at once

Best for: Teams already standardised on the same engine for code scanning who want secrets in the same workflow rather than as a separate tool.

Pricing: Commercial component of the platform, metered by contributing developers alongside the other scanning products.

detect-secrets

detect-secrets takes a distinctly different approach built around the baseline file. You scan once, generate a baseline recording every known finding, commit it, and from then on the tool reports only what is not in the baseline. That inverts the usual adoption problem: instead of a backlog blocking every build on day one, you start green and stay green, and the baseline becomes an auditable record of what was reviewed and by whom.

Pros

  • The baseline model makes adoption on a legacy repository trivial, with no backlog blocking anything
  • Baseline audit workflow records a human decision per finding, which is genuinely useful evidence
  • Plugin architecture for custom detectors, with filters for the common false positive sources
  • Small, fast and dependency-light, so it runs comfortably as a pre-commit hook

Cons

  • No verification, so live and dead credentials look identical in the output
  • The baseline must be maintained, and a carelessly regenerated baseline silently accepts new secrets
  • Detector coverage is narrower than the dedicated commercial tools
  • No history scanning workflow or cross-repository management of its own

Best for: Teams adopting secret scanning on established repositories who want an auditable baseline rather than a backlog, particularly as a pre-commit layer.

Pricing: Free and open source with no vendor and no bill. The cost is maintaining the baseline and reviewing the audit decisions.

Infisical Radar

Infisical Radar is the scanning component attached to a secrets management platform, and that adjacency is the argument. The tool that tells you a credential leaked is next to the tool that could have stored it properly, so the remediation path from detection to rotation to correct storage happens in one place rather than across three vendors and a ticket.

Pros

  • Detection sits next to storage and rotation, which shortens the path from finding a leak to fixing its cause
  • Open source core means you can run and inspect it without a commercial commitment
  • Covers repository scanning and history alongside the platform’s secret distribution features
  • Self-hostable, which keeps both the secrets and the scan results inside your environment

Cons

  • Detector breadth and verification coverage are narrower than the dedicated scanning specialists
  • The value depends on adopting the surrounding platform, so it is a weaker choice as a standalone scanner
  • Younger product with a smaller body of community knowledge when something goes wrong
  • No monitoring of exposure in repositories outside your organisation

Best for: Teams adopting or already running that secrets platform who want detection and correct storage from the same vendor.

Pricing: Open source core free to self-host with no bill. A managed cloud offering and enterprise features are subscription, scaled by users and projects.

How to choose

One. Turn on your platform’s push protection first, today. It is free or nearly free, it is server-side so it cannot be skipped, and it stops the highest-value class of leak before it enters history. Nothing else on this list should be evaluated before this is on.

Two. Run one full history scan with a verification-capable tool. Do this before choosing anything permanent, because what it finds tells you what kind of problem you have. If it finds nothing, your ongoing needs are modest. If it finds live credentials from years ago, you have an incident to work before you have a purchasing decision.

Three. Decide whether you need verification as a continuing capability. With few repositories and few alerts, checking by hand is fine and free tools are sufficient. Above that, unverified alerts will not get triaged, and verification is the feature to pay for.

Four. Enumerate your internal credential formats and confirm you can write patterns and verifiers for them. This is the difference between covering the credentials vendors care about and covering the ones that would actually hurt you.

Five. Check the scanning surface beyond git. Container images, build logs, object storage and configuration management all hold secrets, and most tools in this category only look at repositories. If your leaks are ending up in build logs, a repository scanner will never see them.

ToolPreventionVerificationPicks itself when
GitGuardianHooks and pre-receiveYesYou want one managed product across the lifecycle
TruffleHogHooksYes, extensiveVerification-first scanning you run yourself
GitleaksHooksNoFree, fast, fully self-contained, rules you own
GitHub secret scanningServer-side push protectionPartner revocationYou are on the platform, which is the baseline
Semgrep SecretsHooks and CIYesConsolidating with code and dependency scanning
detect-secretsHooksNoAdopting on legacy repositories without a backlog
Infisical RadarHooks and CILimitedDetection next to storage and rotation

Needs first-hand data: For a month, record every secret finding and classify it: true and live, true but already revoked, test fixture, or false positive. The proportion that is live tells you whether you need verification or just better exclusions, and those two problems have completely different solutions and completely different costs.

Frequently asked questions

Do I need a dedicated tool if my code host already scans for secrets?

Turn the platform feature on regardless, because push protection is the strongest prevention available and you get it without operating anything. You need something additional when you have credentials the platform does not recognise, which means internal tokens and anything from a provider not in the partner programme, or when you need to scan surfaces the platform never sees, such as container images, build logs and object storage. For many small teams the platform feature plus a free scanner in CI is genuinely sufficient.

Is rewriting git history ever actually necessary?

Yes, in specific circumstances: the repository is public or is about to become public, a compliance or contractual obligation requires the value removed, or the secret is something that cannot be rotated in any meaningful sense, such as a private key embedded in shipped artefacts. In a private repository with a properly rotated credential, rewriting is usually not worth the disruption, because the access path is already closed and the rewrite breaks every clone and open pull request. Rotation is what makes the leak harmless; rewriting is cleanup.

How do we stop developers bypassing the pre-commit hook?

Mostly by not relying on the hook as the control. Client-side hooks are advisory by nature and there must be a bypass or they get uninstalled. The enforcement belongs on the server, as push protection or a pre-receive hook, where it applies to everyone regardless of local setup. Then keep the local hook fast and quiet so that bypassing it is rare, monitor how often the bypass is used, and treat a rising bypass rate as a signal that your exclusions need work rather than that your developers need a lecture.

What about secrets in build logs and CI output?

This is a real and commonly missed exposure, and repository scanners do not cover it. Most CI systems mask values they know are secrets, which does nothing for a credential your application prints itself, a value constructed at runtime, or a verbose error that includes a connection string. Treat build logs as a scanning surface in their own right, restrict who can read them, and keep their retention short. The distribution side of this is covered in CI/CD secrets management.

Does a secrets manager remove the need for scanning?

No, it removes the reason for most leaks, which is different and better. A secrets manager gives developers a correct place to put credentials and a convenient way to retrieve them, which removes the temptation that produces most hardcoded values. Scanning still catches the mistakes, the legacy values still sitting in old commits, and the credential someone pasted into a config file while debugging at midnight. Run both, and expect the scanner to get quieter over time as the manager gets adopted. The storage side is covered in secrets managers.