# My Supabase service_role / secret key leaked. What do I do?

**Short answer:** A service_role or `sb_secret_` key bypasses Row Level Security, so anyone with it can read, change or delete every table and file. Create a new secret key in Settings → API Keys, replace it on your servers, then retire the leaked key. Retiring a legacy service_role key also deactivates the legacy anon key, so move clients to a publishable key first.

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

## Is it this key?

**Format:** New: `sb_secret_…`. Legacy: a JWT (`eyJ…`) whose payload has `"role":"service_role"`. Publishable `sb_publishable_` / legacy anon keys are public by design.

**Blast radius:** Full read/write to all tables (RLS bypassed), Storage, and admin Auth APIs such as listing and deleting users.

## The first 10 minutes

| When | Do | How |
|---|---|---|
| 0–2 min | Confirm | Decode the leaked JWT or check the prefix. `service_role` or `sb_secret_` means rotate now. Anon or publishable doesn't need rotation, but check your RLS. |
| 2–5 min | Create & swap | Settings → API Keys → create a new secret key. Put it in server-side env vars and Edge Function secrets only, then redeploy. |
| 5–7 min | Retire | Delete the leaked secret key, or deactivate legacy keys after clients use the publishable key. |
| 7–10 min | Check data | Review API and Auth logs for the exposure window, and look for new users, changed rows or deleted files. |

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

### Will Supabase revoke it for me?
Only new `sb_secret_` keys found in public GitHub repos are auto-revoked, with an email to the owner. Legacy service_role JWTs aren't.

### Is the anon or publishable key a leak?
No, it's meant to be public. RLS is what protects data.

### How do I know which key is in my frontend?
Paste it into ProofForge's JWT role decoder, or run a scan of your live URL.

## Sources

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

## Related

- [Fix: service_role key exposed](/fix/service-role-key-exposed)
- [Supabase says your secret key leaked: what to do now](/errors/supabase-leaked-service-key-email)
- [Supabase JWT role decoder](/tools/supabase-jwt-role-decoder)
- [Fix: Supabase RLS disabled](/fix/supabase-rls-disabled)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: source maps exposed](/fix/source-maps-exposed)
- [All leaked-key guides](/leaked-keys)
