A secret scanner runs a set of detectors over text. Good detectors are format-specific: they recognize a provider's token prefix and length, verify a checksum where the format has one (GitHub tokens carry a CRC32), or decode a structure (a JWT header must be JSON with an alg). Generic detectors look for high-entropy strings assigned to variables with names like api_key or password, and rely on denylists of placeholder values to stay quiet on tutorials and fixtures. Some tools also perform validity checks: they present a found credential to its provider's harmless "who am I" endpoint to learn whether it still works.
How it is used in practice
Secret scanning runs in two places. Before commit, as push protection, it checks the lines about to be committed and stops the commit if a credential is found, which is the cheapest moment to catch one. After the fact, it walks the whole repository history, because a credential deleted in a later commit is still in every clone. A confirmed leak starts a response: identify who introduced it and where it was used, rotate or revoke it at the provider, and record that this was done. Credential rotation is the fix; deleting the line is not.
Common pitfalls
- Scanning only the latest commit. History is where most leaked credentials live.
- Shallow clones. A scan of a shallow clone cannot see commits before its earliest one, and should not report clean.
- Marking a leak "resolved" after rotation. The old credential is still readable in history; what changed is that it no longer works.
- Filtering test keys. Test-mode keys often read real data, and a repository that leaks the test key will leak the live one.
- Validation that phones home unsafely. A validity check must only ever call fixed, known provider endpoints, never a host taken from the scanned content.
How TrustIvan relates to it
TrustIvan scans repositories with the scanner's built-in rules by default. Its optional git history scan walks the full history with 189 detectors: 12 first-party, format-specific rules (AWS and Google Cloud keys, GitHub, GitLab, Slack, npm and PyPI tokens, Stripe live and test keys, PEM private keys, JWTs, database URLs and a generic high-entropy rule) and 177 adopted from the open-source gitleaks project's default configuration. Each finding names the commit and author that introduced it. Validity checking is off by default and only an owner or admin can turn it on; 16 detectors across 14 providers have a check, each calling a fixed, read-only endpoint, and a 403, rate limit or outage reads as unknown, never as invalid. Those checks are tested against documented response shapes, not live providers. A confirmed-live credential is raised to critical. A local pre-commit check scans staged lines; there is no server-side push blocking. Recording a rotation adds a timeline event without closing the finding, and shallow clones are refused by default. See Secret scanning.
Related terms
- Secret sprawl Secret sprawl is the uncontrolled spread of copies of credentials, such as API keys, tokens, passwords and private keys, across source code, configuration files, CI pipelines, container images, chat messages, documents and machines.
- Credential rotation Credential rotation is the practice of replacing a secret, such as an API key, access key, token, password or certificate, with a new one and retiring the old, either on a schedule or in response to exposure.
- Non-human identity (NHI) A non-human identity (NHI) is any identity that authenticates and acts without a person at the keyboard: a service account, IAM role, API key, OAuth application, CI/CD robot, workload identity or AI agent.
- Shift left Shift left is the practice of moving security checks earlier in the software delivery process, into design, coding, pull requests and CI, so that problems are found when they are cheapest and quickest to fix.
- SAST (static application security testing) Static application security testing (SAST) analyzes an application's own source code, bytecode or binaries for security weaknesses without executing it, such as injection, unsafe deserialization or disabled certificate checks.
Guides on Secret scanning
- Finding and Rotating Secrets Leaked into Git History A secret deleted in a later commit is still leaked. Scan the whole git history, rotate in the right order, check for use, and know when a rewrite helps.
- TrustIvan vs. Running Trivy Yourself TrustIvan’s detection is Trivy, the same open-source engine anyone can run free. What TrustIvan adds on top, and when running Trivy alone is the right call.
- Policy as Code for Release Gates: Fail Builds on What Matters A release gate that fails on every critical gets switched off. Write a policy that blocks exploited, fixable risk, warns on the rest and explains itself.
On the platform: Credential security. All glossary terms