Sample alert How it works Coverage PENTEST METHODOLOGY DOCS PRICING FAQ MCP CONTACT LOG IN SCAN MY APP →

How to test multi-tenant data isolation

GUIDE / TENANT ISOLATION

To test multi-tenant data isolation, create two tenants with marker data. Then try to reach the marker data of tenant A from tenant B in every place the app stores data. Test the database, caches, search and vector indexes, file storage, background jobs, exports and analytics. A passing API test does not prove isolation, because data leaks through these other layers.

What is the scope of this test?

This guide tests the data layer. It looks at what the app stores and how it scopes that data. The request layer is a different test. For IDOR, role checks and token tampering, see how to test broken access control. For role matrices, see SaaS privilege escalation.

Run both tests. A request can pass the API check and still read a shared cache that has no tenant in its key.

How do you build a two-tenant test fixture?

A fixture is a fixed set of test data. Build it once, and use it for each test below.

  1. Create tenant A and tenant B. Use two separate sign-ups, not two users in one tenant.
  2. Add one admin and one member to each tenant.
  3. In each tenant, create one object of each type: a record, a file, a document for search, a report and a webhook.
  4. Give every object a unique marker in a text field. Use MARKER-A-0001 for tenant A and MARKER-B-0001 for tenant B.
  5. Save the IDs, the tokens and the markers in one file.

The marker is the key idea. If MARKER-A appears anywhere in a response, a job output, an email or a log line that tenant B sees, you found a leak. You do not need to read the data. You only search for the marker.

How do you test Postgres and Supabase RLS?

RLS (Row Level Security) makes the database filter rows by policy. In Supabase, the browser can reach the database through the public API, so RLS is the main control. See the Supabase RLS guide for the policy basics and the Postgres RLS documentation for the full rules.

Step 1: Find tables with no RLS

Run this query as an admin in the SQL editor.

select c.relname
from pg_class c
join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind = 'r' and not c.relrowsecurity;

Each row is a table that has no RLS. If the table holds tenant data and the public API exposes it, that is a finding.

Step 2: Read the policies

select tablename, policyname, cmd, qual, with_check
from pg_policies where schemaname = 'public' order by tablename, cmd;

Examine each policy with these questions:

  • Is the condition true, or only auth.uid() is not null? Any signed-in user passes.
  • Does the policy read the tenant from user_metadata? The user can edit that field.
  • Is there a policy for each of select, insert, update and delete? A missing delete policy is common.
  • Does the with_check clause stop a user from writing a row with another tenant’s org_id?

Step 3: Run queries as tenant B

Do not trust the policy text. Run real queries with the identity of a tenant B user. Use a transaction, and roll it back.

begin;
set local role authenticated;
set local request.jwt.claims = '{"sub":"USER_ID_OF_B","role":"authenticated"}';

select count(*) from invoices where org_id = 'ORG_ID_OF_A';
select * from invoices where note like 'MARKER-A%';
insert into invoices (org_id, note) values ('ORG_ID_OF_A', 'written by B');
update invoices set note = 'changed by B' where org_id = 'ORG_ID_OF_A';
rollback;

The expected result is zero rows for select, and an error or zero affected rows for the write queries. Any other result is a finding.

Step 4: Test the paths that skip RLS

  • Views. A Postgres view runs with the rights of its owner by default. It can bypass RLS. Check each view that reads tenant tables. In Postgres 15 and later, create the view with security_invoker = true.
  • Functions. A security definer function runs with the rights of its owner. Call each one through RPC as tenant B and check that it filters by tenant.
  • The service role key. This key bypasses RLS. If it appears in the browser bundle, isolation is gone. See the service role leak pattern.
  • Direct API calls. Call the Supabase REST API with the public key and the token of B.
curl -s "$SUPABASE_URL/rest/v1/invoices?org_id=eq.ORG_ID_OF_A&select=id,note" \
  -H "apikey: $ANON_KEY" -H "Authorization: Bearer $TOKEN_B"

