RLS is enabled but your Supabase data is still public: how to audit your policies

By AI App Medic · Updated · Supabase · Security · RLS

Many AI builders show a security indicator that turns green once Row Level Security is enabled. That check alone does not tell you whether the policies protect anything. A table with RLS on and a policy of using (true) is exactly as open as a table with RLS off.

Why this matters

Your Supabase URL and anon/publishable key are embedded in your JavaScript. Anyone can copy them from DevTools and call your database API directly, skipping your UI entirely. Whatever your policies allow for anon and authenticated is what any visitor (or any free account) can do.

Query 1: tables without RLS

Run this in the Supabase SQL Editor. Every table it returns is fully accessible to the API roles that have grants on it:

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

Query 2: policies that match everyone

select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
  and (qual = 'true' or with_check = 'true');

Read each result and ask: should every visitor (anon) or every signed-in user (authenticated) be able to do this to every row? For a public blog post list, maybe yes. For profiles, orders, messages or anything with emails, almost certainly no.

Other patterns that look safe but are not

Fixing a too-broad policy

drop policy "Enable read access for all users" on public.profiles;

create policy "Users read their own profile"
  on public.profiles for select to authenticated
  using ((select auth.uid()) = id);

If some fields really must be public (for example a username on a public profile page), expose them through a separate table or a security_invoker view that only selects those columns, instead of opening the whole table.

Verify from the outside

Open a private browser window, sign out, and request https://<project>.supabase.co/rest/v1/profiles?select=* with the apikey header set to your public key. Private data must not come back. Repeat signed in as a normal user and make sure you only see your own rows.

Our free health scan automates the outside check safely: when it finds a Supabase key in your bundle it asks only for row counts, never the rows themselves, and flags tables that are readable without logging in.

If a policy change starts failing with infinite recursion detected in policy, the expression is looping rather than too open. That fix is in infinite recursion detected in policy.

FAQ

Is my Supabase anon key a secret?

No. The anon/publishable key is meant to be in your frontend. It is safe only because RLS policies decide what that key can do. If policies are missing or too broad, the key gives access to your data.

What does USING (true) mean in a policy?

It means the policy matches every row for the roles it applies to. On a SELECT policy for anon or authenticated, every visitor or every signed-in user can read every row.

How can I check from the outside whether a table is readable?

Call the table's REST endpoint with only the public key while signed out. If private rows come back, the table is exposed. Our free scan does a safe version of this using row counts only.

Related guides