Skip to content
VibeSafeDaily

Exposed data

Table grants stay wide open after policies are added

Cataloged October 16, 2026 · Lovable · Bolt · Cursor · Supabase

Symptom

You added policies, then a signed-out client can still insert, or a signed-in client can still delete rows the policy was meant to hide.

Root cause

Supabase's RLS guide separates grants from policies. Grants decide whether a role may run an operation at all. Policies decide which rows it applies to. On existing projects, a new table in public can start with select, insert, update, and delete already granted to anon, authenticated, and service_role. Adding policies does not revoke those grants. service_role keeps full access and bypasses RLS, so that key has to stay on the server.

Before and after

The after block is the fix prompt. The before line is the grant state the root cause describes: the table already allows the operation, so a policy alone does not remove it.

Before

-- anon and authenticated already have insert, update, and delete

After

revoke all on table public.your_table from anon, authenticated;
grant select, insert, update, delete on table public.your_table to authenticated;

Fix prompt

In this project's migrations only, for every client-facing table:

alter table public.your_table enable row level security;
revoke all on table public.your_table from anon, authenticated;
grant select, insert, update, delete on table public.your_table to authenticated;

Grant anon nothing unless the product truly has a public read. Then write one policy per granted operation. Do not grant service_role to the browser. Do not edit other projects.

Paste this into the coding tool that has your own project open.

2-minute self-check

These steps are for an app you own. Do not run them against someone else's project.

  1. In your own SQL editor, run select grantee, privilege_type, table_name from information_schema.role_table_grants where table_schema = 'public' and grantee in ('anon', 'authenticated').
  2. Confirm anon has no insert, update, or delete on private tables.
  3. Signed out of your own app, try the create action in the UI. It should fail.

Common questions

I added policies, and a signed-out client can still insert. What did I miss?

Supabase separates grants from policies. Grants decide whether a role may run an operation at all. Policies decide which rows. On an existing project, a new public table can already grant select, insert, update, and delete to anon and authenticated. Adding policies does not revoke those grants. Confirm anon has no insert, update, or delete on your own private tables.

Does the service role key still bypass the new policies?

Yes. service_role keeps full access and bypasses RLS, so that key stays on the server. The fix prompt revokes anon and authenticated, then grants back only the operations the app uses. It does not grant the service role to the browser.

Longer guide

Sources

Same symptom

Same platform