Leaked your Supabase secret key?
Every Supabase project has two kinds of key. One is made for the browser. The other skips every row-level security rule, and if it's in your app's front-end code, anyone who opens your site can copy it.
Which key is which
| Key | Looks like | Where it belongs |
|---|---|---|
| Publishable key, or the older anon key | sb_publishable_…, or a long string starting eyJ | The browser. Your security rules apply to it. |
| Secret key, or the older service role key | sb_secret_…, or a long string starting eyJ | Your server only: edge functions and backend code. It skips every rule. |
If a secret key leaked
- In the Supabase dashboard, open Settings, then API Keys, and create a new secret key.
- Put the new key wherever your server code used the old one.
- Check that everything works with the new key.
- Delete the old secret key. Deleting can't be undone, so do it last. A leaked older service role key is deactivated in the same place instead.
If your app runs on Lovable Cloud, the project doesn't appear in a Supabase dashboard: ask in Lovable how to replace its keys.
Then move the code that needed it
Whatever used the secret key in the browser should run in an edge function, where the key stays on the server and the browser only calls the function.
Did GitHub already catch it?
Supabase is a GitHub secret scanning partner: older service role keys pushed to a public repository are sent to Supabase, which revokes them and tells you. We couldn't confirm that the newer sb_secret_ keys are covered, so replace a leaked key yourself either way.
Find keys that shouldn't be in your code
rls-probe looks for both kinds of Supabase secret key, Stripe, OpenAI, Anthropic and AWS keys, and variables like VITE_…SECRET that a build sends to every visitor. Inspect your app in the browser.
Sources: Supabase, Understanding API keys; GitHub, Supabase is now a GitHub secret scanning partner.