Supabase RLS
Keep the Supabase profiles role column under server control
Keep the owner UPDATE policy for profile rows and put role, plan and billing fields in a separate table that the browser role cannot write. If a protected field has to stay in profiles, replace table-wide UPDATE with an explicit grant for the editable columns.
- Strict runtime confirmations
- 4 of 20
Apply the fix
Separate ownership from authority
Put display fields in
profilesand server-managed fields in an authorization or billing table keyed by user ID. Write server fields through a trusted backend that checks the caller's authority. Give the browser only the reads it needs.Restrict writes if the schema must stay
In one migration, replace the browser role's table-wide grants with column grants for explicitly editable fields. For a schema where
authenticatedcurrently has table-levelUPDATEanddisplay_nameandavatar_urlare user-editable, the update part looks like this.revoke update on table public.profiles from authenticated; grant update (display_name, avatar_url) on table public.profiles to authenticated;Review every write path
Check effective grants from inherited roles,
PUBLICand existing column privileges. If the browser creates rows or uses upserts, restrictINSERTto the permitted fields too. Review any writable views or RPCs that update the same data.
Verify the change
On a disposable project, confirm that an ordinary account can save its own display fields, that the browser role lacks write permission on server-managed columns, and that the intended backend can still update them. Keep the row ownership assertion next to the column assertions.
Research and sources
The policy shape appeared in 168 of 749 fully loaded repositories. In the follow-up, 4 of 20 flagged repositories met the strict definition: the write succeeded in isolation and a server writer was present in source. The study estimates about 4.5% for this policy shape in the fully loaded cohort, with a wide interval.