TL;DR: GitGuardian’s ggshield cheat sheet maps a terminal-first workflow for scanning repos, paths, archives, Docker images, packages, and CI pipelines, while also covering hooks, Honeytokens, and HasMySecretLeaked for leaked-secret checks. The broader lesson is that secrets control has to move left and operate continuously, not as a one-time repository scan.
At a glance
What this is: GitGuardian’s ggshield cheat sheet is a CLI-focused guide to scanning code, files, archives, containers, CI, and leaked secrets from the terminal.
Why it matters: For IAM and NHI practitioners, it shows how secrets detection can be embedded into developer workflows instead of treated as a separate security review step.
By the numbers:
- GitGuardian says it has a database of over 20 million publicly leaked secrets for its HasMySecretLeaked service.
👉 Read GitGuardian's ggshield cheat sheet for terminal-based secrets scanning
Context
Secret scanning is only useful when it fits how developers actually work, because secrets exposure often starts in local files, commit history, CI pipelines, and packaged artifacts rather than in one obvious repository event. For NHI governance, that means detection has to reach beyond source code review and into the places where service credentials, tokens, and certificates get created, copied, and reused.
The article frames ggshield as a terminal workflow tool, but the governance issue is broader: every command path that can inspect code or content can also become a control point for NHI hygiene. That is typical of modern development teams, where the operational boundary between coding, shipping, and credential handling is thin and often poorly instrumented.
Key questions
Q: How should teams stop secrets from entering code in the first place?
A: The most effective pattern is to scan before code is shared, not after. Use local pre-commit and pre-push checks, then reinforce them with CI scanning so secrets are blocked in both developer and pipeline paths. That reduces the chance a token reaches shared history, packaged artefacts, or deployment systems.
Q: What is the difference between scanning a repository and scanning a CI pipeline?
A: Repository scanning looks for secrets already present in source history or working files, while CI scanning checks the set of commits that triggered a build. Both matter, but they catch different moments in the lifecycle. Repository scanning is broader; CI scanning is more immediate and better suited to enforcement at release time.
Q: Why do leaked secrets remain a problem after developers delete them?
A: Deleting a secret from the latest commit does not remove it from earlier commits, copied artefacts, archives, or other systems that already captured it. Unless the credential is revoked and rotated, it may remain valid and exploitable. That is why detection must be paired with lifecycle response, not treated as the end state.
Q: Should organisations use Honeytokens as part of secrets management?
A: Yes, when they want to detect unexpected use of credentials and validate that monitoring works. Honeytokens are useful because they act like real secrets without providing access. They do not replace prevention or rotation, but they do add a practical signal for misuse, especially in environments with broad secret sprawl.
Technical breakdown
How CLI-based secret scanning works across development artifacts
A CLI secret scanner works by inspecting content for patterns, fingerprints, or known secret formats and then returning findings that can be acted on in automation. The important detail is scope. The same engine can evaluate a repository, a single path, an archive, a container image, a package, or a commit range. That breadth matters because NHI exposure is rarely limited to source control alone. When the scanner is embedded in pre-commit or pre-push hooks, it shifts from retrospective discovery to preventive control at the developer edge.
Practical implication: Treat CLI scanning as a control plane for developer-side NHI exposure, not just as a one-off audit tool.
Why hooks and pipeline scans matter for NHI lifecycle control
Git hooks and CI scans change the timing of detection. Pre-commit and pre-push checks reduce the chance that secrets ever land in shared history, while CI scanning catches what escaped local review. This matters for NHI lifecycle management because exposure is a lifecycle failure, not only a storage failure. If a token is copied into a repo, archive, or build artifact, it becomes part of the environment’s identity sprawl and can persist long after the original developer action is forgotten.
Practical implication: Use local hooks for prevention and CI scans for enforcement, then tie both to revocation workflows.
What Honeytokens and leaked-secret checks add to defence in depth
Honeytokens are decoy credentials that alert when someone tries to use them, which makes them useful for detecting unexpected access paths and validating whether a secret has escaped containment. HasMySecretLeaked adds a second layer by checking whether fingerprints match publicly exposed secrets. Together, these controls address two different problems: active misuse and prior exposure. For NHI teams, that combination helps separate secrets discovery from secrets abuse, which is essential when leaked credentials may remain valid long after disclosure.
Practical implication: Pair decoy credentials with leak intelligence so exposure, use, and revocation are linked in one workflow.
Threat narrative
Attacker objective: The attacker wants durable access through a credential that survives the original developer workflow and can be reused outside it.
- Entry occurs when a secret is copied into source code, a commit history, a CI artifact, or an exported container image.
- Escalation follows when the exposed credential is reused in another system, often because the same NHI is shared across applications.
- Impact occurs when the leaked secret gives access to cloud resources, repositories, or supporting services beyond the original codebase.
Breaches seen in the wild
- CI/CD pipeline exploitation case study — full server takeover via exposed .git directory and mismanaged CI/CD pipeline secrets.
- Shai Hulud npm malware campaign — Shai Hulud campaign: npm malware exposed secrets on GitHub.
Read our 52 NHI Breaches Analysis report for a comprehensive view of breaches impacting Non-Human Identities including AI Agents.
NHI Mgmt Group analysis
CLI secret scanning is becoming a frontline NHI control, not a developer convenience. The article shows that secret detection now spans repositories, paths, archives, containers, and CI. That is the right direction because NHI exposure does not respect tool boundaries. Security teams should treat the terminal as a governance surface and not only as a developer interface.
Identity blast radius grows when secrets are discoverable across multiple workflow layers. When a token appears in a commit, archive, package, or pipeline, the same credential can re-enter the environment through several paths. That creates a larger operational blast radius than many IAM teams model today. The practical conclusion is simple: discovery must be paired with rapid revocation and scope reduction.
Honeytokens add value because they test assumptions, not just compliance. A decoy secret reveals whether an attacker, insider, or automation process can reach and attempt to use a credential that should not be active. That makes deception a control for visibility and validation, not just detection. Practitioners should use it to confirm that their NHI monitoring can distinguish routine noise from real misuse.
HasMySecretLeaked-style checks address the part of the problem scanners cannot solve alone. A local scan can tell you that a secret exists, but it cannot prove whether that secret has already been copied into external systems or public repositories. The NHI governance lesson is that exposure intelligence belongs in the same operating model as rotation and offboarding. Teams should assume that any discovered secret may already be in circulation.
Static secrets remain the weak point in otherwise modern development workflows. Terminal-based automation makes it easier to catch them, but it does not remove the underlying trust problem of long-lived credentials. That is why the broader control objective should be reducing standing secret exposure, shortening credential lifetime, and making reuse harder. Security teams should move toward dynamic or tightly scoped credentials where possible.
From our research:
- 64% of valid secrets leaked in 2022 are still valid and exploitable today, according to The State of Secrets Sprawl 2026.
- 44% of NHI tokens are exposed in the wild, being sent or stored over collaboration tools, tickets, pages, and code commits, according to Entro Security.
- That is why teams should pair discovery with automated revocation and lifecycle review, a pattern explored in Ultimate Guide to NHIs , Static vs Dynamic Secrets.
What this signals
Secret scanning is becoming a governance control for autonomous development workflows. As more work moves through terminals, CI pipelines, and packaged artefacts, the control point moves closer to the developer edge. Teams should assume that a secret found in one location may already exist in several others, which makes revocation speed more important than detection volume.
Identity blast radius is the useful operating concept here. A leaked NHI credential is not just a data point, it is a path to lateral use across systems that still trust the same token or key. Security programmes should measure how far a single credential can travel, then reduce that distance with scope, TTL, and offboarding controls.
The governance gap is now visible in the numbers: AI-related credential leaks surged 81.5% year-over-year in 2025, according to The State of Secrets Sprawl 2026. That trend suggests the problem is expanding into AI build and runtime paths faster than many IAM processes can classify and contain it.
For practitioners
- Embed pre-commit and pre-push secret checks Run automated scans locally before code enters shared history so exposed tokens are stopped at the developer edge. Make the checks part of the standard workflow for every repository that handles service credentials, API keys, or certificates.
- Scan non-repository artefacts for secrets Extend detection to archives, Docker images, package dependencies, and standalone files because secrets often leave source control through packaging and distribution paths. Treat exported build artefacts as first-class NHI exposure surfaces.
- Tie findings to revocation and rotation Create an operational path from detection to token revocation, secret rotation, and access review so a discovered secret does not remain valid. If a credential is still active after exposure, the scan only proves awareness, not control.
- Use Honeytokens to validate misuse detection Place decoy credentials in realistic locations where unexpected access would be meaningful, then monitor for activation. This helps confirm whether monitoring, alerting, and triage processes can distinguish real compromise from routine developer activity.
Key takeaways
- CLI secret scanning matters because it moves NHI exposure control into the developer workflow where secrets are created and copied.
- Discovery alone is insufficient when leaked credentials can stay valid until a separate revocation action is taken.
- Teams should combine local hooks, CI enforcement, and lifecycle response so secret detection becomes a governed process rather than a best-effort check.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-01 | Secret discovery and hardcoded credentials are central to this article. |
| NIST CSF 2.0 | PR.AC-1 | Credential exposure directly affects access control and identity assurance. |
| NIST Zero Trust (SP 800-207) | Short-lived access and continuous verification fit the article's workflow focus. |
Scan code, pipelines, and artefacts continuously, then remove exposed secrets from every lifecycle stage.
Key terms
- Secret Sprawl: Secret sprawl is the uncontrolled spread of credentials across code, tickets, chat, archives, and runtime systems. It turns one token into many copies, which increases exposure and makes revocation harder because no single system owns the full lifecycle of the secret.
- Honeytoken: A honeytoken is a decoy credential designed to look real but provide no useful access. It is used to detect unexpected use or validation attempts, giving defenders a signal that a secret has escaped normal control or that an attacker is testing exposed assets.
- Commit History Exposure: Commit history exposure happens when a secret is removed from the latest version of code but remains available in earlier commits or branches. This is a common NHI failure mode because the credential can survive long after the visible fix, especially if rotation and revocation are delayed.
- Identity Blast Radius: Identity blast radius is the amount of damage a single NHI credential can create if it is exposed or misused. It depends on privilege scope, reuse across applications, token lifetime, and whether monitoring can detect and revoke the credential quickly enough.
What's in the full article
GitGuardian's full article covers the operational detail this post intentionally leaves for the source:
- Exact ggshield command syntax for repo, path, commit-range, archive, Docker, and PyPI scans
- Authentication, token scope, and logout behaviour for terminal-based use
- Hook installation options for pre-commit and pre-push automation
- HasMySecretLeaked workflow details for fingerprinting and checking leaked secrets
👉 GitGuardian's full cheat sheet includes command examples, hooks, and leak-check workflows
Deepen your knowledge
Secret scanning across repositories, CI, archives, and leaked-secret workflows is covered in our NHI Foundation Level course, the industry's only accredited NHI security programme. If your team is trying to reduce secrets sprawl without slowing developers down, it is worth exploring.
Published by the NHIMG editorial team on 2025-12-10.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org