Deutsch
Fix libraryLowSupabase · RLS

RLS enabled but no policies: why your app shows nothing, and the fix that keeps data safe

RLS is on but the table has no policies, so lists are empty and inserts fail. Add the right policies instead of turning RLS off or allowing everything.

By Tim GeithnerPublished 3 min read

ShipRely's Database & Supabase audit checks for this today.

Short answer

When row level security is on and a table has no policies, Postgres denies everything: selects return no rows without an error and inserts fail with a row-level security error. Your data is safe, but the app looks broken, and the quick fixes people reach for (disable RLS, or a policy of true) open the table to everyone. Add owner policies for the actions your app needs, or document the table as server-only.

Ask an AI about this page:ChatGPTClaude

On this page

If row level security is on and a table has no policies, Postgres uses a default deny: no rows are visible and none can be written. Your data is safe, but your app looks broken: lists stay empty and saving fails. It is rated low because nothing leaks. The real danger is the “fix” that comes next, when someone switches RLS off or adds a policy of true to make the error go away, and the table becomes readable by everyone.

Why it matters

This usually happens after a security clean-up. Someone (or an AI tool) adds enable row level security to a table but no policies:

VulnerableA table that locks everyone out
create table public.notes (
  id uuid primary key default gen_random_uuid(),
  user_id uuid not null default auth.uid() references auth.users (id) on delete cascade,
  body text not null,
  created_at timestamptz not null default now()
);

alter table public.notes enable row level security;

From now on, a signed-in user’s supabase.from("notes").select() returns an empty list without any error, because RLS filters rows silently. Saving a note fails with new row violates row-level security policy for table "notes". When you paste that error into an AI builder, the fastest answers are these two:

VulnerableThe two quick fixes to avoid
alter table public.notes disable row level security;

create policy "Allow all" on public.notes for all using (true) with check (true);

Both make the error disappear and both open the table. The first removes the row check entirely; the second keeps RLS on in name only and, because it has no to clause, applies to signed-out visitors too. We checked both on a Supabase-like Postgres: after either one, a visitor with only the public key reads every user’s notes. The weakness behind both is missing authorization (CWE-862 (opens in a new tab)), which is why this page carries that label even though the locked table itself leaks nothing.

How to find it in your app

The Security Advisor lists these tables as lint 0008 (rls_enabled_no_policy). This query in the SQL Editor shows the same and any comment that explains the table:

Tables with RLS on and no policies
select c.relname as table_name,
       obj_description(c.oid, 'pg_class') as note
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and c.relkind in ('r', 'p')
  and c.relrowsecurity
  and not exists (
    select 1 from pg_policies p
    where p.schemaname = n.nspname and p.tablename = c.relname
  )
order by 1;

For every table it returns, check your frontend code: if the browser reads or writes it with supabase.from("…"), it needs policies. If only an edge function or a database function with elevated rights uses it, the lockout is fine and you should document it (below).

How to fix it

Add the policies the app needs, in a new migration. For notes that belong to one user, one policy covers all four actions:

SafeFix: an owner policy for every action
revoke all on table public.notes from anon;

create policy "Owners manage their notes"
  on public.notes for all
  to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

using decides which existing rows the user may see, change and delete; with check decides which rows they may write, so nobody can create a note in someone else’s name. If read and write rules differ, write separate policies per action instead, as in the table without RLS fix.

If the table is server-only, keep it locked and make that visible:

SafeServer-only table: keep the lockout and say so
revoke all on table public.webhook_events from anon, authenticated;

comment on table public.webhook_events is
  'Server only: written by the stripe-webhook edge function with the secret key. No client policies on purpose.';

The table will keep appearing in the check, now with the note next to it.

Add the missing RLS policies

The table public.notes (replace with your table) has row level security enabled but no policies, so the app cannot read or save rows. Do not disable RLS and do not add a policy that is always true. Add a new Supabase migration that revokes all privileges on the table from anon and creates policies for the authenticated role only that allow select, insert, update and delete when (select auth.uid()) = user_id, with WITH CHECK on insert and update. If the frontend never queries this table, tell me instead of adding policies.

Check that the fix works

Act as a user, write a note and read it back, all inside a transaction that you roll back:

Check as a user
begin;
set local role authenticated;
set local request.jwt.claims = '{"sub": "11111111-1111-1111-1111-111111111111", "role": "authenticated"}';
insert into public.notes (body) values ('test note');
select count(*) as my_notes from public.notes;
rollback;

With a real user ID from Authentication → Users, the insert must succeed and the count must include the new note. Repeat with a second user: they must not see the first user’s notes. Then reload your app as a visitor and confirm the notes page asks you to sign in instead of showing data. For a fuller routine, see how to test your RLS policies, and never let an always-true policy be the answer to an empty list.

Frequently asked questions

Why does my Supabase query return an empty array instead of an error?

RLS filters rows silently. With no select policy, every row is filtered out, so the query succeeds with zero rows. Inserts are different: a new row that no policy allows is rejected with an error.

Is it safe to just disable RLS to make it work?

No. With RLS off, the table answers every request its grants allow, and with Supabase’s default grants that can include signed-out visitors. Add policies instead.

Can a table with RLS and no policies be correct?

Yes, if only your server touches it, for example a table that an edge function writes with the secret key. Then the empty policy list is deliberate. Revoke the client grants and leave a comment so nobody ‘fixes’ it later.

Why does the Security Advisor list this as info, not as an error?

Lint 0008 (rls_enabled_no_policy) is informational because nothing leaks: the API simply returns no data. It is a prompt to decide whether the lockout is intended.

Sources

  1. 1.Row Level Security — Supabase Docs
  2. 2.Performance and Security Advisors — Supabase Docs
  3. 3.Row Security Policies — PostgreSQL Documentation
  4. 4.CREATE POLICY — PostgreSQL Documentation
  5. 5.CWE-862: Missing Authorization — MITRE

Find this in your own app

ShipRely reads your repository (read-only), proves each finding with file and line, and gives you a fix prompt to paste into your AI builder.

Run a demo audit
  • Read-only access to your repository
  • Every finding with file and line
  • Fix prompts for Lovable, Cursor, Claude Code and Bolt