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.

Flagged repositories in the follow-up
Strict runtime confirmations
4 of 20
Policy verification outcomes

Apply the fix

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

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

    revoke update on table public.profiles from authenticated;
    grant update (display_name, avatar_url)
      on table public.profiles to authenticated;
  3. 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.