My Supabase service_role / secret key leaked. What do I do?
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_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
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.