By NHI Mgmt Group Editorial TeamDomain: Breaches & IncidentsSource: SemgrepPublished November 20, 2025

TL;DR: Common secret-scanning design choices such as word boundaries and keywords can miss valid live secrets in public GitHub repositories, including tokens from GitHub, OpenAI, Anthropic, Gemini and others, according to Semgrep. The result is a familiar governance problem: tuning for fewer false positives can silently widen the false-negative window.


At a glance

What this is: This analysis shows that over-restrictive secret-scanning rules can miss valid live secrets in public repositories, especially when scanners rely on word boundaries and narrow keyword logic.

Why it matters: IAM, AppSec, and NHI teams need to understand that detection tuning can create hidden exposure, leaving hardcoded secrets, API keys, and tokens outside monitoring and revocation workflows.

By the numbers:

  • The average estimated time to remediate a leaked secret is 27 days, despite 75% of organisations expressing strong confidence in their secrets management capabilities.
  • Only 44% of developers are reported to follow security best practices for secrets management, exposing a significant developer behaviour gap.

👉 Read Semgrep's analysis of why secret scanners miss valid live tokens


Context

Secret scanning is the control that looks for exposed credentials, tokens, and API keys in code and related artefacts before they are abused. In this article, the primary problem is not that secret scanning exists, but that design choices made to reduce noise can create false negatives and allow live secrets to remain in public GitHub repositories.

For IAM and NHI programmes, this matters because a secret is an identity artefact. If scanners miss it, rotation, revocation, and incident response may never begin. The article is about detection accuracy, but the governance impact reaches across secrets management, application security, and workload identity oversight.

The examples here are typical of modern development environments where tokens can appear in code comments, terminal output, notebook cells, diffs, and encoded strings. That makes detection rules part of the control plane, not a back-office tuning detail.


Key questions

Q: How should security teams reduce false positives in generic secrets scanning?

A: Start by removing credential types that are public by design, then add contextual checks for keys whose risk depends on platform permissions or surrounding code. The goal is not to suppress more findings overall, but to preserve analyst time for credentials that can actually be used to access sensitive systems.

Q: Why do secret scanners miss valid credentials in source code and repository artefacts?

A: They often assume that secrets will appear in clean, standalone formats. In practice, developers paste credentials into comments, strings, output files, or encoded text that breaks the regex assumptions. If the scanner depends too heavily on word boundaries or a nearby provider keyword, it can miss a live secret even when the token itself is valid.

Q: What do teams get wrong about keyword-based secret detection?

A: They treat keywords as proof of identity instead of one signal among several. A keyword can be missing, misplaced, or wrong, especially when developers use a different product label than the token issuer. That means keyword-only validation can exclude real secrets and create a false sense of control coverage.

Q: What should organisations do when a live secret is discovered in a public repository?

A: Revoke or rotate the credential immediately, confirm where it was copied, and check whether the token was exposed in other artefacts such as logs, notebooks, or chat tools. Then review why detection failed so the same token family is not missed again. Public exposure is both an incident and a control failure.


Technical breakdown

How word boundaries create secret-scanning blind spots

Word boundaries are regex rules that only match when a token sits between non-word characters. That helps reduce noise, but it also means a valid secret embedded in code comments, concatenated strings, ANSI output, or encoded text can disappear from detection. When scanners depend too heavily on boundary logic, they stop detecting the token shape and start detecting formatting instead. In practice, the control fails whenever a live secret is surrounded by characters that look like ordinary text to the regex engine but still preserve the secret value.

Practical implication: review boundary rules against real repository content, not only idealised token examples.

Why keyword filters miss real secrets in application code

Keyword filters try to improve confidence by requiring a provider name or adjacent context before a match is validated. That works until the keyword appears in the wrong place, in the file name, or not at all. It also fails when developers label a token incorrectly, such as using a different provider name in code than the token's actual service. The result is a detection model that assumes context is reliable even though developers often copy, rename, or embed secrets inconsistently across files and workflows.

Practical implication: treat provider keywords as one signal, not a hard prerequisite for high-confidence detection.

Why provider-specific token formats matter more than generic regex

Generic expressions such as broad token prefixes and wide length ranges increase match coverage, but they also force scanners to lean on boundaries and keywords to suppress noise. The better approach is precise patterning for each token family, including unique prefixes, suffixes, and service-specific markers where they exist. Semgrep's research argues that some services already have enough uniqueness to support tighter matching without the same false-positive tradeoff. This is a detection engineering problem, not just a secrets policy issue.

Practical implication: maintain separate rules for distinct token families and test them against real leaked examples.


Threat narrative

Attacker objective: The objective is to obtain a usable credential or token that can be replayed before defenders detect and revoke it.

  1. Entry occurs when a secret is committed, pasted, logged, or otherwise exposed into a repository, notebook, terminal capture, or related artefact.
  2. Escalation follows when over-restrictive scanner logic fails to classify the exposed value as a live credential because of boundary or keyword assumptions.
  3. Impact occurs when the missed secret remains valid long enough for reuse, abuse, or downstream compromise of the connected service.

Read our 52 NHI Breaches Analysis report for a comprehensive view of breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

False-negative tolerance is now an identity governance decision, not a tuning preference. Secret scanning exists to find live credentials before they become attacker-controlled identity material, but every suppression rule changes the control's failure mode. When boundary logic and keyword logic become more important than token fidelity, the programme is trading certainty of detection for comfort on false positives. The practitioner conclusion is simple: if the scanner cannot reliably find live secrets in real developer output, the governance model is already incomplete.

