Supabase RLS: USING vs WITH CHECK on UPDATE
USING picks the rows a user can touch. WITH CHECK limits what the row can become. How a loose UPDATE policy lets a user change user_id, and the SQL to fix it.
In a Supabase RLS policy, USING decides which existing rows a user can see or change. WITH CHECK decides what the row is allowed to look like after an INSERT or UPDATE. If your UPDATE policy lets a user write any value into user_id, that user can hand a row to someone else.
What are USING and WITH CHECK?
Both are conditions you write in create policy. They look at different versions of a row.
The PostgreSQL docs put it this way: existing rows are checked against USING, while new rows created by INSERT or UPDATE are checked against WITH CHECK. Supabase says the same in plainer words: USING decides which existing rows can be updated, and WITH CHECK decides what the resulting row is allowed to look like.
An UPDATE has both a before and an after. USING guards the before. WITH CHECK guards the after. INSERT has no before, so an INSERT policy only takes WITH CHECK.
There is one more rule to know. If an UPDATE policy has only USING, Postgres uses that same expression for WITH CHECK. So using (auth.uid() = user_id) alone does stop a user from moving a row to another owner. The new row must still pass the same test.
Why does a missing or loose WITH CHECK matter?
The gap opens in a few specific shapes. Here is what each one allows.
WITH CHECK (true). The user can only pick rows that USING lets through, but the new values are not tested at all. A user who owns a row can set user_id to any other user's id. The row leaves their account and lands in someone else's.
USING (true) on UPDATE. Every row is visible to the update, and with no WITH CHECK the same true is reused for the new row. Any signed-in user can edit any row, including the owner column.
An INSERT policy with WITH CHECK (true). Any signed-in user can insert a row with someone else's user_id. That can plant data in another person's account.
A USING test on a different column. For example, a policy that checks team membership but never looks at user_id. The user can change the owner and still pass.
Another thing can hide the problem. Permissive policies for the same command are combined with OR, per the PostgreSQL docs. One strict policy does not help if a loose one sits next to it. Old policies from an earlier prompt or template often stay behind.
Also, Supabase notes that an UPDATE needs a matching SELECT policy. A missing SELECT policy makes updates fail. It does not fix a loose WITH CHECK.
How can you check this without code?
You do not need to write code to look. You need to read what your policies say.
- Open your project in the Supabase dashboard and go to the policies page for each table that has an owner column such as
user_id,owner_idorauthor_id. - For every UPDATE policy (or ALL policy), find the "using" and "with check" boxes. Ask yourself: if I change the owner column to someone else, does any box stop me?
- Flag any policy whose expression is just
true. - Flag any UPDATE or ALL policy that mentions the owner in USING but has a different, empty or
trueWITH CHECK. - Flag any INSERT policy that does not compare the owner column to the signed-in user.
- Look for two policies on one command. The looser one wins.
Then test with two accounts. Sign in as user A and open a row you own. Try to save it with a different owner id, copied from user B. If the app or the API accepts it, the policy allows it. Do this on a copy of your data, not on live customer rows.
Also check that RLS is on. Supabase says a table in an exposed schema without RLS is readable and writable by any role with a grant on it.
For developers: the SQL
List every policy and read its two expressions. In the PostgreSQL pg_policies view, qual is the USING expression and with_check is the WITH CHECK expression.
select tablename, policyname, cmd, roles, permissive, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename, cmd;Look for rows where qual or with_check is true, or where cmd is UPDATE or ALL and with_check is empty while qual does not test the owner column. An empty with_check means Postgres reuses qual.
Replace a loose UPDATE policy with one that tests both the old row and the new row. This example uses a table called todos. Swap in your own table and policy names.
drop policy if exists "Users update own todos" on public.todos;
create policy "Users update own todos"
on public.todos
for update
to authenticated
using ((select auth.uid()) = user_id)
with check ((select auth.uid()) = user_id);Fix the INSERT side too:
drop policy if exists "Users insert own todos" on public.todos;
create policy "Users insert own todos"
on public.todos
for insert
to authenticated
with check ((select auth.uid()) = user_id);Wrapping the call as (select auth.uid()) makes Postgres run it once as an initPlan rather than per row. It does not change the logic.
Drop any other policy on the same table and command that is looser than these. If a user should be able to edit a row but never change its owner, keep the check on user_id as above.
Finally, rerun the pg_policies query and repeat the two-account test. Reading the policy text shows what is allowed. The test shows what the API does.
Sources
- PostgreSQL documentation, CREATE POLICY: https://www.postgresql.org/docs/current/sql-createpolicy.html (read 2026-11-28)
- Supabase documentation, Row Level Security: https://supabase.com/docs/guides/database/postgres/row-level-security (read 2026-11-28)
- PostgreSQL documentation, pg_policies view: https://www.postgresql.org/docs/current/view-pg-policies.html (read 2026-11-28)
If you want a second look at your project, ShipSafe can scan it: ship-safe.co/scan.
Questions and answers
- What happens if I leave WITH CHECK out of an UPDATE policy?
- Postgres reuses your USING expression as the WITH CHECK expression. So `using (auth.uid() = user_id)` with no WITH CHECK still tests the new row against the same condition. The risk comes when USING is `true`, tests a different column, or when you write `with check (true)`. Read the `with_check` column in `pg_policies` to see what is set.
- Can a signed-in user change user_id on their own row?
- Only if the policy allows the new value. If WITH CHECK is `true`, or USING and WITH CHECK never compare `user_id` to `auth.uid()`, the update goes through. If both compare it, the new row fails the check and Postgres raises an error. Test it with two accounts on a copy of your data.
- Do I need a SELECT policy for UPDATE to work?
- Yes. Supabase says an UPDATE needs a corresponding SELECT policy. Postgres says the user needs access to the row through a SELECT or ALL policy as well as an UPDATE or ALL policy. A SELECT policy lets the update find the row. It does not limit what the row becomes. WITH CHECK does that.
- Does an INSERT policy use USING?
- No. An INSERT policy takes only WITH CHECK, because there is no existing row to look at. If the policy is `with check (true)`, a signed-in user can insert a row that names another user as the owner. Compare the owner column to `(select auth.uid())` in WITH CHECK.
- Do these policies apply to the service key?
- Supabase says a secret key bypasses RLS only when the request carries no user access token. Server code that uses that key is not limited by your policies, so check owner values in that code yourself. This post covers requests made as a signed-in user.
You just read what AI builders ship. Now check yours.
Paste your GitHub URL. 2 minutes. You get the findings in plain English, and the report says what it could not check. Free, no card.
Scan My App Free