Supabase columns users should never edit: roles, pro flags and plan fields

By Arif Khan, AIVolve LLC · Updated November 13, 2026

"Can a user make themselves admin, or give themselves Pro, in my Supabase app just by editing their own profile?"

Short answer: often, yes. Row Level Security decides which rows a user can change, not which columns. The usual AI-generated policy, "users can update their own profile", lets a signed-in user change every column in their own row, including role, is_admin, is_pro, plan and credits. They don't need your app's screens to do it: your project URL and public key are in the browser, so a few lines in the browser console are enough. Supabase's docs also say user_metadata "is editable by the user without any checks", so a role kept there is just as open. The fix: move the columns that grant access into a table users can only read, or lock them with column privileges or a trigger. Keep roles in app_metadata, which only your server can change, and make sure no security definer function trusts a user id sent from the browser.

Why this matters right now

When a founder's Supabase app was wiped in October, his postmortem on X (@MaxHirsch13) included a 10-point audit prompt that has been bookmarked over 2,000 times. Point 6 is the subject of this guide: "Every profile column that grants access (pro flags, trial dates, roles, admin) can only be changed by the server." Point 5 asks whether any security definer function will "trust a user id passed as a parameter instead of auth.uid()". Our view bypass guide covered his points 2 and 3. This one covers 5 and 6.

I think this hole is easy to miss because the app looks right. The profile page only shows a name and an avatar field, and the admin screen is hidden from normal users. But hiding a button doesn't protect anything. Only the database can refuse the change.

Why your RLS policy doesn't protect these columns

Supabase's column-level security page puts it plainly. For an owner-only update policy, it says: "this gives the post owner full access to update the row, including all of the columns." The policy checks whose row it is. It never looks at what changed.

On a test database with a typical profiles table and the standard "update own profile" policy, a signed-in user ran one update on their own row and came out with role = admin, is_admin = true, is_pro = true and 999,999 credits. Another user's row stayed untouched, so RLS was working. It just wasn't the right lock.

Inserts have the same gap. If your app lets users create their own profile row (an INSERT policy with with check (auth.uid() = id)), a new user can create it with is_admin = true from the start.

And user_metadata is open by design. Supabase's docs say raw_user_meta_data "can be updated by the authenticated user using the supabase.auth.update() function. It is not a good place to store authorization data." Anyone can also pick their own metadata at sign-up, so a sign-up trigger that copies a role from raw_user_meta_data into profiles hands out roles to anyone who asks.

Before you start (2 minutes)

Step 1: Find the columns that grant access

This read-only query lists columns in public whose names suggest they control access or money, and whether signed-in users (and logged-out visitors) can write them:

select c.table_name, c.column_name,
  has_column_privilege('authenticated', format('%I.%I', c.table_schema, c.table_name), c.column_name, 'update') as signed_in_can_update,
  has_column_privilege('authenticated', format('%I.%I', c.table_schema, c.table_name), c.column_name, 'insert') as signed_in_can_insert,
  has_column_privilege('anon', format('%I.%I', c.table_schema, c.table_name), c.column_name, 'update') as anon_can_update
from information_schema.columns c
where c.table_schema = 'public'
  and c.column_name ~* '(role|admin|is_pro|premium|plan|tier|credit|balance|quota|subscription|stripe|paid|trial|verified|approved|banned|permission)'
order by 1, 2;

A true in any of the three columns means that role holds the privilege. Whether a user can actually change their own row then depends on your policies. List the ones that allow writes:

select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public' and cmd in ('INSERT', 'UPDATE', 'ALL')
order by 1, 2;

If a table from the first query has an UPDATE (or ALL) policy for authenticated that only checks auth.uid(), users can change those columns on their own rows. An INSERT policy means they can also choose the values when the row is created.

Then check whether anything trusts user_metadata:

select 'policy' as kind, tablename as name, policyname as detail
from pg_policies
where coalesce(qual, '') || coalesce(with_check, '') ~* 'user_metadata|raw_user_meta_data'
union all
select 'function', p.proname, pg_get_function_arguments(p.oid)
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosrc ~* 'user_metadata|raw_user_meta_data';

A sign-up trigger that copies a display name from raw_user_meta_data is fine. One that copies a role, plan or flag is not. In your app's code, search for user_metadata too: any if (user.user_metadata.role === 'admin') is a check the user controls.

Step 2: Test it like a stranger would

Test 1, in the SQL editor (changes nothing). Replace the id with your test user's id (find it under Authentication → Users). The whole test is rolled back:

begin;
set local role authenticated;
set local request.jwt.claim.sub = 'YOUR-TEST-USER-ID';
update public.profiles set is_admin = true
where id = 'YOUR-TEST-USER-ID'
returning id, is_admin;
rollback;

Test 2, from the browser console, with only your public key. This is exactly what a curious user can do. Open your live app in Chrome, press F12, choose Console, and paste this, with your project URL, your public key (the publishable key, or the older anon key) and your test account's email and password:

