Supabase "rls_references_user_metadata": what it means and how to fix it
Short answer: Supabase shows rls_references_user_metadata ("Security policy relies on user-editable data", lint 0015, level ERROR) when a row level security policy reads user_metadata from the user's JWT. Any signed-in user can change their own user_metadata, so a check like is_admin = true there lets anyone make themselves an admin. Move the role to app_metadata or a roles table only your server writes, replace the policy, then test as a normal user who edits their own metadata. SniffPup, a free passive security scanner for vibe-coded apps, can then run a free SniffPup scan of your own site to see what visitors can reach.
Passive, read-only checks only, for a live URL you own or are authorized to test. The free scan does not read your RLS policies; this is not a source, RLS, or security audit. A score of 100 means no issues were found in our checks, not proof of security. Full fixes free for every critical issue (no critical? one other fix is free).
Home › Guides › Supabase "rls_references_user_metadata": what it means and how to fix it · Last updated · By Ember, SniffPup
What does "Security policy relies on user-editable data" mean?
Every Supabase user has two metadata fields. user_metadata (stored in raw_user_meta_data) is set by the user: at sign-up through options.data, and later with supabase.auth.updateUser. app_metadata (stored in raw_app_meta_data) can't be updated by the user. Both show up in the JWT that auth.jwt() returns inside a policy.
Supabase's docs say not to use user_metadata in security-sensitive places such as RLS policies or authorization logic. The Advisor's own example of an unsafe policy:
create policy bad_policy on public.foo for select to authenticated using ( (( select auth.jwt() ) -> 'user_metadata' ->> 'is_admin' )::bool );
Any signed-in user can run updateUser({ data: { is_admin: true } }) from the browser and pass it. If sign-ups are open, that means anyone who creates an account.
Bolt's docs say its database Security page uses the same checks as Supabase's Security Advisor.
How do I find every policy that trusts user_metadata?
Start with Advisors > Security Advisor in the Supabase dashboard. The lint matches policy text that reads user_metadata through auth.jwt() or the request.jwt.claims setting, so also list policies and functions yourself in the SQL Editor:
-- policies that read user metadata directly select schemaname, tablename, policyname, cmd, roles, qual, with_check from pg_policies where coalesce(qual, '') ~* '(user_metadata|raw_user_meta_data)' or coalesce(with_check, '') ~* '(user_metadata|raw_user_meta_data)'; -- functions in public that read it (policies may call these) select p.proname 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)';
These queries find direct text references only, and the function query looks only in public, so they don't prove you found every case; review helper functions and triggers too. A function hit is fine if it only copies a name or avatar, as in Supabase's own sign-up trigger example. It is the same hole if it copies a role, plan or team into a table your policies trust. You can also paste your policies into the RLS policy explainer, which runs in your browser and flags policies that read user_metadata.
How do I fix it?
Supabase's docs say there is no one-size-fits-all replacement, so rewrite each policy. Pick one of two places for the role.
Option A: a role in app_metadata
Replace the policy so it reads app_metadata, which users can't update:
drop policy "Admins read all reports" on public.reports; create policy "Admins read all reports" on public.reports for select to authenticated using ( (select auth.jwt() -> 'app_metadata' ->> 'role') = 'admin' );
Set the role only on your server, with the Admin API and your secret key (never in the browser):
await supabase.auth.admin.updateUserById(userId, {
app_metadata: { role: "admin" },
});A JWT is not always up to date: Supabase's RLS docs say a change to app_metadata is not reflected in auth.jwt() until the user's JWT is refreshed. If removing someone's access must work at once, use option B.
Option B: a roles table only your server writes
create table public.user_roles (
user_id uuid primary key references auth.users on delete cascade,
role text not null check (role in ('admin', 'member'))
);
alter table public.user_roles enable row level security;
revoke all on table public.user_roles from anon, authenticated;
grant select on table public.user_roles to authenticated;
grant all on table public.user_roles to service_role;
create policy "Users read own role"
on public.user_roles for select
to authenticated
using ( (select auth.uid()) = user_id );
drop policy "Admins read all reports" on public.reports;
create policy "Admins read all reports"
on public.reports for select
to authenticated
using ( exists (
select 1 from public.user_roles r
where r.user_id = (select auth.uid()) and r.role = 'admin'
) );Signed-in users get only select, and there is no insert, update or delete policy for them, so they can't change a role from the browser. Your server (with the secret key) or the SQL Editor manages roles. Supabase's RBAC guide uses the same kind of table, plus a Custom Access Token hook that adds the role to the JWT. More patterns: admin-only access without self-promotion and stop users updating their own role column.
Using Lovable, Bolt or Cursor? Paste this into the chat:
Supabase Security Advisor reports rls_references_user_metadata. List every RLS policy and database function that reads user_metadata or raw_user_meta_data. Move roles and permissions to a public.user_roles table with RLS on, a select policy for the user's own row, and no insert, update or delete for anon or authenticated. Rewrite each policy to check that table. Drop the old policies by name; don't add new ones next to them. Don't decide admin screens from user_metadata in the app code either. Show me the SQL before you run it.
How do I check the fix worked?
Open Security Advisor again; the finding should be gone. Then test as a stranger with an account: sign in as a test user who is not an admin, run supabase.auth.updateUser({ data: { is_admin: true } }) (use the key your old policy read), call supabase.auth.refreshSession(), and try the admin read. Expect no rows. Then check who already had the role:
select id, email, raw_user_meta_data ->> 'is_admin' as is_admin from auth.users where raw_user_meta_data ? 'is_admin';
Change is_admin to the key your old policy used. The query lists every account that has the key, even when it is false. If an account you don't recognize has it set to true, treat it as a possible incident and review what that table holds.
What should I do?
1. Find every policy and function that reads user_metadata
Open Advisors, then Security Advisor, in the Supabase dashboard. Each finding names the table and policy. Then run the pg_policies and pg_proc queries in this guide in the SQL Editor. They find direct text references only (the function query looks in public), and a policy that calls a function is not caught by the lint, so also review helper functions and triggers by hand.
2. Decide where the role should live
Use app_metadata if you can accept access remaining until the user's JWT is refreshed after you remove a role. Use a user_roles table that only your server writes if removing access must work at once, or if you have more than a couple of roles.
3. Give real admins their role in the new place first
Set app_metadata from your server with the Admin API and your secret key, or add rows to user_roles in the SQL Editor. Do this before you replace the policy, or your admins lose access.
4. Replace each policy instead of adding another
Drop the policy that reads user_metadata by name and create it again reading app_metadata or the roles table. Permissive policies for the same command combine with OR, so a new strict policy next to the old one does not close anything.
5. Test as a normal user who edits their own metadata
Sign in as a test account that is not an admin, call supabase.auth.updateUser({ data: { is_admin: true } }) (or whatever key your old policy read), refresh the session and try the admin action. It should return no rows or an error.
6. Check who already had the role
List accounts whose raw_user_meta_data holds the role key. If someone you don't know has it set to grant access, treat it as a possible incident, not just a migration step.
Can SniffPup check this?
The free outside scan can't: it is passive and read-only, looks at what your published site gives any visitor, and does not read your RLS policies. If you connect your Supabase project read-only, the Supabase project check (free with a SniffPup account) flags policies that trust user_metadata. The RLS policy explainer flags them in SQL you paste, and nothing is uploaded.
Next: Stop users updating their role column, Supabase RLS policy examples, rls_disabled_in_public, and Supabase security audit.
FAQ
What does rls_references_user_metadata mean?
Supabase's Security Advisor found a row level security policy that reads user_metadata from the user's JWT. Supabase lists it as lint 0015, "Security policy relies on user-editable data", at level ERROR. Any signed-in user can change their own user_metadata, for example with supabase.auth.updateUser({ data: { is_admin: true } }), so a policy that grants access based on a user_metadata value can let users grant themselves that access.
Is user_metadata safe for anything?
Yes, for things the user owns and may change, like a display name, avatar or theme. Supabase's docs say not to use it in security-sensitive places such as RLS policies or authorization logic, because the user can edit it without any checks.
What should I use instead of user_metadata?
Use app_metadata, which users can't update and which you set from your server, or a roles table that only your server can write, with RLS on. Supabase's RBAC guide uses a user_roles table plus a Custom Access Token hook that adds the role to the JWT.
I moved the role to app_metadata. Why doesn't the change show up right away?
Policies read auth.jwt(), and a JWT is not always up to date. Supabase's RLS docs say a change to app_metadata is not reflected in auth.jwt() until the user's JWT is refreshed. If removing access must take effect at once, check a roles table in the policy instead of the JWT.
The Advisor is clean. Can I still have this problem?
Yes. The lint matches policy text that reads user_metadata through auth.jwt() or the request.jwt.claims setting. A policy that calls a helper function, or a sign-up trigger that copies a role from raw_user_meta_data into a profiles table, can carry the same mistake without this warning. App code that shows admin screens because user_metadata says so has the same problem on the screen. Search policies, functions and code for user_metadata and raw_user_meta_data.
Can a SniffPup scan find this?
Not the free outside scan. It is passive and read-only on a live URL you own or are authorized to test, and it does not read your RLS policies. If you connect your Supabase project read-only, SniffPup's Supabase project check (free with a SniffPup account) flags policies that trust user_metadata. The free RLS policy explainer also flags them in SQL you paste, in your browser.
Sources: Supabase: Advisors (lint 0015, level ERROR, the unsafe example policy), Supabase splinter: lint 0015 source (what the text match covers), Supabase: Row Level Security (raw_user_meta_data vs raw_app_meta_data, JWT not always up to date), Supabase: Users (don't use user_metadata in RLS policies or authorization logic), Supabase: Managing user data (metadata at sign-up, sign-up trigger), Supabase: Custom claims and RBAC, Supabase: updateUserById (server only), PostgreSQL: CREATE POLICY (permissive policies combined with OR) and Bolt: Database security settings, checked November 13, 2026. SniffPup facts are from our scanner page and the Supabase project check page.