Skip to content

Test with 2 real users whether one client can read another client’s data

Enter two user ids from your Supabase project. You get a read-only script for your own SQL Editor, and it returns what each user can read, table by table.

Your two test users

Find them in the Supabase dashboard under Authentication → Users. Pick users from different companies, each with some data of their own.

The script is built in your browser and your user ids stay there: this site only counts that a script was built. You need no password or key here, and only someone with access to the project’s SQL Editor can run it.

Read-only script → As user A / As user B → invoices / projects. No write is tried. 1 You run the script in your SQL Editor, read-only; 2 It reads every table as user A; 3 Then it reads every table as user B; 4 invoices: each user gets different rows, reads_separated; 5 projects: both get the same rows, shared_check_it; 6 Writes are not tested: try them by hand on a copy.
What the script does with your two users, and how a shared table shows up. Sample tables.

How to read the result

This test only reads. It tries no write, so reads_separated says nothing about whether one client can insert or change another client’s data. Test writes by hand, as the guide below shows.

VerdictWhat it means
anon_can_readAnyone with your public key can read rows here, with no sign-in. Fine for a public catalog, a leak for anything else.
shared_check_itBoth users read the same rows. Fine for a public catalog, a leak if those rows belong to a client.
view_check_itEach user gets different rows through this view or foreign table, which proves little. A view with its owner’s rights skips RLS, and a per-user column can hide shared rows. Read its definition by hand.
capped_check_itA user reads over 5,000 rows, so the comparison stopped at the limit and shared rows may sit past it. Compare on a smaller copy or by hand.
test_by_handA security definer function that signed-in users can call. It skips RLS, so call it by hand with the other company’s id.
one_user_sees_nothingOnly one user reads rows here, so nothing is proven yet. Give the other user a row, or check that its policy is not too tight.
neither_sees_rowsRows exist, but neither user reads any. These users may own none of them, the policy may rely on a custom access token hook or an MFA level, or it blocks everyone, including real clients.
empty_seed_itThe table is empty, so the test proves nothing. Add one row per company and run it again.
no_accessNeither user has a grant on this table. The app cannot read it as a signed-in user at all.
read_failedReading this object failed, for example a foreign table whose server did not answer or a view that tries to write. Check it by hand.
reads_separatedEach user reads different rows and none in common. This covers reading only: no write was tried. Open a few rows and confirm they belong to that user, because this test cannot tell whose rows they are.

What this test cannot see

It only reads tables and views in the public schema, as the anon role and as each user’s own role. It builds each user’s claims from their account, so claims from a custom access token hook or an MFA level will not match. Writes, adding yourself to another company, function arguments, Storage, Realtime and Edge Functions need their own attempts. The full list of paths is in the multi-tenant isolation test guide.

The test shows who can read what, not whether your app’s logic is right. If you need an engineer to close what it finds and keep running the product, write to yes@madsalt.tech.

Questions

Why a SQL script and not a login form?

A form would need real passwords, and anyone could point it at someone else’s app. The script needs neither: only the people who already run the project can use it.

Can the script change my data?

Not through this transaction: it switches to read-only before the first read, so Postgres refuses any write in it. A view that calls out over its own connection, with dblink for one, would still act as it does on any read. The script creates two temporary functions, which disappear with the session.

Does a clean result mean one client cannot write into another’s data?

No. The script never tries a write, because a test that writes does not belong on a live database. In my own test, 2 of 6 leaks were writes: joining another company and inserting an invoice into it. Those need their own attempts on a copy.

Is a shared table always a leak?

No. Plans, countries and other public lists are meant to be shared. Go through the flagged tables and ask whether a row belongs to one client.

How is this different from the Supabase security scanner?

The scanner reads settings and policies, so it cannot tell which company a row belongs to. This test reads as two real users and compares what each one gets.