# 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

| 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_` 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.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## 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](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/token-expiration-and-revocation)
- [GitHub: Managing personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)
- [GitHub: Remediating a leaked secret](https://docs.github.com/en/code-security/tutorials/remediate-leaked-secrets/remediating-a-leaked-secret)

## Related

- [Fix GitHub GH013 'Push cannot contain secrets'](/errors/github-push-protection-secret)
- [Fix: .git folder exposed](/fix/git-folder-exposed)
- [Fix: .env file exposed](/fix/env-file-exposed)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
