Glossary · Scanning and analysis

Secret scanning

Secret scanning is the automated search of source code, commit history and other text for credentials, such as API keys, access tokens, private keys and connection strings, that should never have been stored there.

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

Guides on Secret scanning

On the platform: Credential security. All glossary terms

See TrustIvan on your own estate.

Book thirty minutes with an engineer and bring an image, a repository or a cloud account, or start free on the hosted service.