VibeCodeHealth

supabase

Can strangers read my Supabase tables? How to verify RLS with the anon key

Prove whether the public anon key can SELECT your Lovable/Bolt/v0 tables with a three-row PostgREST curl, fix open RLS policies, and re-scan with the free grader that now checks this automatically.

Paste your production URL into the free Vibe Code Health grader for a Semrush-style score on secrets, headers, TLS, and common leaks—then come back to this guide for the fixes.

You shipped a Lovable or Bolt app with Supabase. Auth works. The Table Editor shows rows. You never put service_role in the browser. So you assume the data is locked.

Here is the check almost nobody runs before sharing the link: open a private window, take only the public anon key from your page, and ask PostgREST for three rows. If JSON comes back with other people’s data, strangers can do the same thing—no password, no magic exploit, just the same credentials your frontend already publishes.

This guide is about proving whether unsigned visitors can SELECT your tables in vibe-coded apps (Lovable, Bolt, v0, Replit, Cursor + Supabase). It is not the mental-model RLS tutorial (RLS for beginners) and not the anon-vs-service_role key explainer (Supabase keys). Those teach the locks. This post teaches the smoke test—and how Vibe Code Health now runs a capped version of that test for you.

Why “I used the anon key” is not the same as “my tables are private”

Supabase’s model is intentional: the anon (publishable) key belongs in the browser (API keys). That key only means “talk to my project as the anon Postgres role.” What anon can read is decided by grants and Row Level Security, not by the key string looking “public.”

Official docs warn hard: a table in an exposed schema without RLS can be read and written by any role that still has grants on it (Row Level Security, Securing your API). Grants are checked first; policies second. A missing grant fails loudly. A missing policy (with RLS on) often fails quietly as []. RLS off with default grants is the silent dump.

AI builders optimize for demos. A common scaffold:

  1. You say “add profiles and a messages feed.”
  2. The model creates tables, wires supabase.from("profiles"), and adds a policy like USING (true) “so the list shows up.”
  3. Or RLS never gets enabled because the SQL Editor path skipped the Dashboard default.
  4. You paste the production URL into a launch channel. Anyone can open DevTools, copy NEXT_PUBLIC_SUPABASE_URL + the anon JWT, and call the Data API the same way your app does.

Minification does not hide those strings. They are supposed to be there. Your policies are the product.

Two minutes: prove it with curl (your project only)

Only test apps you own or have permission to test. Copying someone else’s anon key to dump their tables is not OK.

SUPABASE_URL="https://YOUR_PROJECT.supabase.co"
ANON_KEY="eyJ…your-anon-jwt-from-the-browser…"

curl -sS -D - \
  "$SUPABASE_URL/rest/v1/profiles?select=*&limit=3" \
  -H "apikey: $ANON_KEY" \
  -H "Authorization: Bearer $ANON_KEY" \
  -H "Accept: application/json"

Repeat for every table your UI touches (messages, orders, todos, invoices, …). Read status and body separately:

ResultWhat it usually means
200 + JSON array of rowsanon can SELECT those rows. If that was not intentional public data, fix RLS/grants now.
200 + []Grant exists and RLS matched nothing—or the table is empty. Empty is not proof of safety.
401 / 403 or Postgres 42501Permission denied. Healthy for private tables.
Schema / PGRST205 errorsWrong name or table not exposed—fix the name before you change policies.

Optional: add -H "Prefer: count=exact" and inspect Content-Range. A range like 0-2/128 means 128 rows are visible to anon even though you only asked for three (PostgREST-style Data API).

You do not need the Dashboard for this proof. PostgREST is the same /rest/v1/ surface the JS client uses.

What Vibe Code Health checks automatically

Paste your live URL into the free scanner. When the grader finds a Supabase project URL and an anon JWT in HTML/JS, it:

  1. Still notes that anon in the client is expected (informational)—same as before.
  2. Passively lists Storage buckets when possible (public Storage buckets guide).
  3. New: mines .from("table") calls from your client bundles (skipping storage.from("bucket")), then issues read-only GET /rest/v1/{table}?select=*&limit=3 with that same anon key.

