By NHI Mgmt Group Editorial TeamBased on GitGuardian: “How To Use ggshield To Avoid Hardcoded Secrets [cheat sheet included]” (December 10, 2025)

TL;DR: GitGuardian’s ggshield cheat sheet shows how terminal-first secrets scanning can cover repos, paths, archives, Docker images, packages, CI pipelines, hooks, Honeytokens, and leaked-secret checks, rather than relying on a one-time repository scan. The underlying lesson is that secrets governance has to move left, stay continuous, and fit the way developers actually work.


At a glance

What this is: This is a GitGuardian cheat sheet for ggshield that maps secrets scanning and related controls into terminal workflows across files, repos, CI, hooks, archives, containers, packages, and leaked-secret checks.

Why it matters: It matters because IAM and security teams need controls that meet developers where work happens, otherwise secrets management stays episodic while credential exposure keeps spreading across the delivery chain.

By the numbers:

👉 Read GitGuardian's ggshield cheat sheet on terminal-based secrets scanning


Context

GitGuardian’s cheat sheet is best understood as a workflow guide for secrets governance, not just a CLI reference. The article shows how a terminal-first tool can inspect code, archives, containers, packages, and pipeline changes before credentials become persistent exposure.

For IAM and NHI teams, the important shift is control placement. Secrets scanning is no longer only a repository hygiene task, because exposed credentials can enter through files, commit ranges, hooks, and CI, then survive in places developers already trust.

The article also frames Honeytokens and leaked-secret checks as part of the same operational loop. That connects detection, deception, and verification into a single developer-facing workflow instead of separate security projects.


Key questions

Q: What breaks when secret scanning is only done before commit?

A: The main break point is enforcement. Local scanning can miss untracked files, skipped hooks, and contributors who never installed the checks. It also does nothing for later changes introduced in pull requests or pipeline steps. Without repeatable server-side validation, organisations end up with optional guardrails instead of reliable control.

Q: Why do developer workflows matter for secrets governance?

A: Because developers create and package code in the terminal, the governance model has to meet them there. If scanning is outside the normal command path, it becomes optional and easy to bypass. Workflow-native controls reduce reliance on memory and make enforcement part of routine development behaviour.

Q: How do Honeytokens help detect secrets exposure?

A: Honeytokens act as decoy credentials that should never be used legitimately, so any access attempt becomes an alert signal. They are useful when you want to detect unexpected use of a secret that may already have leaked or been copied outside the intended environment.

Q: What is the difference between prevention and leaked-secret checking?

A: Prevention tries to stop new secrets from entering code, while leaked-secret checking asks whether a credential fingerprint already exists in public exposure. Both are needed because a secret can be removed locally and still remain valid in other places. Governance needs both front-end blocking and back-end verification.


Technical breakdown

How terminal-first secrets scanning changes control placement

A CLI such as ggshield moves secrets detection into the same place developers create and package code. That matters because the exposure surface is not limited to source repositories. It also includes local files, commit ranges, archives, container exports, and package contents. When scanning happens in the terminal, the control can act before a commit, before a push, or before artefacts are shared. That is a materially different control point from periodic post-hoc scanning, because the signal arrives while the developer still has context to fix it.

Practical implication: treat terminal-side scanning as a pre-exposure control, not a cleanup step after secrets have already spread.

Why hooks and CI scanning reduce secrets persistence

Git hooks and CI checks turn secrets scanning into an enforced workflow rather than an optional one. Pre-commit and pre-push hooks check tracked changes while the developer is still in flow, and CI scanning inspects the pushed commits that triggered the pipeline. That pairing matters because it covers both local authoring and shared build activity. It also reduces dependence on manual discipline, which is where hardcoded secrets typically survive. The control logic is simple, but the governance effect is broad: the earlier the scan runs, the smaller the persistence window.

Practical implication: place secrets controls at commit, push, and pipeline boundaries so credentials are blocked before they become durable history.

How Honeytokens and leaked-secret checks extend detection

Honeytokens and HasMySecretLeaked add two different layers to secrets governance. Honeytokens are decoy credentials that should never be used legitimately, so any validation attempt becomes a signal. HasMySecretLeaked checks whether secret fingerprints already appear in GitHub public exposure. Together they shift the problem from only preventing creation of secrets to also detecting reuse and external leakage. That is useful because credential risk does not end at the repo boundary. A secret may be copied, mirrored, or exposed elsewhere long after the original source file is cleaned up.

Practical implication: pair preventative scanning with tripwires and leaked-secret lookups so exposure is detected even after code has left the repository.


  • 12,000 secrets in LLM training data: Truffle Security found 11,908 live API keys and passwords hard-coded in web pages captured by Common Crawl, a dataset used to train LLMs.
  • PyPI secrets exposure 2023: Researchers found 3,938 unique secrets in published PyPI packages, 768 still valid; a new release or yank does not remove them.

Read and download The State of NHI & AI Agent Breach Report 2026, covering 150+ breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Secrets governance fails when it is limited to the repository boundary: The article shows that credentials can appear in files, archives, container exports, packages, commit ranges, and CI outputs, not just in git history. That means the governing assumption that one repo scan is enough no longer holds. The practical conclusion is that secrets control has to follow the artefact lifecycle, not the developer’s preferred location.

