Supabase database
Can a user make themselves admin in my Supabase app?
Yes, if your profiles table holds the role and users may update their own profile row. RLS only checks that the row is theirs, not which column changes, so one request can set role = 'admin'; the fix is to let users write only the columns they own, or keep roles in a table they can’t write.
TL;DR
- In our lab a normal user sent one PATCH setting his own
roletoadmin, then read an admin-only payouts table. - A brand-new user did the same at sign-up, by inserting his profile with
role: 'admin'. - Column grants (
grant update (full_name)) stopped both with 42501 and kept profile editing working. - Supabase’s docs recommend a dedicated roles table; and never use
user_metadatafor roles, because users can edit it.
Why an owner-only policy doesn’t protect the role
A common AI-built setup: a profiles table with id, full_name and role, and a policy “users can update their own profile”. Admin screens and other policies then check profiles.role = 'admin'.
The update policy asks one question: is this row yours? It doesn’t ask which columns you change. Supabase’s column-level security page makes the same point: an owner policy “gives the post owner full access to update the row, including all of the columns”. Your app may never show a role field, but anyone signed in can call the API directly with their own token.
What we saw in the lab
-- profiles(id, full_name, role default 'user'); policies: read own, create own, update own (using + with check)
-- payouts: readable only when profiles.role = 'admin'
bob GET /payouts: [] [HTTP 200]
bob PATCH his own profile role=admin: [{"id":"22222222-…","full_name":"Bob","role":"admin"}] [HTTP 200]
bob GET /payouts: [{"id":1,"customer":"Carol","iban":"GB00TEST00000000000000"}] [HTTP 200]
stranger creates his profile with role=admin: [{"id":"99999999-…","full_name":"Sam","role":"admin"}] [HTTP 201]
stranger GET /payouts: [{"id":1,"customer":"Carol", … }] [HTTP 200]In the browser this is one line: supabase.from('profiles').update({ role: 'admin' }).eq('id', user.id). The with check on the policy didn’t help, because the row still belonged to Bob after the change.
The fix: users write only the columns they own
revoke insert, update on public.profiles from anon, authenticated;
grant insert (id, full_name) on public.profiles to authenticated;
grant update (full_name) on public.profiles to authenticated;
-- role keeps its default ('user'). Change it from the dashboard, a server
-- function using the secret key, or an admin-only function.bob PATCH role=admin: {"code":"42501","message":"permission denied for table profiles"} [HTTP 403]
bob PATCH full_name: [{"id":"22222222-…","full_name":"Robert","role":"user"}] [HTTP 200]
stranger creates profile with role=admin: {"code":"42501", … } [HTTP 403]
stranger creates profile without role: [{"id":"99999999-…","full_name":"Sam","role":"user"}] [HTTP 201]
stranger GET /payouts: [] [HTTP 200]
alice (admin) GET /payouts: [{"id":1,"customer":"Carol", … }] [HTTP 200]Add each new editable column to the grant when you add it to the form. If your profile row is created by a trigger on auth.users (the usual Supabase pattern), drop the insert grant for authenticated altogether.
The cleaner long-term design, and the one Supabase’s docs recommend, is a separate user_roles table with no insert or update policy for authenticated, read by policies through a small security definer helper. See user_metadata vs app_metadata for that pattern, and infinite recursion in a policy for the helper.
Two other ways users promote themselves
user_metadata. Any signed-in user can change it withsupabase.auth.updateUser({ data: { role: 'admin' } }). Supabase’s Security Advisor flags policies that read it (“RLS references user metadata”, ERROR).- Admin checks only in the browser. Hiding the admin menu doesn’t stop the API. The rule has to be in a policy or a server function (finding PL-020).
How to check it worked
Read-only: which columns can signed-in users write on profiles?
select table_name, privilege_type,
string_agg(column_name, ', ' order by column_name) as columns
from information_schema.column_privileges
where table_schema = 'public' and table_name = 'profiles'
and grantee = 'authenticated' and privilege_type in ('INSERT', 'UPDATE')
group by 1, 2;profiles | INSERT | full_name, id
profiles | UPDATE | full_nameIf role (or is_admin, plan, credits, verified) appears, users can set it. Then test for real: sign in as a normal user and, in the browser console, run the update above. It must fail.
Ask your AI builder to fix it
In my Supabase app, users can update their own row in public.profiles, and that table has a role column that other policies trust. Stop users changing role (and any other column like is_admin, plan or credits). Write a migration that revokes insert and update on public.profiles from anon and authenticated, then grants insert (id, full_name) and update (full_name) to authenticated, adding only the columns the profile form really edits. Role changes must only happen server-side. Don't use user_metadata for roles. Show me the SQL before you apply it, and list any app code that writes role.Questions people ask
Can a user change their own role in Supabase?
Yes, if the role is a column in a table they may update, such as profiles with an owner-only update policy. Row level security checks the row, not the column. In our lab a normal user set his role to admin with one request.
How do I stop users updating one column in Supabase?
Revoke update on the table from authenticated and grant update only on the columns users may edit, for example grant update (full_name) on public.profiles to authenticated. In our lab changing role then failed with 42501.
Where should I store user roles in Supabase?
In a table users can't write, such as user_roles with no insert or update policy for authenticated, or in app_metadata, which only the server can set. Supabase's docs recommend RLS with a dedicated roles table. Never in user_metadata.
Does WITH CHECK stop users making themselves admin?
Not if it only checks ownership. In our lab the policy had with check (auth.uid() = id), and the row was still Bob's after he set role to admin, so the update passed.
Sources and lab
- Supabase: Column Level Security, read 5 Dec 2026: an owner policy allows updating every column; revoke and grant per column; dedicated roles table recommended.
- Supabase: lint 0015 rls_references_user_metadata: users can set user_metadata with updateUser.
- Lab: Postgres 17.11 and 18.6 with PostgREST 12.2.12 and a Supabase role shim, real HTTP requests as an admin, a normal user and a new user, 5 Dec 2026. Synthetic data and test IBAN only. Same results on both versions.
Related findings
The checks behind this guide, each with example code, a self-check and the fix.
Users can make themselves admin
PL-004UPDATE policy missing WITH CHECK
PL-019Access decided by user_metadata, which users can edit
Free check
Check your migrations for this, free.
Paste a public GitHub repo. The free RLS check reads its supabase/migrations and flags tables with RLS off or no policies, always-true policies, update policies with no WITH CHECK, SECURITY DEFINER functions anyone can call or with no fixed search_path, views that skip RLS and public buckets. It never connects to your database.
Written by Manraj Singh Dhillon. Last checked 5 Dec 2026. Code samples are synthetic and run against your own project; nothing here names a real app. Spotted a mistake? Tell us.