Response & recovery

Leaked API key response: revoke, investigate, and fix the path

An exposed API key needs an authority and usage review, not just deletion from a file. Identify what it permits, revoke or replace it using the provider’s supported process, investigate relevant activity, and correct the path that exposed it. Perform sensitive recovery from a trusted environment.

What matters first

  • Deleting a key from source or a page does not invalidate existing copies.
  • Map the key’s consumers and permissions before coordinating replacement.
  • Verify old-key rejection and inspect relevant provider activity.

Identify the credential and its authority

Establish the provider, environment, permissions, owner, and consumers without copying the secret into a public ticket or booking form. Determine whether the value is a privileged credential or an intentionally public identifier. The response should follow its actual capability, not its appearance.

Record where and when exposure was observed: a public repository, browser bundle, log, image layer, support attachment, or compromised machine. Preserve enough evidence to understand the path while limiting further distribution of the value.

References: [1] OWASP, [2] GitHub

Revoke or rotate from a trusted environment

Use the provider’s supported replacement and revocation process with the responsible owner. If there is active misuse or a highly privileged exposure, containment urgency may require a different sequence from routine maintenance. Keep a clear record of actions and their operational effects.

Update consumers through a controlled path and avoid introducing a replacement credential into a system still suspected to be compromised. Review related tokens, sessions, or credentials reachable through the same exposure. Rotating one value is not enough when the attacker retains access to its source.

References: [3] NIST, [1] OWASP

Investigate use and downstream consequences

Review provider audit records and relevant application activity for the credential’s known exposure window, while preserving uncertainty about when it was first obtained. Look at the actions the key could authorize and identify affected resources or newly created authority that needs investigation.

Keep confirmed misuse distinct from potential reach. A broad key can create substantial risk without proving every reachable asset was accessed. Coordinate any customer or external communication through the authorized incident process using supported facts.

References: [4] OWASP, [3] NIST

Correct the exposure path and verify closure

Remove the secret from the inappropriate publication or logging path and fix the code or configuration that placed it there. If it entered repository history or public artifacts, assess retained copies and the platform’s cleanup process. GitHub’s guidance makes clear that removing sensitive data can require coordinated history and clone handling.

Verify that the old key is rejected and intended consumers use the replacement. Check secondary deployments, queued jobs, and rarely used integrations. Add a preventive check close to the exposure path, and record the owner of the credential’s future lifecycle.

References: [2] GitHub, [5] Next.js, [1] OWASP

Your next steps

  1. Identify the key’s authority, owner, consumers, and observed exposure path.
  2. Coordinate revocation or rotation from a trusted administrative environment.
  3. Review relevant activity and any downstream authority changes.
  4. Verify rejection of the old key and scope a review of the underlying leak path.

Questions teams ask

Can we just delete the key from GitHub?

Deletion can reduce future exposure, but a retrieved copy may remain usable. Revoke or rotate the credential and assess relevant activity.

Should we paste the key into a support request for identification?

Avoid distributing the value further. Use the provider’s identifier or restricted support process and share only the context needed by the authorized owner.

Sources and editorial notes

Public-source facts are cited above. The review questions and action plans are Cyphen’s guidance for applying those lessons to your own systems. Sources checked on .

  1. OWASP: Secrets Management Cheat Sheet
  2. GitHub: Removing sensitive data from a repository
  3. NIST: Incident Response Recommendations: SP 800-61 Rev. 3
  4. OWASP: Logging Cheat Sheet
  5. Next.js: Environment variables and browser bundling