Skip to content

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

WhenDoHow
0–2 minConfirmDecode 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 minCreate & swapSettings → API Keys → create a new secret key. Put it in server-side env vars and Edge Function secrets only, then redeploy.
5–7 minRetireDelete the leaked secret key, or deactivate legacy keys after clients use the publishable key.
7–10 minCheck dataReview 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.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

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

Related

Read as Markdown · Scan methodology