Secrets scanning tells you a credential has already escaped into code, tickets or logs, while secrets management is what stops it being there in the first place, and many teams fund one and assume it covers the other. A scanner with no vault behind it produces an endless queue of findings that developers cannot fix properly, because there is nowhere safe to move the secret to. A vault with no scanner gives a false sense of safety, because nobody notices the API key that was pasted into a CI variable, a wiki page or a public repository last spring. This guide compares the two disciplines side by side: what each does, where each sits in the credential lifecycle, when to lead with one, how they feed each other and how to measure whether the pair is working. It is written for platform, AppSec and identity teams who own API keys, tokens, passwords and certificates used by applications, pipelines and AI agents.
Key takeaways
- Scanning is detection, management is prevention. Scanners find secrets that are already exposed; a secrets manager stores, issues, rotates and revokes them so they do not need to be written down.
- Revocation, not deletion, closes a leak. Removing a key from Git history does nothing if the key still works: the fix is revoke and rotate, which only a managed lifecycle makes fast.
- Neither works alone. Scanning without a vault creates findings with no safe destination; a vault without scanning cannot see the secrets that bypassed it.
- Push protection is the meeting point. Blocking a secret at commit or push time, with a clear path to the approved store, is where detection becomes prevention.
- Measure both ends. Track mean time to revoke for scanner findings and the share of workloads that fetch secrets at runtime; the second number should drive the first one down.
What each one is
Secrets scanning is the automated search for credentials in places they should not be: source code and its full Git history, container images, CI logs, issue trackers, chat, wikis and public sites. Scanners match provider-specific patterns (an AWS access key ID, a GitHub token prefix, a private key header), generic patterns and, increasingly, model-based detection for unstructured passwords. Code platforms named on this page (GitHub, GitLab) are listed alphabetically as documented examples, not a ranking. Platform-native scanning extends beyond code: GitHub's secret scanning covers the full Git history on all branches, issue and pull request text, Discussions, wikis and secret gists, and rescans when new secret types are added. Open-source scanners such as Gitleaks scan Git history, directories or standard input, and run as pre-commit hooks.
Secrets management is the system and process that owns a credential across its whole life: secure creation, storage, access control, delivery to the workload at runtime, rotation, expiry and revocation, with an audit trail of who read what and when. The OWASP Secrets Management Cheat Sheet frames it as centralising and standardising that lifecycle, applying least privilege to each secret, auditing every access and preferring dynamic secrets with short leases where possible. See the Secrets Management Guide for the full discipline.
The two map onto different weaknesses. CWE-798 (Use of Hard-coded Credentials) is the flaw secrets management removes: credentials embedded in code or configuration. MITRE ATT&CK T1552.001 (Credentials In Files) is the attacker behaviour scanning races against: searching files, configuration and source code for stored credentials. NIST SP 800-53 Rev 5 control IA-5(7), No Embedded Unencrypted Static Authenticators, is the control both serve: management makes it achievable, scanning proves whether it holds.
Side-by-side comparison
| Dimension | Secrets scanning | Secrets management |
|---|---|---|
| Primary goal | Detect credentials already exposed | Prevent exposure by storing and issuing credentials safely |
| Control type | Detective (preventive only at push or commit time) | Preventive and corrective (rotation, revocation) |
| Where it looks or acts | Repositories and history, CI logs, images, tickets, chat, public code | Vault or cloud secrets store, workload identity, runtime injection |
| Typical output | Alerts with location, secret type and sometimes validity | Leases, short-lived credentials, rotation events, access logs |
| Main users | AppSec, SOC, developers triaging findings | Platform engineering, application owners, identity teams |
| Weakness it addresses | Unknown exposure, ATT&CK T1552.001 | Hard-coded and long-lived credentials, CWE-798 |
| Failure mode alone | Findings pile up with no safe place to move the secret | Secrets copied out of the vault go unseen |
| Coverage of third-party leaks | Yes, including public repositories and partner notification | No, it only sees secrets it issued |
| Speed of fix it enables | Tells you what to fix | Makes the fix (revoke and reissue) quick and low risk |
| Key metric | Mean time to revoke a confirmed live secret | Share of workloads fetching secrets at runtime |
Where each sits in the secret lifecycle
Following one API key from birth to retirement shows why both are needed:
- Creation: management issues the key with the minimum privilege needed and records an owner, purpose and rotation rule (OWASP's "prepare to move the secret" metadata). Scanning has no role yet.
- Delivery: management injects the key at runtime through an agent, sidecar, CSI driver or SDK call, so it never lands in a file the developer commits. See the Environment Variables and .env Files guide for why environment files are a common leak point.
- Development: scanning runs in the IDE or as a pre-commit hook to catch a key pasted in for a quick test.
- Push: push protection blocks the commit server-side. GitHub push protection covers the command line, web UI commits, file uploads and REST API requests; GitLab secret push protection blocks pushes containing secrets unless the check is skipped.
- Pipeline and history: pipeline scanning and full-history scans find what slipped through earlier, including in merge requests before they reach the default branch.
- Beyond the repository: scanning of tickets, chat, container registries and public code catches copies made outside source control. GitLab client-side secret detection checks issue and merge request comments before they are saved.
- Rotation and expiry: management rotates on a schedule and enforces expiry, shrinking the useful life of anything that leaked unnoticed.
- Revocation: on a confirmed leak, the scanner's alert triggers the manager's revoke and reissue. GitHub's own guidance is to rotate the affected credential immediately, noting that removing it from history is time-consuming and often unnecessary once it is revoked.
When to lead with each
Most organisations need both, but the order of investment depends on where you are.
| Situation | Lead with | Why |
|---|---|---|
| No inventory of secrets, unknown exposure in old repositories | Scanning (full history, all repositories) | You cannot plan a vault migration without knowing what exists and what is live |
| Public repositories or open-source projects | Scanning with push protection | Exposure is immediate and attackers harvest public leaks quickly |
| Scanner already deployed, backlog growing | Management | Findings recur because developers have nowhere approved to put the secret |
| Cloud workloads using long-lived access keys | Management plus workload identity | Replacing static keys with federation removes whole classes of finding |
| Regulated environment needing audit evidence | Management | Access logs, rotation records and ownership metadata are the evidence auditors ask for |
| Fast-growing use of AI coding assistants and agents | Both, scanning first in the IDE | Assistants and agent configs create new copies of keys outside normal review |
- Small teams: turn on the scanning and push protection your code host already provides, then move the handful of production secrets into your cloud provider's secrets store. That covers most of the risk at low cost. See the Cloud Secrets Managers Guide.
- Large organisations: run scanning across every code host, registry and collaboration tool, centralise alerts, and pair it with a managed secrets platform that supports dynamic credentials and federation, so scanning findings become a declining exception rather than daily noise. The Secrets Scanning Buyer's Guide and Secrets Management Buyer's Guide cover evaluation criteria for each.
- When scanning is the only option for now: for legacy systems or third-party integrations that cannot fetch secrets at runtime, scanning plus a documented exception and scheduled rotation is the interim control.
How the two work together
The value comes from wiring them into one loop rather than running two tools.
- Finding to owner: a scanner alert is only actionable if you can find who owns the credential. Ownership metadata kept in the secrets manager answers that in minutes instead of days.
- Validity first: validity checks (GitHub's term) test whether a detected secret is still active, so responders work live secrets first. See Developer Secret Scanning Triage.
- Revoke through the manager: where the leaked secret was issued by the manager, revoke the lease or rotate the version there; dependent workloads pick up the new value without a redeploy.
- Remediation order: OWASP sets the sequence as revoke immediately, rotate (ideally automated), delete from the exposed systems including code and logs, then log the event.
- Feedback into prevention: each confirmed leak should lead to a question: why was this secret static, and why was it in a file? The answer is usually a move to runtime injection or to dynamic secrets and ephemeral credentials.
- Partner revocation: GitHub's secret scanning partner program notifies the issuing provider when a partner secret appears in a public repository, so the provider can act, such as by revoking it. Your process should assume a provider may revoke a key before you do, and the manager should make reissue painless.
- Bypass governance: push protection lets contributors bypass a block with a reason ("It's used in tests", "It's a false positive", "I'll fix it later"). Each bypass creates an audit log entry and an alert; delegated bypass restricts who can approve. Review bypasses weekly.
Where identity fits
Most secrets are non-human identity credentials: API keys, service account passwords, OAuth client secrets, personal access tokens and cloud access keys. That changes what "fixing" a finding means. Revoking a key without knowing which service account or integration depends on it causes outages, which is why teams hesitate and leaks stay live. An NHI inventory that links each credential to its workload, owner and permissions lets you revoke with confidence. The strongest long-term move is to remove the secret entirely: workload identity federation, managed identities and short-lived tokens mean there is nothing static to scan for. See the Cloud Access Key Leak Playbook for the response steps when a cloud key does leak.
Threat model, failure modes and a worked scenario for each option
Secrets scanning
Threat model. Scanning assumes a secret will leak into code, logs or tickets, and aims to shorten the time before it is found; the weakness it addresses is CWE-798 Use of Hard-coded Credentials. Failure modes. Alerts with no owner, and push protection that anyone with write access can bypass by giving a reason, which is the default behaviour on at least one major platform. A bypass marked "I'll fix it later" leaves an open alert that nobody closes. Controls. Push-time blocking, delegated bypass so only named reviewers can approve, and a playbook that revokes the secret rather than deleting the commit. Decision criteria. Lead with scanning when you do not yet know where secrets are.
Secrets management
Threat model. The vault becomes the high-value target, and the bootstrap credential an application uses to reach it becomes the new secret zero. Failure modes. Secrets copied out of the vault into config files, so they are managed in one place and leaked in another. Controls. Workload identity for vault access, short-lived credentials and rotation. Decision criteria. Lead with management when you know where secrets live and need to stop new ones appearing in code.
Worked scenario. A scanner flags a database password in a merged pull request. Deleting the commit does nothing, because the secret is already in clones and caches. The team rotates the password in the vault, the application picks up the new value at its next fetch, and the alert is closed only after the old credential is confirmed revoked.
Detection and measurement
Log and alert on these events:
- Scanner events: new alerts by secret type and location, push protection blocks and bypasses with the stated reason, and alerts closed without rotation.
- Manager events: secret reads by identity, failed authentication and authorisation, administrative changes, and anomalous bulk retrieval (OWASP recommends alerting on unusual retrieval and attempts to dump secrets to logs).
- Use of leaked credentials: authentication from new IP ranges or user agents with a key that was flagged, and attacker validation calls. See Leaked Secret Validation Detection.
| Metric | What it shows | Direction |
|---|---|---|
| Mean time to revoke a confirmed live secret | How fast detection turns into containment | Hours, not days |
| Push protection block rate vs bypass rate | Whether prevention at commit time is accepted or routed around | Bypasses falling |
| Repeat findings per repository | Whether teams have a working alternative to hard-coding | Falling |
| Share of production workloads fetching secrets at runtime | Adoption of management | Rising |
| Share of secrets with owner, expiry and rotation metadata | Readiness to revoke without outage | Rising towards 100% |
| Static long-lived credentials remaining | Residual attack surface for scanners to chase | Falling |
Common failure patterns
- Detection without revocation: a finding is logged, the key is deleted from the file, and the credential keeps working. The Home Depot token exposure shows the cost: a GitHub access token with wide internal access was reported exposed for more than a year before it was revoked.
- Scanning only the default branch or only new commits: secrets in old history, forks and feature branches stay live. Run a full-history baseline once, then scan incrementally.
- Vault adoption that copies secrets back out: teams fetch a secret from the manager during build and write it into an image, a Helm values file or a CI variable, recreating the exposure the vault was meant to prevent.
- Unreviewed bypasses: "I'll fix it later" becomes permanent. Without review, push protection turns into a speed bump.
- Allowlists that grow forever: suppressions such as inline allow comments or ignore files hide real keys labelled as test data. Use clearly fake, standard test secrets, as OWASP suggests.
- No owner metadata: responders cannot tell what will break if they revoke, so they wait. The leak window grows while the team investigates.
Framework mapping
| Framework | Reference | Secrets scanning | Secrets management |
|---|---|---|---|
| NIST SP 800-53 Rev 5 | IA-5 Authenticator Management; IA-5(7) No Embedded Unencrypted Static Authenticators | Verifies no embedded authenticators remain | Implements authenticator lifecycle and removes embedded secrets |
| NIST SP 800-53 Rev 5 | SI-4 System Monitoring; RA-5 Vulnerability Monitoring and Scanning | Continuous monitoring of code and content for exposed credentials | Access logs feed monitoring |
| NIST SP 800-53 Rev 5 | SC-12 Cryptographic Key Establishment and Management; SC-28 Protection of Information at Rest | Not applicable | Key and secret storage and protection |
| NIST CSF 2.0 | PR.AA-01 identities and credentials managed; DE.CM-09 computing hardware, software and data monitored | DE.CM-09 | PR.AA-01 |
| MITRE ATT&CK v20 | T1552.001 Credentials In Files; mitigation M1047 Audit | M1047: proactively search for files containing passwords | M1027 Password Policies: prohibit storing passwords in files |
| CWE | CWE-798 Use of Hard-coded Credentials | Detects instances | Removes the cause |
| OWASP Top 10 CI/CD Security Risks | CICD-SEC-6 Insufficient Credential Hygiene | Finds credentials in pipelines and logs | Scoped, short-lived pipeline credentials |
Practitioner checklist
- Run a full-history scan of every repository and record which findings are still valid before planning any migration.
- Turn on push protection on every code host and route bypass alerts to a named reviewer.
- Add pre-commit or IDE scanning for developers, with standard fake secrets for tests.
- Stand up a secrets manager or cloud secrets store and publish a one-page "where to put a secret" guide that every scanner alert links to.
- Record owner, purpose, expiry and rotation rule for every managed secret.
- Define the leak runbook: validate, revoke, rotate, remove from code and logs, check for use, log the event.
- Replace static cloud keys in pipelines with workload identity federation where the platform supports it.
- Extend scanning to tickets, chat, wikis, container registries and AI assistant configuration files.
- Report mean time to revoke and runtime-fetch adoption together each month.
Standards and references
- OWASP: Secrets Management Cheat Sheet
- MITRE: CWE-798 Use of Hard-coded Credentials
- MITRE ATT&CK: T1552.001 Credentials In Files
- OWASP: Top 10 CI/CD Security Risks
- GitHub Docs: About secret scanning
- GitHub Docs: About push protection
- GitLab Docs: Secret detection
- Gitleaks: Project documentation
Related NHI Mgmt Group resources: Secrets Management Guide · Git Secret Scanning Guide · How to enable GitHub secret scanning push protection · Honeytokens and Canary Credentials Guide · Secrets scanning tool health check