Join our Newsletter — 33% off our NHI Course
Home› Guides› Leaked Credential and Secret Incident Response Playbook
Guide Non-Human Identity (NHI)

Leaked Credential and Secret Incident Response Playbook

← All guides
By Lalit Choda, NHI Mgmt Group Updated 27 September 2026 6 min read
On this page

When a credential leaks, the clock starts immediately. Attackers run automated scanners against public repositories, package registries, container images and paste sites, and exposed cloud keys can be used within minutes. Yet many leaked secrets stay valid for months, because nobody knows who owns them, what depends on them or how to rotate them without breaking production. This playbook gives a repeatable response for leaked API keys, cloud access keys, tokens, passwords, certificates, SSH keys and OAuth grants: triage, contain, rotate, investigate, recover and prevent. Use it alongside your wider incident response plan.

Key takeaways

  • Assume a leaked secret has been used until logs prove otherwise.
  • Revoke or disable first, then rotate. Deleting a commit or a file does not invalidate the credential.
  • Response speed depends on work done before the incident: an inventory with owners, dependency maps and automated rotation.
  • Investigate what the credential could reach as well as what it did reach.
  • Every leak is evidence of a process gap. Fix the root cause, such as a missing vault or pre-commit scanning.

Where credentials leak

Step 1: Triage (minutes)

  • Confirm it is live: check whether the credential is valid, using the provider's safe verification method where available rather than exercising its privileges.
  • Identify it: credential type, issuing system, account or tenant, and owner. If there is no known owner, escalate to the platform team for that system.
  • Size the blast radius: what permissions and data it grants, and whether it can create other credentials.
  • Record where and when it was exposed, and whether the exposure is public or internal.
  • Set severity from privilege and exposure. A public, admin-level cloud key is critical.

Step 2: Contain

CredentialContainment action
Cloud access keyDeactivate the key; attach a deny policy if needed; review and remove any identities or keys created with it
SaaS or API keyRevoke in the provider's console; restrict by IP where the provider supports it
OAuth access and refresh tokensRevoke the grant for the application; revoke refresh tokens; disable the OAuth app if compromised. See the SaaS and OAuth App Governance Guide
Personal access token (GitHub, GitLab, npm, PyPI)Revoke the token; check for new tokens, SSH keys, deploy keys or package versions created with it
Password (service account or user)Reset, revoke sessions and refresh tokens, check MFA registrations
Private key or certificateRevoke the certificate; issue a new key pair; for signing keys, assess what was signed. See the Cryptographic Key Management Guide
SSH private keyRemove the public key from every authorized_keys file and revoke any SSH certificates. See the SSH Key Management Guide
Session cookies and tokensRevoke sessions for the affected accounts. See the Token and Session Security Guide

Removing the secret from the repository, image or page is still worth doing to stop re-use, but it is not containment. The credential remains valid until revoked, and copies already exist.

Step 3: Rotate and restore service

  • Issue a replacement credential with the minimum privilege actually needed, which is often less than the original.
  • Deploy it through the vault or secrets manager rather than editing configuration by hand. See the Secrets Management Guide.
  • Where possible, replace the static secret entirely with workload identity federation or short-lived credentials. See the NHI Authentication Guide.
  • Confirm dependent services are healthy, and watch for failed authentication from anything you missed.

The Guide to NHI Rotation Challenges covers why rotation breaks things and how to plan for it.

Step 4: Investigate

  • Pull provider logs for the credential from the time of exposure (or earlier, if the exposure date is uncertain) to now.
  • Look for use from unfamiliar IP addresses, regions, user agents or tools.
  • Look for persistence: new users, keys, roles, OAuth apps, SSH keys, webhooks, CI secrets or package versions.
  • Look for data access and export, and for resource creation such as compute used for cryptomining or LLMjacking. See the LLMjacking Guide.
  • Check whether the same secret was reused elsewhere.
  • Decide on notification duties for customers, partners and regulators with legal and privacy teams.

Step 5: Recover and close

  • Remove any persistence found and rotate anything the attacker could have reached.
  • Purge the secret from repository history, images and caches where practical.
  • Update the credential's inventory record: new owner confirmation, new expiry, new scope.
  • Close the incident with a timeline: exposure, detection, revocation and rotation times.

Step 6: Prevent the next one

  • Scan before code reaches a repository (pre-commit and push protection), not only after.
  • Scan images, packages, CI logs, tickets and chat, not just source code.
  • Move secrets into a vault and inject them at runtime.
  • Replace long-lived secrets with short-lived, federated credentials.
  • Give every NHI an owner so triage does not stall. See the NHI Ownership Guide.
  • Deploy canary tokens that alert when used, to detect leaks you do not know about.

Roles and timings

RoleResponsibility
Security operationsDetection, triage, severity, coordination and investigation
Credential ownerRotation, dependency knowledge and service recovery
Platform or cloud teamRevocation where the owner is unknown; log access; persistence checks
Legal and privacyNotification decisions

Agree target times in advance, for example revocation of a public critical credential within an hour of detection, and measure against them.

Practitioner checklist

  • Maintain an inventory of NHI credentials with owners, scopes and dependencies.
  • Document how to revoke each credential type you use, and test it.
  • Revoke first, then rotate; never treat deleting the file as containment.
  • Investigate for persistence and data access from the exposure date onwards.
  • Replace leaked static secrets with federated or short-lived credentials where possible.
  • Scan code, images, packages, logs and collaboration tools continuously, with push protection.
  • Track time to detect, revoke and rotate for every incident.

Standards and references

Related NHI Mgmt Group resources: Guide to the Secret Sprawl Challenge · API Key Management Guide · Secrets Management Guide · ITDR Guide

Explore further

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Written and reviewed by Lalit Choda, NHI Mgmt Group. Last updated 27 September 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org