# 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.

## From the research

4 of 20 flagged repositories met the strict runtime definition in the follow-up.

- [Policy verification outcomes](https://github.com/ohad6k/viberaven-research/blob/2d45c586d8d73b8913651894f4451b8071086daf/data/policy-verification-aggregate.csv)

## Apply the fix

### Separate ownership from authority

Put display fields in `profiles` and 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 `authenticated` currently has table-level `UPDATE` and `display_name` and `avatar_url` are user-editable, the update part looks like this.

```sql
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, `PUBLIC` and existing column privileges. If the browser creates rows or uses upserts, restrict `INSERT` to 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.

- [Policy shape study and sampling limits](https://github.com/ohad6k/viberaven-research/blob/2d45c586d8d73b8913651894f4451b8071086daf/studies/policy-shapes/README.md)
- [Supabase Column Level Security](https://supabase.com/docs/guides/database/postgres/column-level-security)

## Related guide

- [Test Supabase row ownership policies](https://viberaven.dev/test-supabase-rls-policies)

Source: https://viberaven.dev/answers/supabase-profile-update-role-column

Site index: https://viberaven.dev/llms.txt
