Home › Security notes › Row-level security turned off on a Supabase table

Weekly security note

Row-level security turned off on a Supabase table

By Warditor · Published

What it is

Supabase gives every project a public anon key that ships in your frontend code. It is meant to be public. What protects your data is row-level security (RLS): rules on each table that decide who can read or change which rows.

If RLS is turned off on a table in an exposed schema, the anon key alone is enough to query it.

Why it's risky

Anyone who opens your site can find the anon key in the browser's network tab or JavaScript bundle. With RLS off, they can use it to read every row in that table, and depending on your grants, insert, update or delete rows too.

If the table holds user emails, profiles, orders or messages, that data is effectively public.

How to check

  1. Open your Supabase dashboard and go to Table Editor. Tables without RLS show an "RLS disabled" or "Unrestricted" label.
  2. Or run the SQL below in the SQL Editor to list tables in the public schema with RLS off.
  3. Check Advisors (Security) in the dashboard, which flags tables with RLS disabled.

Example

-- Example: list public tables with RLS off
select tablename from pg_tables
where schemaname = 'public' and rowsecurity = false;

Or run a free scan. It checks your app's public surface for this and other common exposures.

How to fix it

  1. Turn on RLS for every table in exposed schemas.

    Example

    alter table public.profiles enable row level security;
  2. Add a policy for each thing users should be allowed to do. Without policies, RLS blocks all access through the anon key.

    Example

    create policy "Users read own profile"
    on public.profiles for select
    to authenticated
    using ( (select auth.uid()) = id );
  3. Add separate policies for insert, update and delete only where your app needs them.
  4. Test as a signed-out user and as a second account to confirm you can't see other people's rows.

After you fix it

The anon key itself doesn't need rotating, because it was always public. If you ever shipped the service_role key to the frontend, rotate it now.

Re-run a scan to confirm the table is no longer readable without login.

To catch it if this comes back, Warditor Monitor re-scans your app every 6 days for $19/month.

FAQ

Is the Supabase anon key a secret?

No. It's designed to be public and ships in your frontend. Your data is protected by RLS policies, not by hiding the anon key.

I turned on RLS and now my app shows no data. Why?

RLS with no policies denies everything. Add policies that allow the specific reads and writes your app needs.

Do I need RLS on tables my app never reads from the frontend?

Yes, if they're in an exposed schema like public. The anon key can query any table there, whether or not your app uses it.

Can Warditor see my data?

No. The scan only makes a minimal, read-only check to see whether a table answers without login. It doesn't keep any rows.

Scan your app free

Look-only check of what any visitor can already see. No login, no changes to your app.

Scan your app free

Need help fixing it? See Fix Pack, Monitor and Shield.

More security notes

This page describes a generic mistake pattern. It is not about any specific app, site or person.