All guidesSupabase RLS and keys

Supabase tenant isolation

How do I test tenant A cannot read tenant B data?

By Ohad Krispin, founder of VibeRaven · LinkedIn

Short answer

Seed two organizations and one signed-in member in each on a local Supabase stack. Using each user's own session, verify that their organization query returns the seeded record and that an explicit query for the other organization returns zero rows or your documented denial.

Next step in your repo: run

npx -y viberaven check
.

For Vercel + Supabase apps, run this at the app root to flag missing RLS or broadly permissive policies in migrations. It is advice, not a gate, and a repository check, not a live database test. Use the fixture below to verify membership through the app.

On this page

Why keep the two identities separate?

Our October 2026 static study of 512 public Lovable repositories with Supabase migrations found seven additional projects with a write policy that allowed any signed-in user to update or delete whole tables. The study inspected files, so use your own fixture to check how your membership policy behaves. See the evidence

Test two tenant memberships

  1. 1
    On a local Supabase stack, create two organization records, one ordinary member per organization and one private record per organization. Give the records distinct IDs and use the same membership shape that your production migrations define.
  2. 2
    Sign in to separate local clients or browser contexts with the two test accounts. Keep the same publishable key and user-scoped client that your app uses. With each account, first check that its own seeded record is present.
  3. 3
    Request the other organization by its seeded ID through the same app route or Data API request. Assert the denial your app documents. For an RLS-filtered SELECT, assert an empty result and check that the same query still returns the row to its owner.
  4. 4
    If a user can belong to multiple organizations, repeat with a user who belongs to both, then remove one membership and check that access to only that organization goes away. Repeat through the app client as well as any pgTAP suite.

Official docs behind this checklist

FAQ for builders before launch

Can I test tenant isolation without production data?

Yes. Apply your checked-in migrations to a local Supabase project and seed fake organizations, users and memberships. Use the production policy shape with test records and credentials.

Why check that the member can read their own record first?

An empty result from the other tenant is meaningful only after a control proves the row exists and the normal user path can read allowed rows.