If you built an app with Lovable (or Bolt, or v0) and use Supabase, you will find a long eyJ... string in your JavaScript bundle. Many people read that as a leaked key. Sometimes it is, and sometimes it is by design. Here is how to tell.
The key that belongs in the browser
Supabase gives each project two keys. The anon (publishable) key is meant to run in the browser. It identifies your project and acts as the "anonymous" role. By itself it is not a secret.
Decode the middle section of the JWT (it is base64). If you see "role":"anon", that is the expected key.
The key that must never be there
The service_role key bypasses every access rule. If the decoded role says service_role, the key is a leak. Treat it as compromised: rotate it in the Supabase dashboard, move any code that needs it to a server function, and redeploy.
Why the anon key is only safe with Row Level Security
The anon key is safe because Row Level Security (RLS) decides what the anonymous role can read or write. If RLS is off on a table, or a policy says USING (true), anyone with the anon key from your bundle can read that table through the API. The key is not the leak in that case. The open table is.
The check, for a project you own:
- In the Supabase dashboard, open Authentication > Policies and confirm RLS is enabled on every table that holds user data.
- Look for policies that use
USING (true)on private tables. - From a signed-out browser or curl, request a table with the anon key and confirm you get no private rows.
- Test with two accounts: user B should not read user A's rows.
Quick answers
- Is the anon key in my bundle a leak? No, if it decodes to
anonand RLS is correct. - Is the service_role key in my bundle a leak? Yes. Rotate it now.
- Does an AI app builder's built-in scan cover this? It reviews your project. Check the deployed site from outside as well, because that is what a stranger sees.
ProofForge has a free count-only Supabase check and a free JWT role decoder that runs locally in your browser: https://proofforge.live/tools/supabase-rls-checker and https://proofforge.live/tools/supabase-jwt-role-decoder . Fix guide for exposed keys: https://proofforge.live/fix/service-role-key-exposed
