I ran a security audit on my own Supabase project last week. RLS was enabled. Three policies per table. The dashboard showed everything green.
Every table was wide open to anyone holding the publishable key.
Here's how that happens, and the 10 checks I now run before every launch.
The trap
The Supabase Table Editor shows you data as postgres — which bypasses RLS entirely. So "I can see the rows in the dashboard, and there are 3 policies" tells you exactly nothing about what the anon role sees. I only found it by querying as anon directly:
set role anon;
select count(*) from agent_performance; -- every row. all of them.
The policies were real. They were also USING (true) — which means "everyone." RLS on ≠ secured.
It got worse on the second project
Different project, 10 tables with RLS disabled outright. The main work_orders table: readable, writable, deletable by anyone with the key. And it was wearing 4 policies that did absolutely nothing — because with RLS off, Postgres ignores every policy on the table. Decorative policies. The dashboard showed them; they enforced nothing.
The 10 checks
Paste the whole thing into the SQL Editor. Every query is read-only — nothing is created, granted, or altered. Any rows = a red flag.
1. RLS enabled on every public table
select tablename from pg_tables
where schemaname = 'public' and rowsecurity = false;
2. No table with RLS on but zero policies
select tablename from pg_tables t
where schemaname = 'public' and rowsecurity = true
and not exists (select 1 from pg_policies p
where p.schemaname = 'public' and p.tablename = t.tablename);
3. No USING (true) / WITH CHECK (true) policies
select tablename, policyname, cmd from pg_policies
where schemaname = 'public'
and (qual = 'true' or with_check = 'true');
4. Every INSERT/UPDATE policy has a WITH CHECK
select tablename, policyname from pg_policies
where schemaname = 'public' and cmd in ('INSERT','UPDATE','ALL')
and with_check is null;
5. No policies on tables with RLS disabled (decorative)
select p.tablename, p.policyname from pg_policies p
join pg_tables t on t.schemaname = p.schemaname and t.tablename = p.tablename
where p.schemaname = 'public' and t.rowsecurity = false;
6. No SECURITY DEFINER functions without pinned search_path
select p.proname as function_name from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef = true
and (p.proconfig is null or not (
select bool_or(split_part(c, '=', 1) = 'search_path')
from unnest(p.proconfig) as c));
7. No SECURITY DEFINER views in public
select c.relname as view_name from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'v'
and c.reloptions::text ilike '%security_definer%';
8. anon can't reach what it shouldn't (spot-check your main tables)
-- run as anon in the SQL Editor, or curl with your anon key:
-- curl "https://<ref>.supabase.co/rest/v1/<table>?select=*" -H "apikey: <ANON_KEY>"
-- If it returns rows you expected to be private, RLS isn't doing its job.
9. Oct 30 ready: tables have Data API grants
select tablename from pg_tables t
where schemaname = 'public'
and not has_table_privilege('anon', format('public.%I', tablename), 'SELECT');
-- ^ lists tables anon can't touch at all; if your app needs one, grant it before Oct 30
10. Default privileges set for future tables
select count(*) from pg_default_acl d
join pg_namespace n on n.oid = d.defaclnamespace
where n.nspname = 'public';
-- 0 rows = every table created after today needs a manual GRANT. Set it once.
Two things I'd do differently
1. Policies first, RLS second, tighten third. The naive fix for "RLS off everywhere" is turning it on — which instantly locks out your own app, because RLS-on with zero policies means zero rows for everyone. Write the policies first, enable RLS, then narrow them.
2. Map every policy to its feature before touching it. My first instinct was dropping the anon write policies. That would have killed the CSV upload, which writes to Supabase as part of the flow. Security fixes that break the product get reverted. Document the tradeoff instead.
Oct 30
Supabase stops auto-exposing new tables to the Data API on Oct 30, 2026 — new tables without explicit grants 42501. Check 9 above tells you if you're ready. (It's a grants change, not an RLS change — your policies work exactly the same.)
If Supabase's final-notice email landed in your inbox this week, this is the change it's warning you about.
The full kit
Everything above runs free in your SQL editor — that's the whole point. Locked Down is for when you want the write-ups, the fix playbook, and the two full audits with the wrong calls included: $39:
https://tavora2.gumroad.com/l/lsoerp
Scope note: this is a review aid for projects you own or are authorized to test — not a penetration test, not a certification.
Top comments (19)
Check 7 can come back empty on a leaky project: Postgres views run with the owner's privileges by default, and there's no security_definer reloption to match. The flag that matters is security_invoker=true (Postgres 15+), so list views whose reloptions don't contain it. A postgres-owned view over an RLS table skips the policies otherwise.
Update: that's now in v1.4, live on the kit — CHECK 3 widened, CHECK 10 rewritten to views without security_invoker=true, CHECK 12 for public storage buckets, plus the second-user cross-tenant test. Thanks again for catching these.
One detail for CHECK 12: per Supabase's storage docs a public bucket only skips access control for reading files. Uploads, deletes, moves and copies still go through RLS on
storage.objects, so it's a public bucket plus a loose insert policy that's worth flagging.Good catch — you're right, a public bucket alone only opens reads. The dangerous combo is public bucket plus a loose insert policy on storage.objects, and that's the version of the check worth flagging. Noted for the next version.
Exactly — same gap Dave flagged. A plain view has no security_definer reloption to match, so the check comes back empty on a leaky project. "Views without security_invoker=true" is the right check. Thanks for the confirmation.
One caveat for older instances: security_invoker arrived in Postgres 15 (it isn't in the 14 CREATE VIEW docs), so on 14 every view runs as its owner and that check can't apply.
The check that would have saved me is number 8 done as a habit, not a one-off: I query as anon before every deploy, because the dashboard view as postgres hid exactly this gap from me once. One addition I would make is testing an authenticated user from a different tenant, not just anon, since a policy that blocks anon but leaks across tenants passes your list and still fails in production. Do you run these checks in CI, or only by hand before launch?
Update: that's now in v1.4, live on the kit — CHECK 3 widened, CHECK 10 rewritten to views without security_invoker=true, CHECK 12 for public storage buckets, plus the second-user cross-tenant test. Thanks again for catching these.
Agreed — check 8 as a habit is the real takeaway. I run these by hand before launch, not in CI — the kit is a SQL pack you paste into the editor. The cross-tenant authenticated test is the gap in my list; a policy that blocks anon but leaks across tenants would pass everything I wrote. That's going in the next version.
which tenant pair would you test first?
The pair where a leak would hurt most, with real rows on both sides. In my CRM that's two different companies with actual cases: user A in company 1 creates a case, user B in company 2 lists cases and must see zero of company 1's. Two users in the same tenant proves nothing, and an empty second tenant proves nothing either — zero rows could mean the filter worked or there's just nothing to leak. Run it through the app's real login too, not just set role, so you're testing the same JWT path the app uses.
Check 7 may miss the common case. Postgres views run with their owner's rights by default, so a plain view in public bypasses RLS on the underlying table unless it was created with security_invoker = on (Postgres 15+). The reloptions filter on security_definer only catches views that set it explicitly. Flipping it to "views where reloptions does not contain security_invoker=true" would surface the real exposures. Check 3 has a similar gap: qual = 'true' misses always-true variants like auth.uid() IS NOT NULL, which lets any self-signed-up user read every row. Did your anon test also run as a second authenticated user to catch cross-tenant reads?
Good catches, both of them. You're right that a plain view runs with the owner's rights by default, so flagging only explicit security_definer misses the common case — "views without security_invoker=true" is the better check. Same for Check 3: auth.uid() IS NOT NULL is effectively true for every signed-in user, so qual='true' alone misses it. And no — my test only ran as anon, not as a second authenticated user, so cross-tenant reads are a gap in my test, not something I verified. I'll fold all three into the next version of the checks. Thanks for reading it closely.
Update: that's now in v1.4, live on the kit — CHECK 3 widened, CHECK 10 rewritten to views without security_invoker=true, CHECK 12 for public storage buckets, plus the second-user cross-tenant test. Thanks again for catching these.
That closes the main gaps the thread surfaced. One small note for the view check: security_invoker is available from PostgreSQL 15, so it may help to call that out for projects on older versions. Otherwise readers could mistake an unavailable option for a pass. The second-user test now covers the tenant-leak case the anon check misses.
Really useful write-up, the "set role anon" test is the one most people never run. Two more checks I would add to your list: views, which skip RLS unless you set security_invoker = true, and storage buckets, which are often public by default for things like uploads. Also test with a second signed-in user, not only anon, since "authenticated can read everything" is the other common leak.
Good additions. Storage buckets are a real one I didn't cover — public-by-default upload buckets are their own leak class, separate from table RLS. And yes on the second signed-in user; three of you have now flagged the same gap, so that's clearly the first thing to add.
Thanks Jorge. For buckets, a quick check is to open a file URL in a private window while signed out. If it loads and the bucket isn't meant to be public, switch it to private and serve signed URLs instead.
You’re welcome!
Update: that's now in v1.4, live on the kit — CHECK 3 widened, CHECK 10 rewritten to views without security_invoker=true, CHECK 12 for public storage buckets, plus the second-user cross-tenant test. Thanks again for catching these.