My GitHub key leaked. What do I do?
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
| When | Do | How |
|---|---|---|
| 0–2 min | Revoke | Delete the token under Developer settings, or revoke the OAuth or GitHub App authorization. |
| 2–5 min | Audit | Check Settings → Security log and the org audit log. Look for new deploy keys, webhooks, collaborators and pushed commits. |
| 5–8 min | Rotate downstream | Rotate any secrets the token could read (Actions secrets, .env in private repos). |
| 8–10 min | Replace | Create 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_orEXPO_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
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
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
- GitHub: Token expiration and revocation
- GitHub: Managing personal access tokens
- GitHub: Remediating a leaked secret