CapLeak / Guides

Supabase RLS checker: find your open tables

Get a free outside-in score for your app. Then use the SQL below to check every table's Row Level Security yourself.

Scan your app freeFree score in seconds. No password, no card.

Short answer: run two queries in the Supabase SQL editor: one lists every table in public with its RLS status, the other lists every policy and what it allows. Any table with RLS off, or a policy that says true on private data, is readable with the public anon key your app ships. Then prove it with a "stranger test": request a row using only that key. Fix by enabling RLS and writing policies that match auth.uid().

Why RLS is the whole lock

Many AI-built apps that use Supabase query it straight from the browser using the anon (publishable) key. That key is public by design. Row Level Security is the rule set that decides what that key can actually read and write. Turn it off, or write a policy of true, and the key becomes a pass to the whole table.

Check 1: which tables have RLS off

In your Supabase project's SQL editor, run:

select tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;

Every row with rowsecurity = false is open to the public key, unless you've removed that role's privileges on it. Supabase's Security Advisor also reports tables with RLS disabled.

Check 2: which policies are too loose

select tablename, policyname, cmd, roles, qual, with_check
from pg_policies
where schemaname = 'public'
order by tablename;

Read the qual (who can see a row) and with_check (what can be written) columns:

  • true with role anon or public: anyone on the internet passes. Fine for a blog posts table, wrong for profiles, orders or messages.
  • true with role authenticated: any signed-in user sees every row. If sign-up is open, that's effectively anyone.
  • An insert or update policy with an empty with_check: users may be able to write rows that belong to someone else.
  • No policies at all on an RLS-enabled table: locked for the anon and authenticated roles. Safe, but the app may break.

Check 3: the stranger test

Policies can look right and still leak. Ask the API directly with only the public key and no login:

curl "https://YOUR-PROJECT.supabase.co/rest/v1/orders?select=*&limit=1" \
  -H "apikey: YOUR_ANON_OR_PUBLISHABLE_KEY"

Repeat for each table that holds user data. [] or a permission error is good. A real row means a stranger can read it. Only test projects you own.

How to fix open tables

Private, per-user data

For a table with a user_id column that stores the owner's id:

alter table public.orders enable row level security;

create policy "Owners read their orders"
  on public.orders for select to authenticated
  using ( (select auth.uid()) = user_id );

create policy "Owners create their orders"
  on public.orders for insert to authenticated
  with check ( (select auth.uid()) = user_id );

Add update or delete policies only if the app needs them, each with the same auth.uid() condition.

Content that really is public

Make the rule narrower than true where you can, for example only published rows:

create policy "Anyone reads published posts"
  on public.posts for select to anon, authenticated
  using ( published = true );

Remove the loose policy

drop policy "Enable read access for all users" on public.orders;

Use the exact policy name from Check 2. Then run Checks 1–3 again and click through your app signed in as a normal test user.

Or ask your AI builder

List every table in the public schema with its RLS status and policies. Enable RLS on all of them. For tables with user data, replace any policy using "true" with policies that only allow rows where auth.uid() matches the owner column, and add with check on insert and update. Keep public read access only for tables I confirm are public. Show the SQL before running it.

What CapLeak checks here

CapLeak does a version of the stranger test from the outside. When it finds your Supabase project URL and public key in your app's code, it asks Supabase, with that public key only, how many rows each table would return. It checks up to 20 tables: the ones your code refers to, plus Supabase's public table list if your project exposes it. It's a count-only request, so no row is ever downloaded, and a table only counts as a problem when it would really return rows to a stranger. The free score shows the result as Problem found or No problem found under "Database (Supabase) access". It also flags a leaked service_role or sb_secret_ key, which bypasses RLS entirely.

The $12 full report (one time, per app) shows where each issue is, with a plain-English fix and a copy-paste prompt for Lovable, Bolt or Cursor, right after checkout. The deep part (database tables, hidden files like .env and .git, and source maps) is added after a quick ownership check, which takes about a minute. CapLeak can't read your policies, so run Checks 1 and 2 above as well. If you find a service_role key in your frontend, see Exposed Supabase service_role key: what to do. To keep an app watched every week, Watch is $15 a month per app and Unlimited is $39 a month for up to 25 apps, with no report needed first.

CapLeak runs passive checks only. A passing grade means none of its checks failed; it is not a guarantee of security.

FAQ

Row Level Security, answered.

How do I know if RLS is enabled on my Supabase tables?

Run select tablename, rowsecurity from pg_tables where schemaname = 'public' in the SQL editor, or run Supabase's Security Advisor. Any table with rowsecurity false is not protected by Row Level Security.

Is a policy using true always wrong?

No. It is fine for content that is meant to be public, such as published blog posts. It is wrong on tables with user data, because anyone with your public anon key can read every row.

Why does my app break after I enable RLS?

With RLS on and no matching policy, the anon and authenticated roles get no rows. Add a policy for each action the app needs, scoped with auth.uid(), and test again.

Does the service_role key respect RLS?

No. The service_role key and the newer sb_secret_ keys bypass Row Level Security, which is why they must stay on a server or in Edge Functions.

Does CapLeak's free score check my Supabase tables?

Yes, from the outside. Using only the public key your app ships, CapLeak asks Supabase how many rows each table would return (count only, no rows downloaded) and shows Problem found or No problem found for database access. The $12 full report adds the details and fixes. It can't read your policies, so check those with the SQL above.

Check the outside while you fix the inside.

Free score in seconds. No password, no card.

Get my free score