Home / Guides / How to enable Supabase Row Level Security (RLS)

How to enable Supabase Row Level Security (RLS)

Step-by-step: turn on RLS, write auth.uid() policies, and verify strangers cannot read your tables.

Uses 1 of your 3 free scans today; a site scanned in the last 24 hours answers from that scan. Passive and read-only: we only look at what any browser can see. Only check sites you own or may test.

What the free scan checks

  • Leaked keys in your live JavaScript (AI, payment and cloud keys), including a Supabase service_role key
  • Files that should never be public, like /.env and /.git
  • Supabase and Firebase secrets in the browser: an sb_secret_ key, a Supabase access token or a Firebase service-account file
  • HTTPS and security headers (CSP, HSTS, clickjacking protection)

It only reads what any visitor's browser can see. It doesn't log in, read your tables or check App Check.

Threat brief · updated Oct 22, 2026

What it is: a Supabase table that answers the public anon key with real rows because Row Level Security is off or a policy is too open (for example using (true)).

Who's affected: apps that talk to Supabase straight from the browser, which is how Lovable, Bolt and many AI-built apps are wired. The anon key is meant to be public; RLS is what protects the data. A table created in the dashboard or by a migration without RLS is the usual gap (see CVE-2025-48757).

Safe self-check

Run this yourself, against your own project, with the anon key your app already ships. It reads at most one row.

Terminal
curl -s "https://YOUR_PROJECT.supabase.co/rest/v1/YOUR_TABLE?select=*&limit=1" \
  -H "apikey: YOUR_ANON_KEY"

A permission error means the anon key can't read that table. [] means no rows came back: if the table has rows, RLS is hiding them from anonymous visitors; if it's empty, this test tells you nothing yet. Any row coming back means anyone with your anon key, which is public, can read it: turn on RLS and add owner-only policies (how to enable Supabase RLS). Repeat for each table. This checks anonymous reads only, not writes or what signed-in users can see.

The free scan below doesn't query your database. It shows whether a key that bypasses RLS leaked, plus whether Supabase and its anon key are in your code. The paid table check needs ownership verification (Fix Pack) and covers up to 12 tables named in your app's code.

Row Level Security is Postgres's per-row access control. With Supabase, the public anon key is meant to be in the browser — safety comes from RLS, not from hiding that key.

Enable RLS on every table

alter table public.profiles enable row level security;

Or in the dashboard: Table Editor → table → toggle RLS enabled.

Typical owner-only policies

create policy "select own" on public.profiles
  for select to authenticated
  using (auth.uid() = id);

create policy "update own" on public.profiles
  for update to authenticated
  using (auth.uid() = id)
  with check (auth.uid() = id);

create policy "insert own" on public.profiles
  for insert to authenticated
  with check (auth.uid() = id);

Avoid using (true) on tables with personal data — that means "everyone can read."

After Oct 30, 2026, if your app shows 'permission denied for table', grant only the tables and roles it needs and keep RLS on. Don't bulk-grant all tables to anon. Supabase changelog.

Verify

  1. Supabase → Advisors → Security Advisor.
  2. From an incognito window (logged out), try the REST API with only the anon key. You should get empty results or 401/403, not other users' rows.

Official docs: Supabase RLS guide.

Copy-paste into your AI builder
Enable Row Level Security on every public table. Add SELECT/INSERT/UPDATE/DELETE policies so a user can only touch rows where auth.uid() equals the owner column (id or user_id). Never use USING (true) on tables with PII. Never put the service_role key in the frontend.

Related: Anon key explained · service_role exposure · How to test Supabase RLS · Security Advisor warnings explained

Scan your app free

Paste your URL. ShipLatch checks for leaked keys, exposed /.env and /.git, and flags Supabase/Firebase so you know what to lock down. The free scan finds the issues; the $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.

Scan free at shiplatch.com → See the Fix Pack

Questions

Is the Supabase anon key a secret?

No. It's meant to be in your frontend. What protects your data is Row Level Security on every table. The key that must never be public is the service_role or sb_secret_ key, because it bypasses RLS.

How do I check if my Supabase table is publicly readable?

Call your table's REST endpoint with only the anon key, logged out, as shown on this page. If rows come back, anyone can read them. Turn on RLS and add owner-only policies.

Want the whole pre-launch process in one place? See what's inside App Security for Vibe Coders, our $9 PDF playbook, or go straight to checkout.

More guides