Signs in to your Supabase project as two test users and as an anonymous visitor, then reports which tables and database functions show one user's data to a stranger or to the other user.
It finds the problems behind most Supabase data leaks in apps built with Lovable, Bolt, v0 or Cursor:
- RLS disabled. Anyone with the public key in your JavaScript bundle can read the table.
- Always-true policies (
using (true), or "any signed-in user"). Every customer can read every other customer's rows. - SECURITY DEFINER functions callable by anon. They skip RLS entirely.
- Optional write probes: whether user B can change or delete what user A created.
Safety rules
- Only run it against a project you own or are authorised to test, with test accounts you created. It refuses to start without
--i-own-this-project(orLEAK_TEST_I_OWN_THIS=1). - Read-only by default. Write probes are opt-in and only touch tables you name.
- It never prints or stores row values. Reports contain table names, column names and counts.
- It caps itself at 200 requests with a short delay between them. It is not a scraper.
- It refuses
service_role/sb_secret_keys. Those bypass RLS, and they should never leave your server.
Setup (5 minutes)
- In your app, sign up two test users with throwaway emails, in separate workspaces/teams (for example,
leaktest-a@yourdomain.comandleaktest-b@yourdomain.com). - As each user, create a little data through the app: a record or two in each main screen.
- Copy your project URL and anon / publishable key from Supabase: Project Settings → API.
Run
pnpm leak-test --i-own-this-project \
--url https://<ref>.supabase.co \
--anon-key <publishable key> \
--user-a leaktest-a@yourdomain.com:<password> \
--user-b leaktest-b@yourdomain.com:<password> \
--md leak-report.mdIf your project hides its API schema from public keys (good), add --tables invoices,clients,profiles,... with names from the Table Editor.
Write probes (creates and deletes one marker row per table you list):
pnpm leak-test ... --probe-writes --write-tables notes,commentsResidual risk: if your insert triggers send emails or call webhooks, the marker row will fire them. Use tables without side effects, or a staging project.
The exit code is 1 when there is any critical or high finding, so it can run in CI against staging.
Sample output
Against the deliberately broken "before" app in this repo: evidence/leak-test/before-report.md. Against the hardened version: evidence/leak-test/after-report.md.
If it finds something
- Anonymous read: turn on RLS for that table, then add policies that name the owner. Supabase: Row Level Security
- Cross-user read: replace
using (true)with an ownership or membership check, and wrapauth.uid()as(select auth.uid())for speed. Never authorise withuser_metadata, which users can edit. - Function callable by anon:
revoke execute ... from anon, public. Prefersecurity invoker, and pinsearch_path. - Run the Security Advisor in the Supabase dashboard (Database → Advisors) and clear every ERROR. Supabase: Database Advisors
- If a
service_rolekey was ever in your frontend or repo, rotate it. Supabase: API keys
This test covers the most common leaks. It is not a full audit: Storage buckets, Edge Functions, Stripe webhooks and business logic need a human review.