Deutsch
Security wikiSupabase · Database

What is tenant isolation?

Also known as: data isolation, cross-tenant access, workspace isolation, tenant separation

Tenant isolation keeps each customer’s data out of every other customer’s reach in a shared app. How it fails in Supabase apps, and a tested membership policy.

By Tim GeithnerPublished 2 min read

Short answer

Tenant isolation is the guarantee that, in a multi-tenant app, one customer can never read or change another customer’s data. In a Supabase app it rests on RLS policies that tie every row’s tenant column to the caller’s verified membership. The most common failure is a policy that lets any signed-in user through, which isolates visitors from data but not customers from each other.

Ask an AI about this page:ChatGPTClaude

On this page

Tenant isolation is the guarantee that, in a multi-tenant app, no tenant can read or change another tenant’s data, through any path: database, API, storage, realtime or background jobs. OWASP’s guidance boils it down to binding every request to “a server-verified identity” and the tenant that identity really belongs to. A client-supplied tenant ID is only a selection, never proof.

Tenant isolation in an AI-built app

In a typical Supabase SaaS, all workspaces share the projects table and a workspace_id column says which row belongs to whom. The generated policy often looks like this:

VulnerableEvery signed-in user reads every workspace
create policy "Signed-in users read projects"
  on public.projects for select
  to authenticated
  using (true);

It feels safe because visitors without an account get nothing. But anyone can sign up, and every signed-in user then reads every customer’s projects. In the browser, the app filters by the current workspace, so nobody notices until someone calls the API without that filter. Changing the ID in a request to reach someone else’s data is authorization bypass through a user-controlled key (CWE-639 (opens in a new tab)), a form of IDOR.

How to check your app

Test as a real user of one workspace and count what they see per workspace. Run this in the SQL Editor with a real user ID from Authentication → Users:

What one user sees, per workspace
begin;
set local role authenticated;
set local request.jwt.claims = '{"sub": "11111111-1111-1111-1111-111111111111", "role": "authenticated"}';
select workspace_id, count(*) from public.projects group by workspace_id;
rollback;

Every workspace_id in the result should be one the user is a member of. A workspace they don’t belong to means isolation is broken. Repeat for every table with a tenant column, and as a user of a second workspace.

How to fix it

Replace the open policy with a membership check. A small helper keeps every policy short:

SafeFix: members only
drop policy "Signed-in users read projects" on public.projects;

create schema if not exists private;

create or replace function private.is_member(ws uuid)
returns boolean
language sql
security definer
set search_path = ''
stable
as $$
  select exists (
    select 1 from public.workspace_members m
    where m.workspace_id = ws
      and m.user_id = (select auth.uid())
  );
$$;

create policy "Members read their workspace's projects"
  on public.projects for select
  to authenticated
  using (private.is_member(workspace_id));

Use the same check for insert, update and delete, with with check so nobody writes rows into a workspace they don’t belong to. The complete approach, including storage and server code, is in Multi-tenant data isolation; the fix for an open policy is on RLS policy USING (true).

Frequently asked questions

Is ‘to authenticated using (true)’ enough for team data?

No. It keeps signed-out visitors away, but every signed-in user of your app, including someone who signs up for free, reads every team’s rows. The policy has to check membership.

Why put the membership check in a SECURITY DEFINER function?

The membership table has RLS of its own. A definer function can read it without running into those policies, and with search_path pinned and the function in a schema the API does not expose, it can’t be misused as an endpoint.

Can users add themselves to another workspace?

Only if your policies on the membership table allow it. Don’t give the client an insert policy on workspace_members; add members through an invite flow on the server.

Sources

  1. 1.Multi-Tenant Security Cheat Sheet — OWASP Cheat Sheet Series
  2. 2.Row Level Security — Supabase Docs
  3. 3.CWE-639: Authorization Bypass Through User-Controlled Key — MITRE
  4. 4.A01 Broken Access Control — OWASP Top 10

Find this in your own app

ShipRely reads your repository (read-only), proves each finding with file and line, and gives you a fix prompt to paste into your AI builder.

Run a demo audit
  • Read-only access to your repository
  • Every finding with file and line
  • Fix prompts for Lovable, Cursor, Claude Code and Bolt