Supabase RLS: how to stop users updating certain columns (plan, credits, verified)
By Abbi Labs · Last updated 18 November 2026
Scan your app free — see what a signed-out stranger can read and write right now.
Abbi Labs checks your live site from the outside: Supabase tables readable with your public key, role-looking columns exposed to the anon role, secret keys in the JavaScript, exposed .env and .git files, source maps, and security headers. Read-only. No sign-up for the quick check.
No app handy?
No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.
Run on every deploy or use from Cursor / Claude Code via MCP →
Weekly AI-app security checklist
One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.
Here's a setup almost every AI-built SaaS ends up with. A profiles table with id, display_name, avatar_url, and then the business columns: plan, credits, is_verified, stripe_customer_id. RLS is on. There's a tidy policy so users can edit their own profile:
create policy "Users can update own profile"
on public.profiles for update to authenticated
using ((select auth.uid()) = id)
with check ((select auth.uid()) = id);It stops user B editing user A's profile. It does nothing about which columns A changes. Any signed-in user can open the browser console on your own site and run:
await supabase.from('profiles')
.update({ plan: 'pro', credits: 999999 })
.eq('id', (await supabase.auth.getUser()).data.user.id)The row is theirs, so the policy passes. If your app reads profiles.plan to unlock features, they just upgraded for free. With open sign-ups, "any signed-in user" is anyone with an email address. Supabase's own Column Level Security docs use this exact example: an owner update policy "gives the post owner full access to update the row, including all of the columns."
1. Find the columns users can update right now
Run this in the SQL Editor. It lists every column in public that the authenticated role is allowed to update:
select c.table_name, c.column_name,
has_column_privilege('authenticated', format('public.%I', c.table_name), c.column_name, 'UPDATE') as authenticated_can_update,
has_column_privilege('authenticated', format('public.%I', c.table_name), c.column_name, 'INSERT') as authenticated_can_insert
from information_schema.columns c
where c.table_schema = 'public'
order by 1, 2;Then look at each table that has an own-row UPDATE (or INSERT) policy and ask one question per true: should a user be able to set this to any value they like? Usual suspects: plan, tier, credits, balance, is_verified, is_banned, role / is_admin, stripe_customer_id, subscription_status, trial_ends_at, org_id, created_at.
2. Fix it with column-level grants
Take away the table-wide UPDATE and give back only the columns users should edit:
revoke update on table public.profiles from authenticated, anon;
grant update (display_name, avatar_url, bio) on table public.profiles to authenticated;The order matters. Supabase's docs point out that if a role has both a table-level and a column-level privilege and you revoke the column one, the table-level grant still applies. So revoke update (plan) on public.profiles from authenticated on its own does nothing while the table grant exists. Revoke the table grant, then grant columns.
Your existing RLS policy keeps doing its job (which row). The grant now does the other half (which columns). Your server code using the secret / service_role key is unaffected, so your Stripe webhook can still set plan.
If your project was created after Supabase's 30 October 2026 grants change, new tables don't get API grants automatically (see the 42501 guide). That's a good moment to grant column-level UPDATE from the start instead of grant update on table ... to authenticated.
3. Don't forget INSERT
Locking UPDATE doesn't help if users can create the row with whatever values they want. If your app lets the client insert its own profile, a user can sign up and insert plan = 'pro' on day one. Two clean options:
- Create profile rows server-side (a trigger on
auth.usersor your backend) andrevoke insert on table public.profiles from authenticated, anon; - Or allow inserts on safe columns only and let defaults fill the rest:
revoke insert on table public.profiles from authenticated; grant insert (id, display_name, avatar_url) on table public.profiles to authenticated;
supabase-js upsert is an insert with an update on conflict, so it needs both privileges on every column you send.
4. Or use a trigger when the rule is conditional
Grants are all-or-nothing per role. If some signed-in users (say, admins checked via a roles table) may change a column and others may not, a BEFORE UPDATE trigger works:
create or replace function public.protect_profile_billing()
returns trigger
language plpgsql
set search_path = ''
as $$
begin
if current_user in ('anon', 'authenticated')
and (new.plan is distinct from old.plan
or new.credits is distinct from old.credits
or new.stripe_customer_id is distinct from old.stripe_customer_id) then
raise exception 'plan, credits and billing fields can only be changed by the server';
end if;
return new;
end;
$$;
create trigger protect_profile_billing
before update on public.profiles
for each row execute function public.protect_profile_billing();Requests through the Supabase API run as anon or authenticated, so the trigger sees that as current_user. Your service_role code doesn't match and passes through. Keep the function as the default security invoker (not security definer) so current_user stays the caller.
5. The cleanest fix: move the values out
Supabase's docs call column privileges an advanced feature and recommend RLS plus a dedicated table for roles. The same goes for billing state. Put plan, credits and Stripe ids in something like public.subscriptions with a select policy for the owner and no insert, update or delete policies for anon or authenticated. Only your webhook (server, secret key) writes to it. Users can read their plan but have no path to change it. Same idea for roles in where to store roles safely.
6. Test it as a real user
The SQL Editor runs as postgres and bypasses all of this (see testing RLS as a real user), so switch roles inside a transaction:
begin;
set local role authenticated;
select set_config('request.jwt.claims',
json_build_object('sub', '<YOUR_TEST_USER_ID>', 'role', 'authenticated')::text, true);
-- should still work: an allowed column on your own row
update public.profiles set display_name = 'test' where id = auth.uid() returning id, display_name;
rollback;
begin;
set local role authenticated;
select set_config('request.jwt.claims',
json_build_object('sub', '<YOUR_TEST_USER_ID>', 'role', 'authenticated')::text, true);
-- should fail with 42501 permission denied (or your trigger's error)
update public.profiles set plan = 'pro' where id = auth.uid() returning id, plan;
rollback;They're in separate transactions because an error aborts the rest of the transaction. Then do the same from your app's browser console with a normal test account. If the plan update comes back with a row, it isn't locked.
A prompt for Lovable, Bolt or Cursor
For every table in my Supabase public schema that has an UPDATE or INSERT policy for authenticated users, list the columns a user could set on their own row. Flag any column that controls billing, credits, plan, verification, roles or ownership. For those tables write a migration that revokes table-level UPDATE (and INSERT where the client doesn't need it) from authenticated and anon, then grants UPDATE/INSERT on only the columns users should edit. Don't change the RLS policies. Then give me SQL tests that run as a signed-in user inside begin; ... rollback; and check that updating plan fails while updating display_name works.What an outside scan can and can't see
Abbi Labs checks from the outside and never writes to your database. On every scan it reports tables your public key can read, and tables with role-looking columns (role, is_admin and similar) where Supabase's public API description lists write methods for the anon role. It doesn't know which of your columns mean "paid", so a self-editable plan column for signed-in users is something to check with the query and test above. If you paste your policies and grants into the free Supabase RLS policy checker (runs in your browser), it flags own-row UPDATE policies on tables with role-type columns when authenticated has table-wide UPDATE, plus RLS off, using (true) and open inserts.
FAQ
Can an RLS policy restrict which columns a user can update?
No. Row Level Security decides which rows a role can see and write. A policy like using ((select auth.uid()) = id) lets the owner update that row, and every column on it. Supabase's Column Level Security docs say the same: use column privileges (grant update (col1, col2)) or move the sensitive values to a table users can't write.
I revoked UPDATE on one column but users can still change it. Why?
Because the table-level UPDATE grant is still there. Supabase's docs note that if a role has both table-level and column-level privileges, revoking the column privilege leaves the table-level one in effect. Revoke UPDATE on the whole table first, then grant UPDATE on only the columns users should edit.
Will column-level grants break select * in my app?
Not if you only restrict UPDATE (and INSERT). Supabase's warning about select * applies when you revoke SELECT on a column: then that role has to list columns explicitly. If you lock columns for update, a write that touches them fails with a permission denied error (42501), and writes to the allowed columns still work.
Column grants or a trigger: which should I use?
Column grants are simplest and are enforced by Postgres before any policy runs. A BEFORE UPDATE trigger is useful when the rule is conditional (for example, admins may change plan but users may not). For values like plan, credits or roles, Supabase recommends a separate table that only your server writes, which avoids the problem entirely.
Can users set plan = 'pro' when they create their profile row?
Yes, if they can insert into the table. Locking UPDATE isn't enough when there's an INSERT policy for authenticated users, because the user picks every column value on insert. Either create profile rows server-side (a trigger on auth.users is common) and revoke INSERT, or grant INSERT on only the safe columns and let defaults fill the rest.
Does Abbi Labs check this?
Partly. The free outside scan flags tables whose column names look like privilege columns (role, is_admin and similar) when Supabase's public API description lists write methods for the anon role, plus tables your public key can read. The free Supabase RLS policy checker flags own-row UPDATE policies on tables with role-type columns when authenticated has table-wide UPDATE. Neither knows that your plan or credits column matters, and neither writes to your database, so run the test on this page yourself.