DEV Community

Supabase says your table is publicly accessible (RLS disabled): what to do, in order

Supabase warns you when a table in the public schema has Row Level Security (RLS) turned off. You may see it as a Security Advisor warning in the dashboard (the lint is called rls_disabled_in_public) or as an email about a publicly accessible table.

If you got one, treat it as real. Here is what to do, in order.

What the warning means

With RLS off, any request that carries your project's anon key can read, and often write, that table through the API. The anon key is in your app's JavaScript, so anyone can get it. The table is open to the internet.

Step 1: Turn RLS on

In the SQL editor:

alter table public.your_table enable row level security;

With RLS on and no policies, nobody except the service role can access the table. Your app will stop reading it until you add policies. That is the safe default.

Step 2: Add the narrowest policy that works

For data that belongs to a user:

create policy "owner can read" on public.your_table for select using (auth.uid() = user_id);
create policy "owner can insert" on public.your_table for insert with check (auth.uid() = user_id);

Add update and delete policies the same way. Avoid using (true) on anything private.

Step 3: Check what was exposed

Open your API logs and check whether the table was read by unknown clients. If it held personal data, tell your own legal or privacy contact. The duties depend on where your users are.

Step 4: Test it from outside

Signed out, request the table with only the anon key and confirm you get no private rows. Then test with two accounts: user B must not see user A's rows.

Step 5: Look for the rest

The warning names one table. Check all of them:

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

Also check storage bucket policies and any service_role key in your front-end code.

Free count-only checker for a project you own: https://proofforge.live/tools/supabase-rls-checker .

Fix guide: https://proofforge.live/fix/supabase-rls-disabled .

Policy error you may hit next: https://proofforge.live/errors/new-row-violates-row-level-security-policy

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.