For Lovable, Bolt, Cursor and Supabase apps
Is your Supabase service_role key in your frontend?
Direct answer
If it is, treat it as an emergency. The service_role key (and the new sb_secret_ key) bypasses Row Level Security, so anyone who copies it from your public JavaScript can read, change, or delete every row in your exposed tables. The anon or sb_publishable_ key is the only Supabase key that belongs in the browser. Rotate a leaked service key, then move the code that needs it to a server function.
LeakLatch is a free, read-only scan of a live URL you own. It reports leaked secret keys in your JS bundles, Supabase tables that answer with your public anon key, and missing security headers. You get a risk score, redacted findings, and a fix prompt for Lovable, Cursor, or Claude.
Owner checks
How to check your own project
Use these on a project you own or have permission to test. They only read your own files and settings; nothing here changes your app.
Step 1
Know the two kinds of Supabase key
The anon key (or new sb_publishable_ key) is meant to be public; it can only do what your Row Level Security policies allow. The service_role key (or new sb_secret_ key) is an admin key: it skips RLS completely and can read, change and delete every row in every exposed table. It belongs only on a server.
Step 2
Decode the key, do not trust the variable name
Legacy Supabase keys are JWTs. The middle part, base64-decoded, contains a role field: anon or service_role. AI assistants sometimes put the service key into a variable called SUPABASE_KEY or even VITE_SUPABASE_ANON_KEY, so check the value, not the label.
Step 3
Search the built bundle
Build the app and run the commands below on the output folder. They look for sb_secret_ keys and print the role inside every Supabase JWT they find. Any service_role result means the admin key ships to every visitor.
Step 4
Check every place a client is created
Search your code for createClient. A browser file, a React component, or anything under src that uses the service key is a leak, even if the page is behind a login. Server functions (Supabase Edge Functions, Vercel or Netlify functions, Next.js route handlers) are the only safe place for it.
Step 5
Check the live site after each deploy
Hosting dashboards can hold different values than your local .env. Open the deployed site, look at its JavaScript files, or run a read-only scan of the live URL to see what actually shipped.
# Run in your own project folder after a production build.
# Vite (Lovable, Bolt): output in dist/ Next.js (Cursor, v0): output in .next/static/
# 1. New-style Supabase secret keys:
grep -rEo "sb_secret_[A-Za-z0-9_-]{6}" dist .next/static 2>/dev/null
# 2. Legacy JWT keys: print the role inside each Supabase-looking JWT.
for t in $(grep -rEoh "eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+" dist .next/static 2>/dev/null | sort -u); do
echo "$t" | cut -d. -f2 | tr '_-' '/+' | base64 -d 2>/dev/null | grep -o '"role":"[a-z_]*"'
done
# "role":"anon" is the public key (fine). "role":"service_role" is a leak.
# 3. Where your code creates Supabase clients:
grep -rn "createClient(" src app 2>/dev/nullCopy-paste fix
Move the admin key server-side with one prompt
Paste this into Lovable, Cursor, or Claude and point it at your own project. Review each change before you apply it, then rotate the service key if it already shipped.
You are helping me remove the Supabase service_role / sb_secret_ key from the client side of my own app. Keep existing features working. 1. Find every place the app creates a Supabase client and every env var or hard-coded string that holds a Supabase key. For each JWT key, decode the payload and tell me whether its role is anon or service_role. 2. Make the browser use only the anon / sb_publishable_ key. 3. For every feature that needed the service key (admin actions, bypassing RLS, cron jobs, webhooks), move that code into a server function (Supabase Edge Function, Vercel/Netlify function, or Next.js route handler) that reads the key from a server-only env var with no VITE_ or NEXT_PUBLIC_ prefix, and checks the caller is allowed before acting. 4. Make sure Row Level Security is enabled with correct policies on every table the browser reads or writes. 5. Remove the service key from the frontend and committed files, rebuild, confirm no service_role JWT or sb_secret_ string is in the build output, and remind me to rotate the key in the Supabase dashboard.
FAQ
Straight answers about the service_role key
Is it safe to use the Supabase service_role key in the browser?
No. The service_role key bypasses Row Level Security, so anyone who copies it from your JavaScript can read, edit or delete all data in your exposed tables and storage. Supabase documents it as a server-only key. Use the anon or publishable key in the browser and keep the service key in a server function.
How do I tell if the key in my app is anon or service_role?
For legacy keys, split the JWT at the dots and base64-decode the middle part; it shows "role":"anon" or "role":"service_role". New keys say it in the prefix: sb_publishable_ is public, sb_secret_ is secret. Your Supabase dashboard API settings page also labels each key.
I found my service_role key in the bundle. What do I do first?
Rotate it first: in the Supabase dashboard, roll the JWT secret (legacy keys) or revoke the sb_secret_ key and create a new one. Then move the code that needed admin access into a server function, redeploy, and review your tables, auth users and storage for changes you did not make. Deleting the variable alone does not help, because old copies of the bundle still contain it.
Does turning on RLS protect me if the service_role key leaked?
No. RLS is exactly what the service_role key skips. RLS protects you from the public anon key; it does nothing against a leaked admin key. You need both: RLS on every exposed table and the service key kept off the client.
What does LeakLatch check here?
LeakLatch loads the live URL you give it and its JavaScript bundles, read-only, and looks for known secret key patterns, including Supabase service_role JWTs and sb_secret_ keys, plus Stripe, OpenAI, Anthropic, AWS, Resend and GitHub keys. It also checks whether Supabase tables answer with your public anon key. Secret values are redacted in the report. You must confirm you own the site or have permission to scan it.
Is this a substitute for a full security audit?
No. LeakLatch is a pre-ship check for leaked secrets, open Supabase tables, and basic headers. It does not replace a penetration test or a careful code review.
Want this check done for you, read-only?
Paste a URL you own. LeakLatch returns a score, redacted findings, and a fix prompt.
Scan my site free