Skip to content

My GitHub key leaked. What do I do?

Short answer

Revoke the token in Settings → Developer settings → Personal access tokens, check your security log and repos for actions you didn't take, then create a fine-grained replacement with minimal scope and an expiry. GitHub auto-revokes tokens pushed to public repos or gists, but tokens exposed elsewhere, such as a website bundle or logs, stay live until you revoke them.

Last updated 2026-11-25 · Reviewed by ProofForge

Is it this key?

Format: Classic PAT ghp_, fine-grained PAT github_pat_, OAuth gho_, user-to-server ghu_, server-to-server ghs_, refresh ghr_

Blast radius: Whatever the token's scopes allow: reading private repos, pushing code (supply-chain risk), changing Actions secrets or settings.

The first 10 minutes

WhenDoHow
0–2 minRevokeDelete the token under Developer settings, or revoke the OAuth or GitHub App authorization.
2–5 minAuditCheck Settings → Security log and the org audit log. Look for new deploy keys, webhooks, collaborators and pushed commits.
5–8 minRotate downstreamRotate any secrets the token could read (Actions secrets, .env in private repos).
8–10 minReplaceCreate a fine-grained token limited to the needed repos and permissions, with an expiry.

Stop the next leak

  • Keep the key in a server-side env var. Never use a VITE_, NEXT_PUBLIC_ or EXPO_PUBLIC_ variable or hard-code it in frontend code.
  • Call the provider from your backend or an edge function, and add .env* to .gitignore.
  • Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed .env or .git paths.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

Did GitHub already revoke it?

If it was pushed to a public repo or gist, GitHub revokes valid tokens automatically. Check the token list.

Push protection blocked my push. Is the token leaked?

Not if the push was blocked and it never left your machine. See /errors/github-push-protection-secret.

Fine-grained or classic?

Fine-grained: per-repo access and mandatory expiry limit the damage.

Sources

Related

Read as Markdown · Scan methodology