Join our Newsletter — 33% off our NHI Course

How should security teams respond when an exposed credential is found in public code but has not yet been revoked?

Treat detection as the start of the workflow, not the end. Teams should verify whether the credential still authenticates, identify what it can reach, assign ownership, and revoke it at the issuing service. Removing the secret from code or closing a ticket is not enough. The goal is verified revocation, because only that removes access and proves the exposure is no longer active.

What “found in public code” changes, and what it does not

An exposed credential in source code is already an access event, even if no one has confirmed abuse yet. Public code tells you where the secret was seen, but not whether the credential is still valid, where it is trusted, or whether it has already been copied. That is why the response has to move from discovery to verification, then to removal of access at the source service.

The practical mistake is treating code cleanup as the control. Deleting the line, rotating a repository, or closing the ticket may reduce future discovery, but it does not prove the credential can no longer authenticate. The real question is whether the secret still opens anything outside the repository, and that can only be answered by checking the issuing service and the systems it reaches.

What to verify before you declare the exposure contained

Once a credential is found, teams should establish whether it is live, what scope it has, and whether the token or key is tied to a human workflow, an application, or a service path. That verification should include the issuing platform, any downstream APIs or data stores, and any logs that show use after the exposure window began. If the credential can still authenticate, containment has not started yet.

Ownership matters because revocation often crosses team boundaries. The group that found the secret may not control the service that issued it, and the service owner may not know which application depended on it. A good response ties the exposed value to a named owner, a named service, and a specific revocation action, so the team does not stall in handoff ambiguity. For background on how exposed secrets move from discovery to remediation, see Guide to the Secret Sprawl Challenge and Secrets Management Guide.

Why verified revocation is the only safe endpoint

Revocation is the decisive control because it removes the credential’s ability to be used, not just its visibility in code. For API keys and similar bearer secrets, that usually means revoking the active key, replacing it with a new one, and confirming that old authentications fail everywhere they are supposed to fail. If the secret has been cloned into build logs, CI variables, containers, or documentation, each copy has to be treated as part of the same exposure event.

Teams should also distinguish short-lived credentials from long-lived ones. A stale API key or token demands immediate revocation and post-exposure validation, while a dynamic credential with a narrow lifetime may require less manual cleanup but still needs confirmation that the old instance expired as expected. See API Key Management Guide for lifecycle handling, and Ultimate Guide to NHIs, Static vs Dynamic Secrets for the difference between persistent and ephemeral credentials.

Risk and Threat Considerations

public code exposure creates a simple but serious attack path: anyone who sees the credential can attempt immediate use, and automated scanners routinely harvest these values at scale. The main risk is not the leak itself, but the time window before revocation, during which the credential may be used for lateral access, data access, or service abuse.

Failure mechanism: The exposed secret remains valid after discovery, so the attacker does not need to bypass controls, they only need to replay the credential before it is revoked or expires.

Impact: Unrevoked exposure can lead to unauthorized access, resource abuse, data exfiltration, or deeper compromise of whatever the secret can reach.

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 addresses the attack and risk surface, while NIST SP 800-53 Rev 5, OWASP ASVS and CIS Controls v8 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST SP 800-53 Rev 5 IA-5 — Authenticator Management Exposed credentials require lifecycle control, revocation, and replacement.
IA-9 — Service Identification and Authentication The question concerns non-human credentials used by services and APIs.
AC-2 — Account Management Ownership and removal of exposed access depends on account lifecycle control.
Recommendation — Revoke the compromised authenticator, replace it, and verify the old value no longer works. Validate the service authenticator’s scope and rotate or revoke it at the issuing system. Assign an owner and disable the associated access path before closing remediation.
OWASP ASVS V6 — Authentication Credential exposure must be addressed by invalidating authentication material, not just editing code.
V9 — Self-contained Tokens Bearer-style tokens and API keys must be treated as valid until explicitly invalidated.
Recommendation — Ensure exposed secrets are revoked and replaced so authentication cannot succeed with the leaked value. Invalidate leaked tokens and confirm they are rejected after rotation.
OWASP Non-Human Identity Top 10 NHI-02 — Secret Leakage Public code exposure is a direct secret-leak scenario requiring revocation.
NHI-07 — Long-Lived Secrets The response depends on shortening or eliminating persistent credentials.
Recommendation — Treat leaked secrets as active access material and revoke them at the source. Replace long-lived exposed secrets with shorter-lived credentials where possible.
CIS Controls v8 CIS-5 — Account Management Exposed credentials require prompt disablement, review, and lifecycle cleanup.
CIS-16 — Application Software Security Source-code secret exposure is an application security and remediation issue.
Recommendation — Remove the exposed access path and verify the account or key is no longer usable. Scan, remove, and remediate exposed secrets in application code and pipelines.

Practitioner Guidance

What to prioritise: Revoke at the issuing service first, then validate that the old credential no longer authenticates anywhere. If the secret is still live, treat the incident as active exposure, not completed remediation.

What to verify: Confirm scope, ownership, and downstream reach before you close the case. A complete response should show who owned the secret, which system issued it, what it could access, and evidence that the old value failed after revocation.

Practitioner takeaway: Secret removal from code is hygiene; verified revocation is containment. Until the issuer rejects the credential, the exposure is still operational.