If rows come back, you get a backend finding such as Anon key can read rows from your Supabase tables or the stronger user/PII-style tables variant (profiles, messages, orders, and similar names). Evidence lists table names and column names—not cell values. Open tables also participate in the grade’s exposure cap (max D), same family as exposed .env / listable Storage.

We never use service_role, never guess tokens, and never write. Details live on /bot and the /learn glossary (RLS, JWT).

Important limitation: [] does not create a “pass.” An empty open table and a locked table can look identical over the wire. Populate a throwaway row in a staging project, or use the Dashboard policy tester, when you need certainty.

The fix: enable RLS, default deny, then scope

Step 1 — Turn RLS on

In Supabase → Authentication / Policies (or SQL):

alter table public.profiles enable row level security;
alter table public.messages enable row level security;
-- repeat for every table the client calls via .from("…")

Tables created in the Dashboard often already have RLS on. Tables created only in the SQL Editor often do not—check explicitly (RLS docs).

Step 2 — Remove “open the floodgates” policies

Delete or rewrite policies that look like:

-- ❌ Makes every row world-readable to anon
create policy "public read all"
  on public.profiles
  for select
  to anon, authenticated
  using (true);

USING (true) is fine for a truly public catalog (published blog posts, a marketing FAQ). It is a data incident for profiles, DMs, and orders.

Step 3 — Owner-scoped policies for private data

-- Authenticated users read/update only their own profile row
create policy "read own profile"
  on public.profiles
  for select
  to authenticated
  using (auth.uid() = id);

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

-- Messages: sender or recipient only (adjust column names to yours)
create policy "read own messages"
  on public.messages
  for select
  to authenticated
  using (
    auth.uid() = sender_id
    or auth.uid() = recipient_id
  );

Keep grants tight too. On many projects, anon and authenticated still receive broad default privileges; revoke what you do not need and grant only the operations each role should have (Securing your API).

Step 4 — Lovable / Bolt / v0 / Cursor prompt

Paste into your builder after you enable RLS in the Dashboard:

Enable Row Level Security on every table the client queries. Remove USING (true) policies for anon unless the data is intentionally public. Add auth.uid()-scoped SELECT/UPDATE policies for authenticated users. Do not put service_role in the browser. Keep using the anon key in the client.

Then re-run the curl check and re-scan.

Intentional public tables vs accidents

Not every 200 + rows finding is wrong. A public product list, a published recipe feed, or a marketing “testimonials” table can legitimately allow anon SELECT. When the scanner flags those:

  1. Confirm the columns contain no emails, phone numbers, or internal IDs you would not put on a webpage.
  2. Prefer a narrow column list in the client (select("id,name,price")) even when rows are public.
  3. Keep user tables on a different policy set—never reuse USING (true) as a template for profiles.

If you meant private and the API still returns rows, treat disclosed values as exposed. The anon key itself usually does not need rotation (it is designed to be public); access rules do.

How this fits the rest of your launch checklist

LayerWhat “locked” meansRelated guide
KeysAnon in browser OK; service_role neverSupabase keys
Table RLSAnon curl returns [] or deny for private dataRLS for beginners
StoragePrivate buckets + signed URLs for user filesPublic Storage buckets
Headers / HTTPSCSP, framing, HSTS on the real hostSecurity headers

Skim /learn for how grades and glossary terms fit the report, and the platform pages under /for if you ship on Lovable, Bolt, v0, or Replit.

Quick FAQ

Does a good grade mean RLS is perfect?
No. Passive checks cannot invent a login as every user. Rows returned to anon are strong evidence of oversharing; silence is inconclusive.

Will the scanner download my whole database?
No. It caps tables mined from your own JS and requests limit=3. Reports store finding codes and masked evidence, not raw row payloads (/bot).

I got []—am I safe?
Not proven. Insert a test row you own, retry anon curl, or use the policy helper in the Dashboard.

Ship the locks, then share the link

Anon in the browser is normal. World-readable profiles is not. Run the three-row curl on every table your UI touches, fix RLS and grants until private tables refuse strangers, then paste your URL into Vibe Code Health and confirm the open-table findings are gone. That is the difference between “the demo worked” and “I can defend this in front of a user.”

Grade your app next

Passive scan only—no login, no crawl of your whole site.

Open the scanner

Platform checkers

Free A–F grades written for the host you ship on.