Stack

How to security test a Supabase app

Updated

Test Supabase by talking to PostgREST with the anon key exactly as the browser does: if row level security is off or a policy is permissive, the table is public. Then check whether the service-role key shipped to the client, which bypasses RLS entirely.

Where this class of bug actually lives in a Supabase project

  • Tables without RLS. RLS is off by default on new tables; a table created after the initial setup usually has none.
  • Policies that are always true. USING (true) on select, or a policy written against auth.uid() that is null for anon and still passes.
  • The service-role key in the client. One NEXT_PUBLIC_ or VITE_ variable with that key and every RLS policy is irrelevant.
  • Storage buckets. A public bucket serves every file to anyone with the URL, and object paths are guessable.

What to try first

  1. With the anon key, GET /rest/v1/<table>?select=* for every table you can name — the OpenAPI root at /rest/v1/ lists them.
  2. Grep the built JS bundle for service_role and for eyJ JWT prefixes.
  3. List storage buckets and try to read a known object path.
  4. Sign in as a second user and repeat the reads to see whether the policy scopes by user.

A reproduction you can keep

The anon-key read is the whole test. No session, no user:

Read a table with the public anon key
curl -sS 'https://<project>.supabase.co/rest/v1/invoices?select=*&limit=5' \
  -H 'apikey: <anon-key>' \
  -H 'Authorization: Bearer <anon-key>'

# vulnerable: rows from every tenant
# fixed: [] — RLS filters everything for anon

# and check what the client ships
grep -o 'service_role' dist/assets/*.js | head

What "fixed" has to look like

Enable RLS on every table and write policies against auth.uid() and the tenant column, so an anon read returns an empty array and a signed-in user sees only their rows. The service-role key must never appear in a client bundle — confirm by grepping the built output.

Where people get this wrong

  • auth.uid() is null for anon requests and for requests made with a key that is not a user token, so a policy that only compares columns can pass for anon.
  • RLS does not apply to the service role. That is the point of it, and the reason a leaked key is total.
  • A public storage bucket ignores table policies entirely.

What Offense does here

Offense runs an agent swarm against your app in a disposable sandbox, keeps the request, the identity and the vulnerable response as evidence, and replays the same attack after the fix so the retest is a control comparison rather than a green check. It does not read your source and it does not patch your code: the finding goes to your coding agent with the reproduction attached. The hosted workspace is invite-only — join the waitlist — and the free dependency audit in /install needs no account.

Questions this page answers

Is Supabase secure by default?

Authentication is. Authorization is not: a table without RLS is readable by anyone holding the anon key, which every client ships.

What does a leaked service-role key let an attacker do?

Everything the database allows, across all tenants, with RLS bypassed. Rotate it immediately if it was in a client bundle.

Written by Offense Research, reviewed December 2, 2026. Correct something? Email imran@offenseresearch.com.