Is your Supabase data public? A two-minute RLS check
Updated · by Zane
Why this matters for apps made with AI tools
An app built with Supabase talks to the database straight from the browser. It does that with the anon key, which newer projects call the publishable key. Anyone who opens your site can find that key in the page code. That is how it is meant to work. It is not a leak.
So the key cannot be what protects your data. Row level security does. RLS is a set of rules on each table that says who can see or change which rows. If a table has no RLS, the public key is enough to read, edit and delete the whole table. AI builders do not always switch RLS on when they create a new table. I would assume nothing and check.
The two-minute check
Only do this on your own project.
1. Look at the tables
Open the Supabase Dashboard, then Table Editor. Look next to each table name for a marker saying RLS is not enabled. Any table with user data and that marker is open.
2. Run Security Advisor
Open Supabase Dashboard, then Advisors, then Security Advisor. It lists tables without RLS and policies that are too loose. Read every line.
3. Ask for the data yourself
This is the test that settles it. In a terminal on your own computer, request a table that holds user data, using your project address and your anon key, while not logged in:
curl "https://<project-ref>.supabase.co/rest/v1/profiles?select=*" \
-H "apikey: <anon key>" \
-H "Authorization: Bearer <anon key>"If you get back rows that belong to other people, that table is public. If you get [], an empty list, the table is protected from anonymous visitors. Try each table that holds anything private.
RLS can be on and still not protect you
Two patterns make RLS close to useless. Look for them when you read your policies:
- A policy written as
using (true). That says every row is allowed. - A select policy opened to the
anonrole on a table that holds private data.
You can see policies in the Supabase Dashboard, then Authentication, then Policies.
Fix it
For each table, switch RLS on, then write policies for who may see which rows. This is what the correct shape looks like in my demo project, where each user can read only their own profile row:
alter table public.profiles enable row level security;
create policy "profiles_select_own" on public.profiles
for select to authenticated
using (auth.uid() = id);If users should read and write their own rows on another table, a policy like this does it. Swap in your own table and column names:
alter table public.notes enable row level security;
create policy "notes_own_rows" on public.notes
for all to authenticated
using (auth.uid() = user_id)
with check (auth.uid() = user_id);If some content really is public, such as published posts, give it its own read-only policy. Do not open the whole table:
create policy "posts_public_read" on public.posts
for select to anon, authenticated
using (published = true);Turning RLS on with no policy denies everything to the frontend. Parts of your app will then show no data, or their updates will change 0 rows with no error. That is expected, and the cure is adding the right policy. I explain that case in Supabase update returns no error but nothing changes. Do not fall back to using (true) to get things working.
Three places people forget
- Storage. Check whether each bucket is public, and whether it has storage policies. A public bucket serves its files to anyone with the link.
- The service role key. It is called the secret key in new projects. It skips every RLS rule. If it appears in frontend code, or in a variable starting with
VITE_, the whole database is effectively public. The Vite build copies those variables into the page, which is also why a missing one gives a blank page, as in Blank white page after publishing your AI-built app. If you ever find the key there, rotate it in the Supabase dashboard right away. - Functions and views. A database function or view can run with more power than the person calling it. Check that they do not hand back rows the caller should not see.
If you find data was exposed
- Turn RLS on first. That stops the exposure.
- Add policies so the app works again.
- Rotate any secret key that might have been visible.
- Work out what was exposed and for how long. Whether you must tell your users depends on where you and they are. I cannot give legal advice here, so ask someone who can.
Check that the fix worked
Run the same request as before. Not logged in, it should return nothing for private tables. Then log in to your app as yourself and confirm your own data still loads and saves. Both results need to be right. A locked-down table that breaks your app is not finished.
Payments carry the same kind of risk. A plan column that users can edit themselves lets anyone upgrade for free. The fix for stuck upgrades is in Stripe payment succeeded but the user is still on the Free plan.
FAQ
My anon key is visible in the browser. Have I been hacked?
No. That key is public by design. Every visitor's browser needs it to talk to your database, so it will always be visible. What matters is whether each table has row level security with sensible policies behind it.
I turned on RLS and now my app shows nothing.
That is expected. RLS with no policies denies everything to the frontend. Add a policy for who may read or write which rows. Updates that quietly change 0 rows have the same cause, and I cover them in the guide linked above.
Does Lovable's or Supabase's security scan make this unnecessary?
A scan can spot tables with RLS switched off. It cannot know whether your policies match your business rules. Running the request yourself once, from outside the app, is still worth two minutes.
Checklist
Still stuck?
Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.
Related guides
- Bolt.new Stripe webhook not working after deploying to Netlify (404 or no upgrade)
- Lovable custom domain with Cloudflare: fix "too many redirects" (ERR_TOO_MANY_REDIRECTS)
- Lovable custom domain not working: stuck pending, no SSL, or www fails
- Lovable email verification not working: signup confirmation emails not arriving
- Lovable Google sign in showing redirect_uri_mismatch or an unverified app warning
- Base44 custom domain stuck on Pending verification
- Base44 payment succeeded, but the customer was not upgraded
- Lovable Stripe checkout: "Edge Function returned a non-2xx status code"
- Lovable password reset link not working or sending users to the wrong page
- Replit custom domain not working: stuck on Verifying or showing a blank page
- Blank white page after publishing your AI-built app
- “No such price” when going live: Stripe test and live mode mixed up
- Stripe payment succeeded but the user is still on the Free plan
- Subscription cancelled in Stripe but the user still has the paid plan
- Stripe webhook signature verification failed (400): causes and fix
- Login sends users to localhost or the preview URL after publishing
- Supabase update returns no error but nothing changes