Lovable: Exposed anon or service role key
Supabase gives you two kinds of keys. The anon (publishable) key is meant to be public and is only safe when RLS is on. The service role (secret) key skips every rule and must never reach the browser.
Free scan: check my app Just your web address. Results in seconds. No signup, no card.
Why it matters for your Lovable app
Lovable apps usually use Supabase for the database and login. Lovable has a built-in security scan, but it can’t sign in as two real users and compare what each one sees.
If the service role key is in your front-end code, anyone can read, change or delete everything in your database. If the anon key is public and RLS is off, the result is nearly as bad.
How to check in five minutes
- Open your live site, press F12, and search the Sources or Network tab for “service_role” or “sb_secret”.
- Search your project code for the service role key.
- If you find it in front-end code, rotate it in Supabase straight away.
What PeekLok’s scan checks
PeekLok’s scan looks through your page and the scripts it loads from your site for Supabase keys. It tells you if a service role key is showing, and if the anon key is there it uses it to test which tables anyone can read.
Fix prompt to paste into the Lovable chat
Find every place the Supabase service role key is used. Move all of them into a server-side function and read the key from a secret setting, never from front-end code. Only the anon (publishable) key may appear in the browser. Then tell me to rotate the service role key in the Supabase dashboard. (This is a Lovable app using Supabase. Keep secrets in Supabase Edge Function secrets.)
After the AI makes changes, test again with two accounts. AI fixes can look right and still miss a table or route.
Sources
- Supabase docs: Understanding API keys
- OWASP Secrets Management Cheat Sheet
- CVE-2025-48757 statement by Matt Palmer (170 of 1,645 Lovable apps exposed data)
Related
- Are uploaded files in my Lovable app public? A storage bucket check
- Lovable: Supabase RLS turned off
- Lovable: Open database tables
- Lovable: API keys in front-end code
- Lovable: Missing auth on endpoints
- Lovable: Missing security headers
- Lovable: One customer can see another’s data
Same issue in other builders:
All Lovable security guides · Exposed anon or service role key explained
Get a free scan
PeekLok checks your live app for secret keys in the page code, a Supabase service or anon key showing, Supabase tables anyone can read with the public key, and five browser security headers. If your app uses Supabase login, you can add two test logins and it checks whether one user can see the other’s data. Only scan apps you own. First scan free. Weekly re-checks will be $12 US a month once payments open.
