# What does it mean when Supabase emails that your secret API key was leaked?

**Short answer:** A Supabase secret key (`sb_secret_…`) was detected in a public GitHub repository through GitHub secret scanning, and Supabase revoked it automatically. Server code using it now fails. Create a new secret key in Settings → API Keys, update your servers, and remove the old key from the repo. Legacy `service_role` JWTs aren't auto-revoked, so check those yourself.

*Last updated 2026-11-25 · Reviewed by ProofForge*

## The exact error

```text
Supabase notifies the project owner by email that a secret API key was found in a public GitHub repository and has been revoked.
Server calls with the old key now fail with: Invalid API key
```

## Why it happens

- An `sb_secret_` key was committed to a public repo (often in `.env`, a config file, or an Edge Function).
- Supabase is a GitHub secret-scanning partner. GitHub reports the match and Supabase revokes it.

## How to fix it

1. In the Dashboard, go to Settings → API Keys and create a new secret key.
2. Put it only in server-side env vars (Edge Function secrets, backend host). Redeploy.
3. Remove the old key from the repo and its history, and add `.env*` to `.gitignore`.
4. Check whether a legacy `service_role` JWT was in the same files. If so, rotate it too (that retires the legacy anon key as well, so move clients to a publishable key).

```bash
# confirm nothing secret is left in the repo
git log -p --all | grep -nE "sb_secret_|service_role"
# server env only
SUPABASE_SECRET_KEY=sb_secret_<new>
```

## Check it's fixed

Server calls succeed with the new key, and a ProofForge scan of your live app finds no `sb_secret_` or service_role JWT in the frontend.

> **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

### Was my data accessed?
The key bypasses RLS, so anyone who found it could read and write any table until it was revoked. Review logs for the exposure window.

### Does this cover the old service_role key?
No. Auto-revocation covers the new `sb_secret_` keys. Legacy service_role JWTs must be rotated by you.

### Why did my app break?
Revocation is immediate. Every server still using the old key fails until you deploy the new one.

## Sources

- [Supabase: Rotate a leaked API key](https://supabase.com/docs/guides/security/rotate-leaked-api-keys)
- [Supabase: Security retro 2025](https://supabase.com/blog/supabase-security-2025-retro)
- [Supabase: API keys](https://supabase.com/docs/guides/api/api-keys)

## Related

- [Supabase service_role / secret key leaked: first 10 minutes](/leaked-keys/supabase-service-role)
- [Fix: service_role key exposed](/fix/service-role-key-exposed)
- [Supabase JWT role decoder](/tools/supabase-jwt-role-decoder)
- [Fix GitHub GH013 'Push cannot contain secrets'](/errors/github-push-protection-secret)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [All errors](/errors)
