Edit: commenters caught several things. Check 1 shows grants, check 3 covers a second user and writes, there's a new check 4, and I removed a "most common" claim I couldn't support.
Edit 2: check 1 now shows each privilege separately, and there's a new check 5.
It's easy to ship a Supabase table that anyone can read. These are the checks I run. None of them needs an extra scanner.
1. Tables with row-level security off
select tablename,
has_table_privilege('anon', t, 'select') as can_read,
has_table_privilege('anon', t, 'insert') as can_insert,
has_table_privilege('anon', t, 'update') as can_update,
has_table_privilege('anon', t, 'delete') as can_delete
from (select tablename, format('%I.%I', schemaname, tablename) as t
from pg_tables where schemaname = 'public' and not rowsecurity) x;
Any true is open to a signed-out visitor. On my local Supabase, new tables in public got these grants by default; the query shows what yours has. (The anon key is meant to be public. The missing protection is the problem.)
2. Policies that say true, and who they apply to
select tablename, policyname, roles, cmd, qual, with_check
from pg_policies where schemaname = 'public';
Postgres never reads a policy's name. A policy called "authenticated users can read" with no to authenticated shows {public}, which includes anon. A "service role" policy with no to is the same, and you can just delete it: the service role skips RLS. Adding and roles = '{public}' lists the policies that name no role, but look at ones written to anon too.
3. Test what actually happens
As a signed-out visitor:
begin;
set local role anon;
select count(*) from public.your_table;
rollback;
As a signed-in user (without the claims, auth.uid() is null and everything looks locked):
begin;
set local role authenticated;
select set_config('request.jwt.claims', '{"sub":"A-USER-UUID","role":"authenticated"}', true);
select count(*) from public.your_table;
rollback;
Writes have their own policies. Try an insert with otherwise valid values, and update and delete against someone else's rows, inside the same kind of transaction. A blocked update or delete just affects 0 rows. A count of 0 only means something if the table has rows.
4. Things that go around table RLS
Views run with their owner's rights unless you set security_invoker, and materialized views can't:
select c.relname, case c.relkind when 'm' then 'materialized view' else 'view' end
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('v', 'm')
and coalesce(c.reloptions::text, '') not like '%security_invoker=true%';
security definer functions that anon can call through /rest/v1/rpc:
select p.oid::regprocedure
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef
and has_function_privilege('anon', p.oid, 'execute');
To close one, revoke from public as well: revoke execute on function ... from public, anon, authenticated; then grant back only what should call it.
Storage: look at select * from pg_policies where schemaname = 'storage';, and note that public buckets serve files by URL whatever those policies say:
select id from storage.buckets where public;
5. Policies that trust what users can edit
Users can change their own user_metadata, so never decide roles from it. And an update policy that only checks row ownership lets a user change any column of their row, such as role. Limit the columns:
revoke update on public.profiles from authenticated;
grant update (name) on public.profiles to authenticated;
Not covered: your app code, backend routes that use the service role (they need their own checks), and anything changed in the dashboard but not in your migrations.
Disclosure: I'm building a free, open-source tool called Svetra that automates much of this (npx svetra check --migrations builds your migrations in a throwaway Docker database and lists what's open). It's early and I'm looking for people to try it. You don't need it for any of the above.