Home / Knowledge hub / Secret scanning
Knowledge hub
Secret scanning
Searching code and history for keys, passwords and tokens that should not be there.
What it means
Secret scanning is the automated search of code, commit history and other text for credentials that should never be stored there: API keys, passwords, private keys and access tokens. Scanners match known formats, such as the prefix a cloud provider puts on its keys, and often look for high-randomness strings too.
The important detail is history. Deleting a key from the latest version of a file does not remove it from earlier commits, forks or clones. A scanner that reads only the current files will miss a secret that anyone with repository access can still retrieve.
Why it matters
A leaked key is often the shortest route into a business. It needs no exploit and no clever chain, only a copy. Automated tools crawl public repositories looking for keys, so a secret pushed by mistake can be found and used quickly. Speed matters more than elegance here.
Cost follows the key's power. A read-only analytics token is an annoyance. A cloud admin key can mean data exfiltration, a surprise bill and a breach notification. Finding it first, and rotating it, is cheap by comparison. It extends the idea of a hardcoded secret to the whole history.
How it shows up
You meet it in three places: a pre-commit hook on the developer's machine, a check on each pull request, and a scheduled scan of whole repositories including old branches. Good setups also scan chat exports, build logs, container images and tickets, because secrets leak well beyond source files.
The common mistakes are treating a found secret as fixed once the line is deleted, and skipping the rotation. A secret that has been exposed is compromised. Revoke it, issue a new one through your secrets manager, and check the logs for use of the old value.
Questions people ask
Secret scanning, answered
What should I do if a secret was committed?
Treat it as stolen. Revoke or rotate it first, then remove it from the code, then review logs for use between the commit and the rotation.
Rewriting history helps tidiness but does not undo the exposure. Rotation is the fix.
Does a private repository make leaked secrets safe?
Safer, not safe. Anyone with access can read it, including contractors, former staff with lingering access and any tool that is granted the repository.
Repositories also become public by mistake. Keep secrets out of code whatever the visibility.
Can scanners find every secret?
No. They are good at known formats and weaker at custom passwords or unusual tokens. Entropy checks find some of those but also produce false positives.
Treat scanning as a net, and prevention through a secrets manager as the real control.
Where should secrets live instead?
In a secrets manager or the platform's secret store, injected at run time and scoped to the service that needs them. Code then holds a reference, not the value.
Short-lived credentials are better still, because a stolen one expires.
Is secret scanning the same as SAST?
They overlap but differ. Static analysis reasons about how code behaves. Secret scanning looks for credential patterns, including in files that are not code.
Most teams run both, often in the same pipeline.
Sources
Where this comes from
Related
Terms that sit next to this one
Hardcoded secret
A password, API key or token written straight into source code.
Secrets management
Keeping keys, passwords and tokens out of code and in a vault.
Key rotation
Replacing a credential on a schedule so a leaked one has a short life.
Pre-commit hook
A small check that runs on a developer's machine before code is committed.
Cloud credentials leak
Cloud access keys exposed in code, images or logs and then used by others.
Is a leaked key already in use?
A scanner finds the key. It cannot tell you what that key reaches in the running app. We test with the access a finding gives and keep proof for each one. Ask us to run it on one of your applications.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.