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.
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.
We're a place where coders share, stay up-to-date and grow their careers.
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.