When you ship a Supabase app generated with Bolt, Lovable, or Cursor, the dashboard can show a green RLS badge on every table while your public anon key can still read every row.
That usually happens for one of four reasons:
- The AI ran
ENABLE ROW LEVEL SECURITYand then addedCREATE POLICY ... FOR SELECT USING (true)to make an early prototype error go away. - A
service_roleJWT or third-party API key landed in the compiled Vite/Next.js client bundle. - A Postgres view queries an RLS-protected table without
WITH (security_invoker = true), so the view executes with the owner's privileges and skips RLS. - A
SECURITY DEFINERfunction is missing a fixedSET search_path = ''.
Checking row exposure without downloading user data
If you want to verify what an unauthenticated visitor can read from your own deployed project without pulling a single byte of user PII into your terminal or logs, PostgREST supports HEAD requests combined with Prefer: count=exact.
First, list the exposed tables from the OpenAPI spec:
curl -s "https://YOUR_REF.supabase.co/rest/v1/" \
-H "apikey: YOUR_ANON_KEY" | jq '.paths | keys'
Then run a HEAD probe against each table:
curl -I -s "https://YOUR_REF.supabase.co/rest/v1/profiles?select=*" \
-H "apikey: YOUR_ANON_KEY" \
-H "Authorization: Bearer YOUR_ANON_KEY" \
-H "Prefer: count=exact"
Look at the response status and Content-Range header. If it returns 200 OK with Content-Range: */1284, any visitor holding the public anon key from your frontend bundle can read all 1,284 rows. Because the method is HEAD, the response body is empty and zero rows are transferred.
Automating the check before launch
Running those curls by hand gets tedious once a project has 10+ tables and several client JS chunks. I wrapped the exact HEAD count probe, client bundle secret scan, and static schema.sql parser into a free read-only web checker so you can sanity-check your own app in ~10 seconds without signing up:
https://rlsguard-rho.vercel.app
It supports two modes:
-
Live URL scan (with an ownership checkbox): reads public JS chunks for leaked keys and runs read-only
HEADcount probes against discovered PostgREST tables. -
Paste
schema.sql: checks locally for missingENABLE ROW LEVEL SECURITY,USING (true)policies, views withoutsecurity_invoker = true, andSECURITY DEFINERfunctions withoutsearch_path.
Quick SQL fixes for the two quietest bugs
For views that silently bypass RLS:
ALTER VIEW public.your_view SET (security_invoker = true);
For USING (true) policies on user-owned tables:
DROP POLICY IF EXISTS "allow_read_all" ON public.profiles;
CREATE POLICY "profiles_select_own"
ON public.profiles
FOR SELECT
TO authenticated
USING ((select auth.uid()) = id);
If you run the scanner on your own schema and hit a false positive or weird SQL syntax it misses, drop a comment and I will patch the parser.
Top comments (4)
The HEAD count only covers tables. A SECURITY DEFINER function reading the same table still shows up under /rest/v1/rpc. On Postgres 17 I had profiles return 0 rows to anon, revoked execute on the function from anon, and anon still got all 1284 emails through it, because EXECUTE is granted to PUBLIC by default.
revoke execute ... from publicclosed it.Good catch. The web HEAD probe only checks table paths, so it misses /rest/v1/rpc/* entirely. That default EXECUTE grant to PUBLIC in Postgres is easy to overlook if you only run REVOKE EXECUTE ... FROM anon, which is why the local SQL check flags SECURITY DEFINER functions and recommends revoking from PUBLIC first.
The HEAD probe is a neat trick — getting Content-Range: */1284 back with zero rows transferred turns a scary "is my data exposed?" question into a check you can run in seconds without touching user data. The USING (true) policy is the one I have seen most in AI-generated apps too: the AI fixes the prototype error by opening the door and nobody comes back to close it. Do you run this probe as part of your launch checklist now, or only when something smells off?
I run it as part of my pre-launch checklist now, right after applying migrations and before sharing the link. It takes about 10 seconds and catches leftover prototype policies before anyone else hits the endpoint. For local work before deploying, I usually run the schema.sql check first so the bad policy never makes it to production.