Is my Supabase app safe? How to check Row Level Security
If your app uses Supabase, the most important security setting is Row Level Security (RLS). Your Supabase URL and anon key ship inside your website, so anyone can call your database API. RLS policies are what decide which rows each visitor can read or change.
Why this matters
The anon (or "publishable") key is meant to be public. That's safe only when RLS is enabled on your tables and the policies are correct. If a table in the exposed public schema has RLS turned off, anyone who copies the key from your site can read, edit or delete every row through Supabase's auto-generated API.
Tables created in the Supabase Table Editor have RLS enabled by default, but tables created with raw SQL (in the SQL Editor, in migrations, or by an AI tool) don't, unless the SQL turns it on.
How to check, step by step
- Open the Security Advisor. In your Supabase dashboard, go to Advisors → Security Advisor. It flags tables in the public schema with RLS disabled.
- Check each table. In Table Editor, tables without RLS show a warning label. Or run this in the SQL Editor:
Any row whereselect schemaname, tablename, rowsecurity from pg_tables where schemaname = 'public';rowsecurityisfalseneeds fixing. - Look at your policies. RLS turned on with no policies blocks everything (safe, but your app may break). A policy like
using (true)lets everyone through, which is the same as no protection for that action. - Check your migrations. Search your repo's
supabase/migrationsfolder forcreate tableand make sure each table has a matchingalter table ... enable row level security. - Make sure the service_role key is server-only. It bypasses RLS completely. It must never appear in browser code or in a
NEXT_PUBLIC_/VITE_variable.
How to fix it
alter table public.todos enable row level security;
create policy "Users can read their own todos"
on public.todos for select
to authenticated
using ( (select auth.uid()) = user_id );
create policy "Users can add their own todos"
on public.todos for insert
to authenticated
with check ( (select auth.uid()) = user_id );
Then test it: sign out and try to load the data, or call the REST API with only the anon key. You should get an empty list, not other people's rows.
public tables to the Data API automatically, so each one needs an explicit GRANT. Don't fix it by disabling RLS or bulk-granting everything. See the safe 42501 fix.Copy-paste prompt for your AI coding tool
Paste this into Cursor, Claude, Lovable, Bolt or whichever AI built your app:
Audit my Supabase project's Row Level Security. For every table in the public schema: 1) make sure RLS is enabled, 2) list the existing policies and explain in plain English who can select, insert, update and delete, 3) write a new migration that enables RLS where missing and adds policies so users can only access their own rows (use auth.uid() and my owner column), 4) make sure the service_role key is only used in server-side code. Then tell me how to test that a logged-out user gets no rows.
Check your repo in about a minute
Paste a public GitHub repo into KeySnare for a free grade and your top 3 issues, each with a copy-paste AI fix prompt.
Run a free scan →FAQ
Is the Supabase anon key a secret?
No. It is designed to be public and ships in your frontend. That is only safe when Row Level Security is enabled with correct policies on every exposed table.
Does Supabase turn on RLS by default?
Tables created in the dashboard Table Editor have RLS enabled by default. Tables created with SQL, including migrations written by AI tools, need an explicit "alter table ... enable row level security" statement.
What happens if RLS is on but there are no policies?
All access through the anon and authenticated roles is denied, so your data is safe but your app may stop showing data until you add policies.
Does the service_role key respect RLS?
No. The service_role key bypasses RLS, so it must only be used in trusted server code and never in the browser.
Can KeySnare check my Supabase dashboard settings?
No. KeySnare scans your GitHub repo, so it checks SQL migrations and code. Use Supabase's Security Advisor for live database settings.