Test your app's database locks: the Supabase public key checklist
The short version
Researchers at Crissy Field checked 159,041 apps built with Lovable (a Common Crawl sample from December 2025 to September 2026, not representative of all Lovable apps). One service provider exposed more than 1,000 records with passport numbers, expiry dates and nationalities. A forum exposed more than 200,000 chat messages. No login was needed, and they could not establish whether any of it was misused.
The key every visitor gets is meant to be public. Supabase's docs say it like this: the publishable key is taped to the front door, and it only opens the lobby. The locks on each table (Row Level Security) decide what else it opens. A table in an exposed schema without them is readable by anyone with the key. Lovable's terms put responsibility for the app and its data on you, so test your locks before real data goes in.
| What you see | What it means | What to do |
|---|---|---|
Logged-out request returns [] or a permission error |
The lock holds for that table | Keep it, re-test after changes |
| Logged-out request returns rows | The table is open to anyone | Turn on Row Level Security and add a policy now |
| Your browser code holds the secret / service_role key | That key skips every lock | Remove it from the client and rotate it |
| A new table or column added this week | New tables start without locks | Re-run the test |
Copy these prompts
Paste them into Claude Code (or any assistant that can see your project).
1. List the tables and their locks
List every table in my Supabase project's exposed schema (public). For each one, tell me whether Row Level Security is enabled and which policies exist for select, insert, update and delete. Flag every table where RLS is off.
2. Write the policies
For my table <table_name> with a user_id column, write the Row Level Security statements: enable RLS, then one policy per operation so a signed-in user can only read and change their own rows. Do not allow anonymous access unless I say so.
3. Check what the browser is holding
Search my app's front-end code and environment files for the Supabase service_role / secret key. It must never be in code shipped to a browser or phone. Tell me where it appears and how to move it to a server-only function.
The test
Run it logged out, with only the public key, once per table. Replace the placeholders with your own project values:
curl -s "https://<project-ref>.supabase.co/rest/v1/<table_name>?select=*&limit=1" \
-H "apikey: <your publishable key>" \
-H "Authorization: Bearer <your publishable key>"
How to read it: [] or a permission error means the lock holds. A row means that table is open to the world.
The fix, per table
alter table public.<table_name> enable row level security;
create policy "own rows" on public.<table_name>
for select to authenticated
using ((select auth.uid()) = user_id);
Add a similar policy for each operation you need. If the table should not be reachable by the public key at all, also revoke its default access:
revoke all on table public.<table_name> from anon;
If you are building
- Turn Row Level Security on for every table in an exposed schema, as you create it.
- Use the public key in the browser and the secret key only on a server.
- Re-run the test after every schema change and before real user data goes in.
- Keep a short list of what each table is allowed to show to a logged-out visitor. For most tables the answer is nothing.
Run this on your codebase
Audit this project's Supabase setup: list every table in the public schema with its RLS status and policies, find any use of the service_role key in client code, and give me the exact curl commands to test each table logged out with the public key.