12 security holes I check in every Lovable and Supabase app
AI coding tools are good at making an app that works when you click through it. They are much worse at making an app that stays safe when a stranger opens the browser dev tools. The gap is almost always in the same places, so here is the list I go through before an AI-built app on Supabase takes real users or real money.
Run these against your own app only.
First, the five-minute stranger test
Your Supabase URL and anon key are in the browser for anyone to see. That is by design: the anon key is meant to be public, and Row Level Security is what stops it from reading everything. So test what a stranger can do with it.
Open your app, open dev tools, go to the Network tab and find a request to your-project.supabase.co. Copy the apikey header. Then, from a terminal:
curl 'https://YOUR-PROJECT.supabase.co/rest/v1/profiles?select=*' \
-H "apikey: YOUR_ANON_KEY" \
-H "Authorization: Bearer YOUR_ANON_KEY"
Swap profiles for each of your tables. If you get rows back without logging in, a stranger gets them too. Most of the list below is about why that happens.
The checklist
1. A table with RLS turned off. One forgotten table is enough. Check them all at once in the SQL editor:
select tablename, rowsecurity
from pg_tables
where schemaname = 'public';
Anything showing false is readable and writable by anyone holding the anon key.
2. A policy that checks login, not ownership. This one passes a quick test, which is why it survives. using (auth.role() = 'authenticated') means any signed-up user can read every row. You almost always want using (auth.uid() = user_id). Sign up as a second user and try to load the first user's data.
3. The service role key in the frontend. The service role key skips RLS entirely. If it sits in a VITE_ or NEXT_PUBLIC_ variable, it ships to every browser. Search your built files for service_role, and if you find it, rotate the key today.
4. Other secret keys shipped to the browser. Same problem with OpenAI, Anthropic or Stripe secret keys. Search the build output for sk- and sk_live_. Those calls belong in an edge function or a server route, never in client code. A leaked model key can empty your API balance overnight.
5. Insert and update policies without with check. A using clause controls which rows you can touch. with check controls what the row is allowed to look like afterwards. Without it, a user can update their own row and set user_id to someone else's.
6. Users can edit their own role or plan. If profiles has columns like role, is_admin or plan, and users can update their own profile row, they can make themselves an admin or a paid user with one request. Move those columns to a table users cannot write to.
7. Admin pages protected only in the frontend. Hiding the /admin route in React does nothing for the data behind it. If the admin tables are readable through the API, the route guard is decoration. The check has to live in RLS.
8. Storage buckets that are public or have no policies. Uploaded IDs, invoices and private photos end up in a public bucket more often than you would think. Check each bucket's visibility and its policies, and try listing files as a logged-out user.
9. Views that skip RLS. In Postgres, a view runs with its owner's rights by default, so it can return rows the underlying table's policies would block. On Postgres 15 and later, create views with with (security_invoker = true).
10. security definer functions anyone can call. Functions in the public schema are callable through the API as RPCs. A security definer function runs with elevated rights, so it needs its own checks on who is calling it.
11. Paid status set by the browser. If your app marks a user as paid when they land on the success page, anyone can visit that page. The paid flag should only change from a Stripe webhook, and the webhook should verify Stripe's signature before it trusts the event.
12. Loose auth settings. Email confirmation turned off, open sign-ups on an app that should be invite-only, or wildcard redirect URLs. Check these in Authentication settings before launch, not after the first fake accounts arrive.
What to do with the results
If the stranger test returns rows, fix that before anything else. Points 1 to 4 are the urgent ones because they leak data or money right now. The rest are worth a calm afternoon before launch.
Most of these fixes are small. The hard part is knowing which of the 12 apply to your app, because the AI that wrote the code will usually tell you everything looks fine.