The result must be []. For the key test in detail, see the anon key guide.

How do you test shared caches and cache keys?

A cache stores the result of a request so the next request is fast. If the cache key does not contain the tenant, tenant B can get the cached answer of tenant A.

  1. Find the cache layers. They include a CDN, a reverse proxy, Redis, an in-memory cache and a framework cache such as unstable_cache.
  2. As tenant A, request a page or an API response that contains CACHE-A.
  3. As tenant B, request the same URL at once.
  4. Search the response for CACHE-A.
curl -s -H "Authorization: Bearer $TOKEN_A" "$BASE/api/dashboard" > /dev/null
curl -s -H "Authorization: Bearer $TOKEN_B" "$BASE/api/dashboard" | grep -c "CACHE-A"

The count must be 0. Read the Cache-Control, Age, Vary and X-Cache headers on the response. A private response must have Cache-Control: private or no-store. A shared cache must not store a response that depends on the Authorization header or a cookie, unless Vary lists it.

Also read the cache keys in Redis if you have access. A key such as dashboard:42 has no tenant. A key such as tenant:ORG_ID:dashboard:42 has one.

How do you test search and vector indexes?

Search engines and vector databases are separate stores. They do not use your RLS policies. The app must add the tenant filter to each query.

  1. Index one document for each tenant. Put VECTOR-A in the text for tenant A.
  2. As tenant B, search for the exact marker and for a close paraphrase.
  3. Ask the RAG chat a question whose answer exists only in the document of tenant A.
  4. Check the citations and the source links in the answer.

If the answer or a citation contains VECTOR-A, the retrieval step does not filter by tenant. Test the paraphrase too, because a vector search finds text by meaning and not by exact words.

Check how the index is built. A filter that the client sends, such as ?tenant=, is not a control. The server must set the filter from the session. Also examine these cases:

  • A shared index with a tenant_id field. The filter must be in every query path, including autocomplete and “related” results.
  • A shared embedding cache. The cache must be scoped by tenant.

The RAG poisoning pattern covers a different risk, which is hostile content in the index.

How do you test file storage paths and signed URLs?

File storage often has its own access rules. Examine the path and the URL.

Check Test Finding if
Path layout Does the path contain a tenant ID, such as tenant-id/file.pdf? All files are in one flat folder
Guessable names Change the file name in the URL to another known name Tenant B can open the file of A
Public bucket Request the file URL with no token 200 with no sign-in
Signed URL scope Ask for a signed URL for the path of A with the token of B The server returns a URL
Signed URL life Wait until after the expiry and use the URL The URL still works
Listing List the bucket with the token of B Files of A appear

For Supabase Storage, access rules are RLS policies on the storage.objects table. Test them with the same SQL pattern as in the RLS section.

curl -s -X POST "$BASE/api/files/sign" -H "Authorization: Bearer $TOKEN_B" \
  -H "Content-Type: application/json" \
  -d '{"path":"ORG_ID_OF_A/FILE-A.pdf"}'

If the server returns a signed URL, the signing endpoint has no ownership check. Also check the signed URL itself. A URL that stays valid for days is a bearer token. Anyone who gets the link gets the file.

How do you test background jobs and queues?

A job runs later, often with a service account that sees all tenants. The job input must carry the tenant, and the job must use it.

  1. Find the jobs. They include imports, exports, emails, webhooks, scheduled reports and AI tasks.
  2. As tenant A, start a job that handles JOB-A data.
  3. As tenant B, start the same kind of job at the same time.
  4. Read the output of each job, such as the file, the email or the webhook body.

Look for these faults:

  • A job that reads a global variable or a shared file path. Two jobs at the same time overwrite or mix data.
  • A job that takes a record ID and does not check the owner of the record.
  • A worker that keeps a database session with the tenant of the previous job. Run many jobs in a row and check the output.
  • A webhook that sends tenant A data to the URL of tenant B.

The job runs outside the request, so no session check protects it. The tenant ID must be in the job payload, and the worker must use it for every query.

