Guide · Supabase
How to check your Supabase RLS before launch
If your app was built with Lovable, Bolt or another AI builder on Supabase, your database key is in your website's JavaScript. That is normal. It also means Row Level Security is the only thing deciding what a stranger can read. Here is how to check it in about ten minutes.
Why the key being public is fine, and RLS is not optional
Supabase gives your app a public key (the anon or sb_publishable_ key). Anyone who opens your site can copy it from the browser and call your database directly, without your app's screens in the way. What they get back is decided by RLS policies on each table.
A table with RLS turned off is readable and writable by anyone holding that key. A table with RLS on but a policy that says true is the same thing with extra steps.
The other key, service_role (or sb_secret_), skips RLS completely. It must never appear in your frontend. If it does, stop reading and rotate it now.
1. Is RLS turned on for every table?
In the Supabase dashboard, open Advisors → Security Advisor. A warning that RLS is disabled on a table in public is the most serious thing it can tell you. The Table Editor also labels these tables "Unrestricted".
Or ask the database directly in the SQL editor:
select tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;
Every row should say true. For each false, turn it on:
alter table public.your_table enable row level security;
With RLS on and no policies, nobody can read the table through the API. That is the safe default. Then add back only what the app needs.
2. Do the policies actually check who is asking?
List every policy:
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename;
Look closely at any row where qual or with_check is just true. That policy lets everyone in its roles through. It is fine for data that really is public, like a list of products. It is not fine for profiles, messages, orders or anything with an email address in it.
A policy that limits people to their own rows looks like this:
create policy "Own rows only" on public.profiles
for select to authenticated
using ((select auth.uid()) = user_id);
Check the insert and update policies too. A common mistake is a careful select policy next to an update policy that lets any signed-in user change anyone's row, including fields like is_admin or plan.
3. Can anyone sign up and become "authenticated"?
Many policies say to authenticated, which feels safe. But if sign-up is open and email confirmation is off, anyone can create an account in seconds with a made-up address, and "signed-in users only" becomes "everyone".
In Authentication → Sign In / Providers, check whether email confirmation is on. If your policies rely on authenticated alone, it should be, and the policies should still check ownership as in step 2.
4. Views and functions can skip RLS
A view in public runs with its owner's rights by default, so it can return rows that the table's RLS would hide. On Postgres 15 and later, make views respect the caller's RLS:
alter view public.your_view set (security_invoker = true);
Functions marked security definer also run with their owner's rights and can be called through the API. Find them:
select p.proname
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef;
Each one should check auth.uid() itself, move out of the public schema, or stop being callable from the API:
revoke execute on function public.your_function from anon, authenticated;
5. Storage buckets
A public bucket serves every file to anyone who has the link. That suits logos and product photos, not ID documents, invoices or private uploads. Open Storage, check which buckets are public, and make private any bucket holding things people uploaded about themselves. For every bucket, public or private, policies on storage.objects decide who can list, upload, overwrite and delete files (and, for private buckets, download them), so read them with the same eye as step 2.
Check from the outside too
The steps above show what you configured. Greenlit shows what a stranger actually gets. Check your app on the Greenlit home page and choose "Check my database here" (you add one tag to prove the app is yours), or run npx greenlitlab yourapp.com --mine on your own computer. Either way it uses only your public key, the same one any visitor has, and reports which tables anyone can read and which storage buckets list their files. It asks for row counts and at most one file name, never contents, and it tests reading, not writing.
See what a stranger sees
Paste your app's address. You get a grade from A to F, every problem in plain words, and a prompt to paste into your builder to fix each one. Free, no sign-up.
Check your appMore guides