const SUPABASE_URL = 'https://YOUR-PROJECT-REF.supabase.co';
const PUBLIC_KEY = 'YOUR_PUBLIC_KEY';
const login = await fetch(SUPABASE_URL + '/auth/v1/token?grant_type=password', {
  method: 'POST',
  headers: { apikey: PUBLIC_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({ email: 'your-test-user@example.com', password: 'TEST_USER_PASSWORD' })
}).then(r => r.json());
const headers = { apikey: PUBLIC_KEY, Authorization: 'Bearer ' + login.access_token, 'Content-Type': 'application/json' };
const me = await fetch(SUPABASE_URL + '/auth/v1/user', { headers }).then(r => r.json());
const res = await fetch(SUPABASE_URL + '/rest/v1/profiles?id=eq.' + me.id, {
  method: 'PATCH',
  headers: { ...headers, Prefer: 'return=representation' },
  body: JSON.stringify({ is_pro: true })
});
console.log(res.status, await res.text());

How to read the result:

This test only works for email and password accounts. If your app only has Google or magic-link sign-in, use test 1.

Step 3: Lock the columns (pick one)

Option A: move them to a table users can only read (Supabase's recommendation)

Supabase's docs say they "do not recommend using column-level privileges for most users" and recommend "RLS policies in combination with a dedicated table for handling user roles." Put everything that grants access or money in its own table. Signed-in users can read their own row. Only your server writes to it.

create table public.user_access (
  user_id uuid primary key references auth.users on delete cascade,
  role text not null default 'user',
  is_pro boolean not null default false,
  plan text not null default 'free',
  credits integer not null default 0
);
alter table public.user_access enable row level security;
revoke all on table public.user_access from anon, authenticated;
grant select on table public.user_access to authenticated;
grant select, insert, update, delete on table public.user_access to service_role;
create policy "Users can read their own access"
on public.user_access for select to authenticated
using ((select auth.uid()) = user_id);

Copy the current values across, then point your app at the new table:

insert into public.user_access (user_id, role, is_pro, plan, credits)
select id, role, is_pro, plan, credits from public.profiles
on conflict (user_id) do nothing;

Drop the old columns from profiles only after the app reads from user_access. There is no write policy, so the public key can't change this table, and the grants block it even before RLS runs. Your Stripe webhook or Edge Function writes to it with the secret key. That's the right place for "user paid, turn on Pro". See Stripe webhooks: test vs live.

Option B: keep one table, lock the columns with privileges

Take away the table-wide UPDATE and INSERT grants, then give back only the safe columns:

revoke insert, update on table public.profiles from anon, authenticated;
grant update (full_name, avatar_url) on table public.profiles to authenticated;

If your app creates the profile row from the browser (you saw an INSERT policy in step 1), also grant the columns it needs to insert:

grant insert (id, full_name, avatar_url) on table public.profiles to authenticated;

Things to know:

Option C: a trigger that refuses client changes

Useful when you can't change the app's code yet. It blocks changes from the browser roles (anon and authenticated) and lets your server and the SQL editor through:

create or replace function public.protect_access_columns()
returns trigger
language plpgsql
set search_path = ''
as $$
begin
  if current_user in ('anon', 'authenticated') then
    if tg_op = 'INSERT' then
      if new.role <> 'user' or new.is_admin or new.is_pro or new.plan <> 'free' then
        raise exception 'You cannot set role, is_admin, is_pro or plan' using errcode = '42501';
      end if;
    elsif (new.role, new.is_admin, new.is_pro, new.plan, new.credits)
      is distinct from (old.role, old.is_admin, old.is_pro, old.plan, old.credits) then
      raise exception 'You cannot change role, is_admin, is_pro, plan or credits' using errcode = '42501';
    end if;
  end if;
  return new;
end;
$$;

create trigger protect_access_columns
before insert or update on public.profiles
for each row execute function public.protect_access_columns();

Edit the column names and starting values to match yours. Updates that leave those columns unchanged still work, so a form that saves the whole row keeps working. For credits, decide whether new users may start with any amount. If not, add or new.credits <> 0 (or your real starting value) to the INSERT check.

Changes made inside a security definer function run as the function's owner, so this trigger lets them through. That's how your own sign-up trigger and credit functions keep working, and it's why step 5 matters.

Step 4: Keep roles in app_metadata, not user_metadata

Supabase's docs: raw_app_meta_data "cannot be updated by the user, so it's a good place to store authorization data." Set a role from the SQL editor:

update auth.users
set raw_app_meta_data = coalesce(raw_app_meta_data, '{}'::jsonb) || '{"role": "admin"}'::jsonb
where id = 'THE-ADMIN-USER-ID';

Or from server code, with the secret key: supabase.auth.admin.updateUserById(userId, { app_metadata: { role: 'admin' } }). Never in the browser.

Then check it in policies through the JWT:

create policy "Admins can read all profiles"
on public.profiles for select to authenticated
using ((select auth.jwt() -> 'app_metadata' ->> 'role') = 'admin');

Two things to know:

Step 5: Fix functions that trust a user id from the browser

A security definer function runs as its owner, which on Supabase is usually postgres, so it skips RLS. Supabase's docs warn that "Any role can call it by default, including anon". That makes this pattern dangerous:

-- Unsafe: anyone can spend anyone's credits
create or replace function public.use_credit(p_user_id uuid)
returns void
language plpgsql
security definer set search_path = ''
as $$
begin
  update public.profiles set credits = credits - 1 where id = p_user_id;
end;
$$;

On the test database, a second signed-in user called it with the first user's id and spent their credits, and a logged-out visitor could do the same. List your security definer functions and who can call them:

select p.proname as function_name,
  pg_get_function_arguments(p.oid) as arguments,
  has_function_privilege('anon', p.oid, 'execute') as anon_can_call,
  has_function_privilege('authenticated', p.oid, 'execute') as signed_in_can_call
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef
order by 1;

Trigger functions such as handle_new_user show up in this list too. They can't be called through the API, so you can leave them. Any other function with a user id argument that changes access, credits or money needs a fix. Take the user from the verified token with auth.uid() instead, and narrow who can call it:

drop function if exists public.use_credit(uuid);
create or replace function public.use_credit()
returns integer
language plpgsql
security definer set search_path = ''
as $$
declare
  remaining integer;
begin
  update public.profiles set credits = credits - 1
  where id = (select auth.uid()) and credits > 0
  returning credits into remaining;
  if remaining is null then
    raise exception 'No credits left';
  end if;
  return remaining;
end;
$$;
revoke execute on function public.use_credit() from public, anon;
grant execute on function public.use_credit() to authenticated;

If you moved credits to user_access in option A, update that table instead of profiles. Functions that only your server should call (for example "grant Pro after payment") shouldn't be callable from the browser at all. Revoke execute from public, anon and authenticated, and grant it to service_role.

How to know you're done

A prompt for Lovable, Cursor or Claude Code

Security fix: users must not be able to change their own access columns in Supabase. Work in two phases. Phase 1, read-only: list every column in the public schema that grants access or money (role, is_admin, admin, is_pro, plan, tier, credits, balance, subscription, trial dates, stripe ids), and for each one whether the authenticated or anon role can INSERT or UPDATE it and which RLS policies allow it. Also list every RLS policy, database function and piece of app code that reads user_metadata or raw_user_meta_data, and every security definer function in public, its arguments, and whether anon or authenticated can execute it. Show me the list and change nothing. Phase 2, after I approve: write ONE migration that 1. moves the access columns into a separate table that authenticated users can only SELECT (their own row, via RLS), with no insert, update or delete grants for anon or authenticated, and grants for service_role, 2. or, if I choose, revokes table-wide INSERT and UPDATE on the profile table from anon and authenticated and grants UPDATE back only on the safe columns I name, 3. moves any role stored in user_metadata to app_metadata and changes every policy to read auth.jwt() -> 'app_metadata', 4. rewrites every security definer function that takes a user id so it uses auth.uid() instead, and revokes execute from public and anon. Update the app code so profile saves only send the safe columns, and payments or admin changes run server-side with the secret key. Do not drop any data. Show me the migration before applying it.

FAQ

Can a Supabase user change their own role or is_admin column?+

Yes, if your RLS policy lets users update their own profile row and the role or is_admin column is in that row. RLS checks which row is changed, not which columns. Move those columns to a table users can only read, or lock them with column privileges or a trigger.

How do I stop users from updating certain columns in Supabase?+

Revoke the table-wide update grant from anon and authenticated, then grant update only on the safe columns, for example grant update (full_name, avatar_url) on table public.profiles to authenticated. Supabase's own recommendation for roles is a separate table that users can only read.

Is user_metadata safe for storing roles in Supabase?+

No. Supabase's docs say user_metadata is editable by the user without any checks, and users can set it at sign-up or with updateUser. Store roles in app_metadata, which only your server or the SQL editor can change, and read it in policies with auth.jwt() -> 'app_metadata'.

Where should I store is_pro or plan fields in Supabase?+

In a table that signed-in users can read but not write, updated only by your server, for example by your Stripe webhook using the secret key. If they stay in the profile table, lock them with column privileges or a trigger so the browser can't change them.

Why is a security definer function that takes a user id dangerous?+

It runs with its owner's rights, usually postgres, so it skips RLS, and by default anyone can call it, including anon. If it acts on a user id passed in by the caller, anyone can act on anyone's account. Use auth.uid() inside the function and revoke execute from public and anon.

Want a second pair of eyes?

Start with a free X-ray: 2 minutes, no code or passwords. Your AI builder writes a read-only report that includes security red flags, and an AIVolve developer reviews every X-ray within 1 business day. Get a free X-ray →

Related: Supabase RLS for AI-built apps: the 10-minute check · Supabase view bypasses RLS: security_invoker and revoking anon delete · Security audit prompts for AI-built apps · Stripe works in test mode but not live · Supabase "Database error deleting user"

Written by Arif Khan, AIVolve LLC. VibeCoderSOS isn't affiliated with Supabase. Docs were checked and every SQL block was tested on a local Postgres database on November 11, 2026.

Need help?

Start with a free X-ray: 2 minutes, no code or passwords. Your AI builder writes a read-only report that includes security red flags, and an AIVolve developer reviews every X-ray within 1 business day.

Get a free X-ray →