★SB-POLICY-OVERLAP
Open policy overrides an owner-only policy
- Severity
- High
- Confidence
- High
- Stack
- Supabase
- Runs
- On by default
What the CLI looks for
A permissive open policy on the same table and operation as an owner-only policy.
Why it matters
Permissive policies are combined with OR. If one policy says “only the owner” and another one says “true”, the second one wins: the table is open, even though the owner policy looks correct on its own.
How to fix it
Drop the open policy. If it was meant to add a condition rather than grant access, declare it AS RESTRICTIVE.
-- Keep only the owner policy for this operation
drop policy if exists "Enable read access for all users" on public.comments;
-- A policy that should narrow access, not widen it:
create policy "Only published" on public.comments
as restrictive for select to authenticated
using (published);