🔧 Unbreak My AppAll fixesError codesFix KitsSponsor

Fixes › Database / Supabase RLS

Supabase table has RLS disabled (public Data API access)

LovableBoltv0CursorReplit

Published

Weakness type: CWE-862 (Missing Authorization)

The error

Table Editor shows RLS disabled / anon key can read or write the whole table via REST / security scanner flags public table

Why it happens

Lovable, Bolt, v0, Cursor and Replit often CREATE TABLE without enabling Row Level Security. The anon (publishable) key is meant to be public, but with RLS off anyone who has it can call PostgREST and select/insert/update/delete every row. Shipping with the anon key and no RLS is the loudest security complaint about vibe-coded apps.

How to fix it

  1. In Supabase → Table Editor, open every table and turn RLS on (or run: alter table public.<TABLE> enable row level security;). Never leave RLS off in production.
  2. Add least-privilege policies for the operations your app needs: SELECT, INSERT, UPDATE, DELETE, typically scoped with auth.uid() = user_id for authenticated users.
  3. Grant anon access only when logged-out visitors must read specific public data; never give anon write access unless that is intentional and heavily constrained.
  4. If the table was public while live, assume data was exposed: export what you need, rotate the anon key (Project Settings → API), and audit for leaked rows.
  5. Repeat the audit for all tables (and storage.objects); AI builders often leave several tables open.

Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

Audit this Supabase project for tables (and storage buckets) with RLS disabled or missing policies. Enable RLS on every public-schema table used by the app. Do NOT leave RLS off. Add least-privilege policies for select/insert/update/delete that match how the app actually uses each table (owner-scoped with auth.uid() = user_id where applicable). Do not grant anon write access. Give me one idempotent SQL migration that enables RLS and creates the policies, list every table you changed, and remind me to rotate the anon key if any table was publicly readable in production.

Error codes this fixes

FAQ

Is the anon key the problem?

No. The anon key is designed to be public. The problem is missing RLS (or missing policies) so PostgREST allows unrestricted access.

Will enabling RLS break my app?

Yes, temporarily: once RLS is on with no policies, queries return empty or fail until you add matching policies. Add the policies in the same migration.

Sources

Based on the official documentation:

Related fixes

Want the full checklist for this area? Get a Fix Kit ($29)

Get one new fix a week

Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.

We only use your email to send the newsletter. Unsubscribe any time. See privacy.