Secret scanning is an NHI control because secrets are identities, not just strings. API keys, PATs, tokens, and certificates are the credentials that let non-human actors authenticate and act. That means missed detection is not merely code hygiene failure. It is a lifecycle failure where issuance, exposure, and revocation are disconnected from each other. Practitioners should treat exposed secrets as unmanaged NHI objects until they are rotated or invalidated.

Boundary-heavy detection creates a secret sprawl blind spot that compounds over time. The more a scanner relies on exact formatting assumptions, the more it misses secrets in comments, diffs, notebooks, logs, and encoded output. Secret-scanning coverage debt: this is the accumulation of valid credentials that exist in the environment but sit outside the scanner's effective match model. The practitioner conclusion is that coverage testing must be continuous, because one missed token can outlive dozens of correctly blocked false positives.

Provider-specific precision beats generic regex when token ecosystems are diverse. Broad patterns look efficient, but they often force scanners into overbroad suppression rules that reduce real detection quality. Precise token families, validated against live repository examples, create a better balance between signal and noise. For IAM and security teams, the lesson is to benchmark detection logic against the actual token formats in use, not against abstract regex ideals.

Secret scanners only work as well as the upstream secret management discipline behind them. If developers paste live tokens into code, logs, or collaboration tools, scanning becomes a last line of defense rather than a containment layer. That is why scanning, rotation, short-lived credentials, and revocation need to be treated as one operating model. The practitioner conclusion is that detection quality and credential lifecycle governance must be managed together.

From our research:

What this signals

Secret-scanning coverage debt: teams that tune for low false positives without a validation harness usually end up with a hidden backlog of live credentials. The practical risk is not only missed detection, but delayed revocation and unmeasured exposure windows that outlast the commit that introduced them.

With 4.6% of public GitHub repositories already containing at least one hardcoded secret, according to GitGuardian's The State of Secrets Sprawl 2025, the problem is not edge-case leakage. It is a repeatable governance failure that needs continuous testing of scanner rules, not occasional tuning.

Security teams should pair scanner rule review with lifecycle controls for the secrets themselves. That means shorter-lived credentials, stronger revocation paths, and operational checks that confirm a missed secret is actually removed from the environment rather than just suppressed in tooling.


For practitioners

  • Audit scanner rules for false-negative bias Test boundary and keyword rules against real examples from code comments, notebooks, diffs, encoded output, and terminal logs. Look for patterns that suppress valid secrets because the token is embedded in a larger string or missing an expected provider keyword.
  • Use token-family-specific rules Replace broad generic regex with precise patterns for each secret format you actually issue or ingest. Keep separate handling for distinct prefixes, suffixes, and service markers so one rule does not hide another service's live credential.
  • Add post-commit validation and revocation workflows Treat detection as the trigger, not the end state. When a secret is found, immediately verify whether it is live, revoke it if possible, and route the event into your incident workflow so exposure does not linger for days.
  • Monitor public repositories for your own token types Do not rely only on partner programs or push protection. Search for your token types in public code, especially where repositories may have moved from private to public or where developers bypassed the normal protection path.

Key takeaways

  • Secret scanning can fail when detection rules are too strict, turning false-positive reduction into a false-negative problem.
  • Hardcoded secrets remain common in public code, which means exposure is a governance issue as much as a tooling issue.
  • Teams need precise token formats, continuous rule testing, and fast revocation workflows to close the gap between detection and containment.

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 CSF 2.0, NIST SP 800-53 Rev 5 and NIST Zero Trust (SP 800-207) set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Non-Human Identity Top 10NHI-03The article centers on exposed secrets and detection gaps in NHI credential management.
NIST CSF 2.0PR.AC-1Secret detection and revocation support access control and identity governance outcomes.
NIST SP 800-53 Rev 5IA-5Authenticator management applies directly to leaked API keys and tokens.
MITRE ATT&CKTA0006 , Credential Access; TA0010 , ExfiltrationLeaked secrets enable credential access and downstream data theft.
NIST Zero Trust (SP 800-207)3.1Zero Trust depends on strong identity verification for non-human credentials.

Treat exposed secrets as trust failures and reduce standing credential validity wherever possible.


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.
  • False Negative: A false negative is a valid secret or credential that exists in the environment but is not detected by the scanner. For identity teams, false negatives are especially dangerous because they delay rotation, revocation, and incident handling while leaving the credential usable.
  • Token Prefix Collision: Token prefix collision occurs when different services use similar credential patterns, making it hard for scanners to attribute a match correctly. This can force teams into broader suppression rules, which may improve confidence but also increase the chance of missing live secrets.
  • Secrets Sprawl: The uncontrolled proliferation of sensitive credentials — API keys, tokens, passwords, certificates — across codebases, cloud environments, CI/CD pipelines, and configuration files. In 2024, over 50 million leaked secrets were found on the dark web.

What's in the full report

Semgrep's full blog post covers the detection examples and rule-level detail this post intentionally leaves for the source:

  • Specific regex permutations used to test word boundaries and keyword placement across GitHub repositories
  • Concrete examples of missed secrets from GitHub, OpenAI, Anthropic, Gemini, and related services
  • The provider-specific detection changes Semgrep says it made after reviewing false-negative patterns
  • Recommendations for third-party services on token design, uniqueness, and revocation endpoints

👉 Semgrep's full post includes the regex examples, missed-token cases, and detection recommendations.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity lifecycle 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 August 2, 2026.
NHI Mgmt Group — the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org