Short answer
A policy with using (true) lets every role it applies to read or change every row, and with check (true) lets them write any row, including rows that claim to belong to someone else. RLS is switched on, the dashboard looks fine, and the data is still open. Find these policies in pg_policies, keep only the ones on truly public data, and replace the rest with a check against (select auth.uid()).
Ask an AI about this page:ChatGPTClaude
On this page
A policy of using (true) says “every row passes”, and with check (true) says “any new row is fine”. Row level security is on, the table shows a policy in the dashboard, and the data is still open to everyone the policy applies to. It is rated critical on per-user data because a single request with your public key returns every row, and the insert version lets a user write rows in someone else’s name.
Why it matters
These policies often come with friendly names, so they pass a quick look. Here is a typical example on a table of invoices:
create table public.invoices (
id uuid primary key default gen_random_uuid(),
user_id uuid not null references auth.users (id) on delete cascade,
customer_name text not null,
amount_cents integer not null,
created_at timestamptz not null default now()
);
alter table public.invoices enable row level security;
create policy "Enable read access for all users"
on public.invoices for select
using (true);
create policy "Enable insert for authenticated users only"
on public.invoices for insert
to authenticated
with check (true);The select policy has no to clause, so it applies to every role, including anon, the role of signed-out visitors. Anyone can download all invoices of all customers. The insert policy only checks that someone is signed in; it never checks that user_id is theirs, so a user can plant rows in another account.
Two look-alikes do the same damage for signed-in users: using (auth.uid() is not null) and using (auth.role() = 'authenticated'). Both mean “any account”, and on many apps anyone can create one. Our audit engine found both shapes in our test apps: a workspace app whose project policies only required auth.uid() is not null, so every user could read and rename other teams’ projects, and a shop whose order insert policy was with check (true). Adding a strict second policy does not help: PostgreSQL combines permissive policies with OR, so the open one wins.
How to find it in your app
The Security Advisor in the Supabase dashboard flags always-true policies as lint 0024 (permissive_rls_policy). To see all of them at once, including the “any signed-in user” variants, run this in the SQL Editor:
select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
and (
qual = 'true' or with_check = 'true'
or concat(qual, ' ', with_check) ~* 'auth\.uid\(\)( as uid\))? is not null|auth\.role\(\)'
)
order by tablename, policyname;For each row, ask one question: may every visitor (roles {public} or {anon}) or every signed-in user ({authenticated}) see or write every row of this table? If the answer is no, the policy has to change.
How to fix it
Replace each open policy with one that ties the row to the caller, in a new migration. For the invoices table:
drop policy "Enable read access for all users" on public.invoices;
drop policy "Enable insert for authenticated users only" on public.invoices;
revoke all on table public.invoices from anon;
create policy "Owners can read their invoices"
on public.invoices for select
to authenticated
using ((select auth.uid()) = user_id);
create policy "Owners can add their own invoices"
on public.invoices for insert
to authenticated
with check ((select auth.uid()) = user_id);If rows belong to a team rather than one person, the check becomes a membership lookup; the multi-tenant data isolation guide shows the pattern. Policies for update and delete need the same owner check, which the missing ownership check fix covers.
For data that really is public, true is fine, as long as the policy only reads and names its roles:
create policy "Anyone can read the product catalogue"
on public.products for select
to anon, authenticated
using (true);With no insert, update or delete policy, nobody can change the catalogue through the API; your server writes it with the secret key.
In the Supabase migrations, find every policy on a table in the public schema whose USING or WITH CHECK expression is true, auth.uid() is not null or auth.role() = ‘authenticated’. Leave select-only policies on tables that are meant to be public (list them and tell me why you kept each one). For every other table, add a new migration that drops the open policy and creates a replacement for the authenticated role only that allows the row only when (select auth.uid()) = user_id (or the table’s owner column). Insert and update policies need WITH CHECK with the same condition.
Do not edit existing migrations, do not disable RLS and do not widen any grant. Show me the migration before applying it.
Check that the fix works
Act as a second user inside a transaction and try both leaks, reading and planting:
begin;
set local role authenticated;
set local request.jwt.claims = '{"sub": "22222222-2222-2222-2222-222222222222", "role": "authenticated"}';
select count(*) as visible from public.invoices;
insert into public.invoices (user_id, customer_name, amount_cents)
values ('11111111-1111-1111-1111-111111111111', 'Planted', 100);
rollback;Use two real user IDs from Authentication → Users: the second user’s ID in the first line, the first user’s ID in the insert. The count must equal the second user’s own invoices, and the insert must fail with new row violates row-level security policy for table "invoices". Then run the query from “How to find it” again: only the policies you kept on purpose may remain. The Supabase RLS guide has more checks to run before launch.
Frequently asked questions
Is using (true) ever correct?
Yes, for a select policy on data that everyone may see, such as a public product catalogue or published blog posts. It is wrong on any table that holds per-user or per-team data, and it is almost never right on insert, update or delete.
Is auth.uid() is not null safer than true?
Only against signed-out visitors. For every signed-in user it is the same as true, and on many apps anyone can sign up. Use it only for data every user of your app may see.
Why does the Security Advisor show a warning for my policy?
Lint 0024 (permissive_rls_policy) flags policies with always-true expressions. Read the policy and decide whether the table is really public. If it is not, replace the policy as shown on this page.
I have a correct owner policy too. Does that cancel the true policy?
No. Permissive policies are combined with OR, so one policy that says true lets every row through, no matter how strict the others are.
Sources
- 1.Row Level Security — Supabase Docs
- 2.Performance and Security Advisors — Supabase Docs
- 3.Row Security Policies — PostgreSQL Documentation
- 4.CREATE POLICY — PostgreSQL Documentation
- 5.CWE-863: Incorrect Authorization — MITRE
- 6.A01 Broken Access Control — OWASP Top 10