RLS Disabled in Public

Supabase is telling you that a table in the public schema has Row Level Security switched off. That schema is served over a REST endpoint, and the key that reaches it is in your frontend bundle. So the honest reading of this warning is: this table is currently open to the internet.

The warning is advisor lint 0013. It is accurate and it is worth acting on the same day.

What is actually exposed

People assume this means someone could read the table. It usually means more than that. When Supabase creates a table through the dashboard it grants the anon and authenticated roles the full set of privileges, and Row Level Security is the only thing that then narrows what those roles can reach. With it off, there is nothing narrowing anything.

Check what the anonymous role can do on your own project:

select table_name, string_agg(privilege_type, ', ' order by privilege_type) as can
from information_schema.role_table_grants
where grantee = 'anon' and table_schema = 'public'
group by table_name
order by table_name;

If a table without Row Level Security shows DELETE in that list, an unauthenticated request can empty it.

List every affected table, not just the one in the warning

The advisor shows them one at a time. Get the whole picture in one query:

select tablename, rowsecurity as rls_enabled
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;

Everything with rls_enabled = false is in the same state as the table Supabase warned you about.

Worth doing next, because it catches the subtler case: a table can have Row Level Security enabled and still be open, if the policy attached to it passes for everyone.

select tablename, policyname, roles, qual as using_clause, with_check
from pg_policies
where schemaname = 'public'
order by tablename;

A using_clause of true granted to anon or public is a shield with nothing behind it.

Turn it on, and expect your app to break

This is the part that makes people undo the fix, so it is worth saying plainly. Enabling Row Level Security denies everything until a policy allows it. Between those two moments, queries return empty arrays and inserts fail. That is the protection working, not a new bug.

alter table public.invoices enable row level security;
alter table public.invoices force row level security;   -- applies to the table owner too

Then allow the access you actually intend:

revoke all on public.invoices from anon;
grant select, insert, update, delete on public.invoices to authenticated;

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

The (select auth.uid()) wrapping is not cosmetic. It lets Postgres evaluate the call once for the whole statement instead of once per row, which is the difference between a policy that scales and one that turns every query into a table scan. Index the column the policy compares against, too:

create index if not exists invoices_user_id_idx on public.invoices (user_id);

If the table really is public data

Reference data that everyone should read is a legitimate case. Say so explicitly rather than by omission, and keep writes closed:

alter table public.countries enable row level security;
revoke all on public.countries from anon;
grant select on public.countries to anon, authenticated;

create policy "public read" on public.countries
  for select to anon, authenticated using ( true );

The difference between this and an unprotected table is that this one is a decision you can point at in a migration.

Find out whether anyone used the gap

Enabling the policy stops what happens next. It says nothing about what already happened. In the Supabase dashboard, open Logs and filter to the window between when the table was created and now. What you are looking for is bulk reads of a table an ordinary user of your app would never query directly, requests from addresses with no matching sign-in, and deletes you cannot account for.

If a service key was also exposed, rotate it before anything else. Deleting the line does not help: the old value stays in your git history.

The mistake to avoid while fixing this

Do not test in the SQL editor and conclude you are safe. The editor runs as a privileged role and bypasses Row Level Security entirely, so a query that returns rows there tells you nothing about what a visitor can reach. Test with an ordinary client using your anon key, and then test again as a second signed-in user to confirm they cannot see the first one's rows.

Related


Check your own project

One command. No install, no signup, and it never touches the network. It reads your repository and tells you which tables are reachable and which keys are exposed, with the fix beside each finding.

npx github:humora2504/vibeproof .

Free and MIT licensed. If you want the policies generated for your own schema, and a script that proves an anonymous visitor is refused, there is a $19 Fix Pack. The scanner stays free either way.