published fresh until

How do I prove one tenant can't read another's data in Supabase?

Summary As of November 2026, use pgTAP cross-user assertions under authenticated roles, then break each policy with a temporary using (true) policy and require a failure. Check returned rows, not just errors, and repeat through the app client. Start the local stack with supabase start

Not for Firebase Security Rules testing.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: Run supabase start and write cross-user policy assertions against the local database.

Short answer

Supabase's policy-testing guide requires a second user to attempt reading, updating and deleting the first user's rows on every user-data table. It also requires a deliberate policy break to demonstrate that the suite catches access widening. Policy-testing guide

What to do

1. List each role and operation that must be allowed or denied, with one test per rule. For organization-based tenancy, include organization membership and cross-organization data isolation in those rules. Advanced multi-tenant example Cover select, insert, update and delete as anon and authenticated. RLS guide 2. Use Supabase CLI v1.11.4 or later. Create a file with supabase test new todos_rls; the guide's file is supabase/tests/todos_rls_test.sql. Enable pgTAP with create extension if not exists pgtap with schema extensions. Wrap fixtures and assertions in begin and rollback, then run supabase test db. CLI testing, policy-testing example 3. Seed distinct users and their rows. Use set local role authenticated and request.jwt.claim.sub to select the actor for each assertion. Check returned rows with results_eq; the example uses is_empty on a cross-user update with returning to show that it changed nothing. Policy-testing example 4. Temporarily add a policy using using (true) on the same table. Run supabase test db and require an assertion failure; remove the temporary policy afterward. Removing the real policy is not a useful substitute: default denial can leave denial assertions passing. Agent testing rules 5. Repeat the boundary assertions through the application's Supabase client. Give each suite unique user IDs and clean up its data. A cross-user update can report no error while changing no rows, so read back the original user's rows to assert they are unchanged. Application testing 6. Run the database suite on pull requests. Supabase's CI example starts the local stack with supabase start, then runs supabase test db. Testing overview

Limits and open questions

Execute access assertions as client roles: table owners normally bypass RLS, and superusers or BYPASSRLS roles always bypass it. PostgreSQL

Views need separate attention: they bypass RLS by default; on PostgreSQL 15 or later, security_invoker = true makes the view follow underlying-table policies for client roles. Database-unit assertions and application-client assertions are distinct parts of Supabase's testing guidance. RLS guide, testing overview

Not for: Firebase Security Rules testing.

Sources

Checked

Primary pages checked 2026-11-30: Supabase’s Test Row Level Security policies with pgTAP, Advanced pgTAP testing, Row Level Security, Testing your database, and Testing overview; PostgreSQL’s Row Security Policies. We ran no command or code.

Started from a post by @igormiazek, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# How do I prove one tenant can't read another's data in Supabase?
Summary: As of November 2026, use pgTAP cross-user assertions under authenticated roles, then break each policy with a temporary using (true) policy and require a failure. Check returned rows, not just errors, and repeat through the app client. Start the local stack with `supabase start`
Copy for agent
get the whatworks thread prove-tenant-isolation-supabase-cross-tenant-tests and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread prove-tenant-isolation-supabase-cross-tenant-tests
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks