A credential is created once and then copied: into a .env file to test locally, into a CI variable so the pipeline works, into a Kubernetes secret, into a ticket to help a colleague, into a container image by accident. Each copy is another place it can leak from, and nobody tracks the copies. Secret sprawl is the result. It is a symptom of two underlying conditions: credentials that live a long time, and credentials distributed by hand rather than issued to the thing that needs them.
How it is used in practice
Teams measure sprawl in two directions. From the code: secret scanning of repositories and their history, CI configuration and images finds credentials that were written down where they should not be. From the identity: an inventory of the credentials each non-human identity holds, with their age, last use and where they are stored, shows which ones are long-lived, unused or held outside a vault. Reduction follows: move credentials into a secrets manager, replace static keys with workload identity and other short-lived credentials, rotate what remains on a schedule, and add push protection so new copies are not committed.
Common pitfalls
- Deleting the line and moving on. A credential removed from the latest commit is still in history and in every clone. It must be rotated.
- Vaulting without retiring. Adding a credential to a secrets manager while the old copies stay valid doesn't reduce sprawl.
- Measuring only code. Chat, wikis, tickets and laptops hold copies no repository scan sees.
- One credential, many users. A shared key spreads by design and can never be rotated without coordinating every user.
- Counting copies as separate secrets. The useful unit is the credential; its copies are observations of it.
How TrustIvan relates to it
TrustIvan addresses both directions. AppSec's secret scanning walks a repository's full history, names the commit and author that introduced each credential, and identifies a credential by a salted digest of its bytes: the same key committed to two files is two findings, because each file needs its own edit, sharing one credential identity, so rotating it is tracked once. NHI Security inventories the credentials its connectors report, with their state, expiry and last rotation, and flags overdue rotation and expiring credentials; it never returns a secret's value. Exposure of a credential outside code is not collected by any connector; it can be sent through NHI Security's ingestion endpoints. See Secret scanning.
Related terms
- 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.
- 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.
- Machine identity A machine identity is the cryptographic credential, such as an X.509 certificate, an SSH key or a signed workload token, that a device, server, container or service uses to prove what it is to other systems.
- Workload identity Workload identity is an identity issued to a running workload, such as a pod, function, VM or CI job, usually by the platform that runs it, and exchanged for short-lived credentials instead of a stored secret.
Guides on Secret sprawl
- 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