Developer workflow is now part of the control plane: ggshield is presented as a terminal-native tool because the terminal is where code is written, checked, packaged, and handed off. That makes workflow placement an identity and access issue, not just a developer-experience issue. If the security control is outside the normal command path, it will miss the moments when secrets are introduced.

Detection and deception belong in the same operating model: Honeytokens and leaked-secret checks are not separate features, they are complementary governance responses. One catches unexpected use, the other catches prior exposure. Together they illustrate a broader NHI governance pattern: a secret is only manageable when organisations can see both where it is created and where it later reappears.

Secrets scanning is a lifecycle control, not a point tool: The cheat sheet reinforces that authentication tokens, ignored findings, hooks, and quota awareness all sit inside one operational loop. That is the right mental model for NHI governance. Credential risk is managed through continuous placement, review, and revocation, not through a single scan event.

From our research library:

  • 28.65 million new hardcoded secrets were detected in public GitHub commits in 2025 alone, a 34% year-over-year increase and the largest single-year jump ever recorded, according to the State of Secrets Sprawl 2026.
  • Internal repositories are 6x more likely to contain secrets than public ones (32.2% vs 5.6%), contradicting the assumption that private repos are safe, according to the State of Secrets Sprawl 2026.
  • Read next: Secrets Management Buyer's Guide

What this signals

Terminal-native controls change the enforcement model: Secrets scanning becomes materially more effective when it runs where code is authored, committed, and packaged. That reduces dependence on periodic review cycles and pushes credential control into the developer’s normal command flow.

Repository-only thinking is too narrow for credential risk: Archives, Docker images, packages, and CI outputs all carry secrets exposure risk, which means governance has to follow artefacts rather than stop at version control.

Honeytokens create a useful governance boundary: A decoy credential is only valuable when teams can distinguish real use from unexpected use, and that makes tripwires a practical complement to prevention controls.


For practitioners

  • Embed scanning before commit and push Use pre-commit and pre-push checks so secrets are blocked while developers still have enough context to fix them. This is the highest-leverage control point in a terminal-first workflow.
  • Scan artefacts beyond source repositories Extend scanning to local files, commit ranges, archives, Docker images, and packages so exposed credentials are not missed simply because they are outside the repo tree.
  • Pair prevention with tripwires Use Honeytokens for decoy credentials and HasMySecretLeaked checks for public exposure so you can detect both active use and prior leakage.
  • Track quota and file-size limits Review API call consumption and remember that files over 1MB or with binary extensions are not scanned, so coverage assumptions need to match tool boundaries.

Key takeaways

  • Secrets management fails when scanning is treated as a repository task instead of a workflow control across files, builds, and packages.
  • The article shows that ggshield is designed to operate where developers already work, which is where risky credentials are most likely to enter the delivery chain.
  • Combining pre-commit checks, CI scanning, Honeytokens, and leaked-secret lookups gives teams a more complete view of credential exposure.

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 and MITRE ATT&CK address the attack and risk surface, while NIST SP 800-53 Rev 5 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-02 — Secret LeakageThe article centres on finding secrets in code, archives, containers, and CI before they spread.
NHI-07 — Long-Lived SecretsThe article repeatedly addresses hardcoded credentials that persist in history and shared artefacts.
Recommendation — Scan developer workflows for exposed secrets and revoke any credential that appears in code or build artefacts. Reduce long-lived secret exposure by enforcing early detection and removal before commits become permanent history.
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementThe article deals with credential lifecycle control, including discovery and handling of secrets used for authentication.
Recommendation — Apply authenticator management controls to detect, rotate, and retire secrets found in development workflows.
MITRE ATT&CKTA0006 — Credential AccessThe core threat pattern is secret exposure that can later be harvested and abused by an attacker.
Recommendation — Map exposed credentials to credential-access detection and prioritise workflows that leak reusable secrets.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsThe article is about governing where secrets grant access and preventing over-broad credential use.
Recommendation — Review secret-bearing workflows so entitlements are limited to the minimum access needed for each task.

Key terms

  • Secrets Scanning: Automated tooling that scans source code repositories, CI/CD pipelines, and cloud environments to detect exposed secrets such as API keys, tokens, and passwords before they are exploited.
  • Honeytoken: A honeytoken is a deliberately planted secret or credential designed to be detected when used. It helps security teams spot misuse early, especially in environments where machine identities and automation can move faster than manual investigation or containment.
  • Pre-commit Hook: A pre-commit hook is an automated local check that runs before code is written into git history. It is especially useful for catching secrets, because once a token or key is committed, removal becomes a revocation problem as well as a code cleanup problem.
  • Commit Range Scan: A commit range scan checks a selected span of repository history instead of the whole project. It is useful when teams need to focus on recent changes or validate whether secrets remain in a bounded slice of history after remediation.

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, archive, Docker, and PyPI scans
  • Step-by-step examples for pre-commit, pre-push, and pre-receive hook setup
  • Authentication and configuration options, including login scopes and token handling
  • HasMySecretLeaked workflow details, including fingerprinting and decrypted output

👉 The full GitGuardian article covers command syntax, hooks, Honeytokens, and leaked-secret checks in detail.

Deepen your knowledge

NHI governance, secrets management, and workload identity security are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are building or maturing an IAM programme, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on May 30, 2026.
Updated on October 7, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org