How do you test exports, reports and emails?

Exports and reports often use their own queries. They are a common place to forget the tenant filter.

  1. Run each export as tenant B: CSV, PDF, “download all” and the report builder.
  2. Search each file for MARKER-A.
  3. Request an export with a filter that names tenant A, such as ?org_id=ORG_ID_OF_A.
  4. Open the email footer, the “share” link and the “invite” email. Check that they contain no data of another tenant.
curl -s -H "Authorization: Bearer $TOKEN_B" "$BASE/api/reports/export?format=csv" \
  | grep -c "MARKER-A"

The count must be 0. Test the “scheduled report” feature as well. The report is made later by a job, so it can use different code from the live view.

How do you test analytics and admin tools?

Analytics and admin tools see data from many tenants by design. Test who can see what.

  • Product analytics. Open the dashboard for tenant B. Check that the charts and tables show only tenant B events. Look at the event names and properties that you sent from tenant A.
  • Third-party tools. Session replay, error tracking and logging can store customer data. Check that tenant B cannot see them, and that the data has a retention limit.
  • Admin panels. Request each admin route with a normal tenant token. See the forced browsing test in the access control guide.
  • Impersonation. If support staff can sign in as a customer, check that the action is logged.

How do you read the results?

Layer Marker Pass Fail
Database MARKER-A Zero rows for B Any row for B
Cache CACHE-A Marker absent Marker in B response
Search and vector VECTOR-A Marker absent Marker in B answer or citation
Storage FILE-A 403 or 404 File opens for B
Jobs JOB-A Marker absent from B output Marker in B output
Exports MARKER-A Count is 0 Count above 0

Treat any leak as a high-severity finding, because the data of one customer reached another customer. The OWASP A01:2021 Broken Access Control entry covers the class.

How do you keep isolation from breaking again?

Isolation fails again when a developer adds a new table, cache or job. Prevent this with a short routine.

  1. Keep the two-tenant fixture in the repository.
  2. Write one test per layer. Each test searches for the marker of the other tenant.
  3. Run the tests in the build for each release.
  4. Add a check in review: each new table needs RLS and each new cache key needs a tenant.
  5. Turn each fixed leak into a permanent test. See security regression testing.

What can VibeEval test here?

VibeEval tests a deployed app from the outside. It does not read your source code or connect to your database. It can find Supabase tables that are reachable without RLS, and it tests BOLA and IDOR with an account that you give it. See the security checks list and the AI pentest for SaaS page. Checks of caches, queues and exports that need access inside your system are your own tests. Use the fixture in this guide for them.

Reviewed against OWASP, Postgres and Supabase documentation on November 18, 2026.

Common questions

What is multi-tenant data isolation?
It is the rule that each customer can see only its own data. The rule must hold in every place that stores or moves data. These places include the database, caches, search indexes, file storage, queues, exports and analytics.
Is a passing API test enough to prove isolation?
No. An API test proves that the request layer checks ownership. Data can still leak through a cache key, a background job or a vector index. Test each of these places on its own.
Do I need RLS if my backend filters by tenant?
RLS is a second layer in the database. A backend filter fails when one query has no filter. RLS still blocks that query. If the client can reach the database directly, as in Supabase, RLS is required.
Is a shared database with a tenant_id column safe?
It is safe only if every read and write is filtered by tenant_id. Enforce the filter in the database with RLS. Do not rely on each developer to add the filter to each query.
How do I test isolation in a RAG or AI chat feature?
Put a unique marker string in the documents of tenant A. Sign in as tenant B and ask questions that match the marker. If the answer contains the marker, the retrieval step does not filter by tenant.
Can I run these tests in production?
Use two test tenants that you own and data that you created. Run read tests first. Use a staging copy for tests that write or delete data.

Check isolation on your live app

VibeEval scans your deployed app and tests whether Supabase tables are reachable without Row Level Security and whether one account can read another account's objects.

14-day free trial · Cancel anytime

SCAN YOUR APP →