Skip to content
ScanAnt

Supabase "RLS disabled in public" warning: how to fix it

Short answer

The warning means a table in the public schema has Row Level Security turned off, so anyone holding your anon key, which is in your front-end code, can read it and often change it. Run alter table ... enable row level security on every table, then add policies for the access your app really needs. Without a policy, the table is closed to the API, which is the safe default.

Why you got this

Supabase exposes every table in the public schema through an automatic REST API. The only thing standing between the internet and your rows is Row Level Security. The anon key is meant to be public, so with RLS off it is effectively a read and write key for the table.

AI builders often create tables and a working screen, but skip policies because the demo works without them. The same applies to tables created in the SQL editor or through migrations. The Supabase advisor flags this as a security issue because it is one of the most common causes of leaked data in apps built this way.

What to do now

  1. List tables with RLS off by running the query below in the SQL editor, or open the Security Advisor in the dashboard.

  2. For each table that holds user data, run enable row level security straight away. Do this first and fix your app second; a broken screen is better than public data.

  3. Add the policies your app needs (see below) and test the app as a normal signed-in user.

  4. Check the logs and your data for rows you did not create, and if the table held personal data, note the period it was open.

How to fix it properly

Find tables where RLS is off.

sql
select schemaname, tablename, rowsecurity
from pg_tables
where schemaname = 'public' and rowsecurity = false;

Enable RLS, then allow each signed-in user to reach only their own rows. This assumes the table has a user_id column that references auth.users.

sql
alter table public.notes enable row level security;

create policy "own rows: read" on public.notes
  for select to authenticated
  using ((select auth.uid()) = user_id);

create policy "own rows: write" on public.notes
  for all to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

Avoid policies like using (true), which look like rules but let everyone in, and never let users update a column that holds their own role or plan. For content that really is public, write a select policy for that purpose only. Your server-side service_role key bypasses RLS, so keep it out of the browser.

How to check it is fixed

In the SQL editor, switch the role to anon and run a select on the table; it should return zero rows or an error. Then test as an authenticated user and confirm that user A cannot read user B's row.

The free ScanAnt scan finds your Supabase project URL and anon key in your public JavaScript and flags a service_role key if one is there. The verified scan, for sites you have proved you own, makes one small read request per table the API lists and saves table names, column names and counts only, never values. It does not read your SQL; upload your migrations in the code scan if you want policies reviewed.

Questions

Is the anon key a secret?

No. It is designed to be in your front-end code. Security depends on RLS, which is why a table with RLS off is dangerous.

I enabled RLS and my app shows no data. Why?

With RLS on and no policy, the API returns nothing. Add a policy for the access you need, for example a select policy for the owner.

Do views and functions need RLS too?

Views run with their owner's rights by default, which can bypass RLS on the underlying tables. Check the Supabase docs for security-invoker views and review functions that return table data.

Does RLS protect Storage?

Storage has its own policies on the storage.objects table. Review them separately from your table policies.

Does the service_role key obey RLS?

No, it bypasses it entirely, which is why it must never reach the browser.

Check your site after the fix

The quick scan is free for any public site and needs no signup. Checks that touch your database or files run only after you prove you own the site.

Choose a scan level →