Cenk Kurtoğlu©26

Supabase security · 7 minute read

What a free anon-key check can — and cannot — prove about your Supabase tables

There is a healthy genre of free tool that points at your project URL, fires REST reads with the public anon key, and reports each table that answers without a login. Run it, get a green list, close the tab. The tool is honest about what it does — but the result is routinely read as "my RLS works", and that conclusion does not follow. This article separates the one thing the check proves from the four access paths it structurally cannot see, with the query set that covers each.

What the check actually proves

The probe is a single shape of request: GET on /rest/v1/<table> with apikey: <anon key> and no session. That request exercises exactly one combination: the anon role, the SELECT privilege, PostgREST (not storage, not functions), unauthenticated. When a table answers with rows, the finding is real and worth acting on: either RLS is off on that table, or a policy grants select to anon / public. When it does not answer, you have learned that unauthenticated REST SELECT is denied. That is the entire content of a green result.

It is a genuinely useful signal — the check finds real exposure, and it is the first thing an attacker runs. It is also the first thing only an attacker runs. Everything below happens after it.

The four paths the check never touches

1. Authenticated cross-user reads

The anon check cannot sign in. So a database where every policy reads auth.uid() = user_id — and one table where that predicate is missing — passes the check completely: unauthenticated reads are denied, every signed-in user reads every other user's rows. The policy set that fails at runtime almost always passes a green anon probe, because the failure is in the authenticated branch of the logic, and the probe never gets there.

Find it without another account:

-- tables with an RLS policy whose qual does not reference the
-- authenticated user at all — the classic "any signed-in user reads
-- everything" shape
select n.nspname as schema, c.relname as table, p.polname
from pg_policy p
join pg_class c on c.oid = p.polrelid
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and p.polcmd in ('r', 'a')               -- SELECT or ALL
  and (p.polqual is null or p.polqual = 'true');

Then prove it at runtime with two sessions — the same row read as user A and user B returns identical data. The full identity matrix (anon, owner, second tenant, expired token, service_role) is in why RLS tests pass and data still leaks.

2. Writes, deletes and grants that survive your policies

A read-only probe sees SELECT. RLS filters rows; it does not revoke table privileges, and an INSERT with no WITH CHECK — or a WITH CHECK of true — lets any client write into a table the probe says is closed. The pattern: USING constrains where a row starts, WITH CHECK constrains where it ends. An UPDATE policy with a correct USING and no WITH CHECK passes any read test and lets every user reassign any row. The query that surfaces those:

-- update/insert policies with no usable check expression
select c.relname as table, p.polname, p.polcmd
from pg_policy p
join pg_class c on c.oid = p.polrelid
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public'
  and p.polcmd in ('a', 'w')
  and (p.polwithcheck is null or p.polwithcheck = 'true');

Grants matter independently: an anon role still holding INSERT on a table is a write path no SELECT probe can ever detect. Census of effective grants:

select table_name, privilege_type
from information_schema.role_table_grants
where grantee in ('anon', 'authenticated')
  and table_schema = 'public'
order by table_name, privilege_type;

3. SECURITY DEFINER functions run as their owner

PostgREST exposes functions as RPC endpoints. A SECURITY DEFINER function executes with its owner's privileges, skipping RLS entirely — so a green anon check on every table says nothing about a function that returns rows from all of them. This is the bypass that survives the most audits, because table-level review and function-level review are usually done separately, and only one of them is what the checker sees.

-- definer functions: their body is your real attack surface
select n.nspname, p.proname, pg_get_userbyid(p.proowner) as owner
from pg_proc p
join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public'
  and p.prosecdef;   -- SECURITY DEFINER

Also check search_path on each: a definer function without a pinned search_path can be redirected through a schema the caller controls. The definer path and its fix are covered in the first 15 minutes of an audit.

4. Storage buckets, and metadata leaks that are not reads

The REST probe does not query storage.objects. A public bucket serves every file it holds to anyone with the URL — the anon key check cannot see that, because the request is shaped differently. List buckets whose exposure is wider than intended:

select id, name, public
from storage.buckets
where public;   -- everything in these buckets is downloadable
                       -- by anyone with the link

And the subtle one: enumeration is not the same as access. A 200 and a 403 differ in timing and message on many endpoints; a table can leak its existence, column names, or approximate row count through error differences while returning no rows. The checker counts that as "closed", and it is right that no data came back — but a "closed" table that returns different errors for existing and non-existing columns is still an information channel.

What a complete check adds

None of this makes the free anon check bad — it makes it one of six steps. The set that actually answers "is my database closed?":

  1. Anon REST read per table (the free checker's job).
  2. Second-identity REST read: sign in as two users, compare row sets. Catches cross-user policy gaps the anon probe cannot express.
  3. DML probe per table: INSERT a row and read it back as the other identity, then UPDATE it with a tampered owner column. Catches missing WITH CHECK.
  4. Definable-function and grants census (the two queries above), plus a read of every definer body.
  5. Storage bucket census and a download attempt on one object per bucket.
  6. Client bundle scan: the anon key ships in the browser by design — check whatelse ships next to it. A service_role reference in the bundle outranks every finding in this list.

Steps 2–6 are exactly the runbook in the $29 self-run audit kit (commented SQL census, two-user DML tests, report and fix-SQL templates). If you want the run with evidence per finding — query, role, pass/fail — the fixed-price review is 48 hours.

The one-line version

A free anon check proves the unauthenticated case only. The exposures that survive it — authenticated cross-user reads, writes without WITH CHECK, definer functions, public buckets — are not theoretical; they are the shapes that show up in most real reviews, and none of them are visible from a single read-only request. Green on the free check means: keep going, not: done.

Template bundle

Review all 20 frontend starters in one bundle

20 editable frontend starters with live demos are $79 — one payment, no subscription.

View the Bundle — $79↗