Supabase RLS: a two-tenant test of tables, views, storage and functions
With the publishable key shipped in your app, row level security decides which rows each request reaches.
This guide explains how Supabase RLS policies and grants make that decision, which keys skip it, where views, Storage and database functions follow different rules, and gives you a two-tenant matrix to run on Supabase's local stack or on a staging project of your own that holds only invented data.
In this guide
Two-tenant Supabase RLS test matrix
Copy the rows into a spreadsheet and run them on Supabase's local stack, or on a development or staging project of your own that holds only invented data, never on a live project. Nothing here connects to your project: every statement is text you run yourself.
How to use itHide the instructions
The SQL rows use the transaction, set local role and auth.users seed that Supabase's test guide shows on a local database; this page asks you to run them only on a local stack or on a staging project that holds only invented data. The cells name an invented schema so they can be run as written: public.tenants; public.tenant_members (tenant_id, user_id); public.projects (id, tenant_id, name), standing in for any table that holds a tenant's records; public.project_list, a simple view over projects; a private bucket tenant-files with each file under a folder named by its tenant's id, and a public bucket public-assets; and four functions called with rpc(): project_count(target_tenant uuid), add_project(target_tenant uuid, project_name text), rename_project(project_id uuid, new_name text) and remove_project(project_id uuid). Replace them with your own, one set of rows for each table, view, bucket and function. Invented ids: tenant A 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', tenant B 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', user A1 '11111111-1111-1111-1111-111111111111' (a member of tenant A only), user B1 '22222222-2222-2222-2222-222222222222' (a member of tenant B only), A project 'aaaa0000-0000-0000-0000-000000000001' and B project 'bbbb0000-0000-0000-0000-000000000001'. Every cell in the T, V and R rows starts with this seed, run as postgres: `begin; insert into auth.users (id, email) values ('11111111-1111-1111-1111-111111111111', 'a1@example.com'), ('22222222-2222-2222-2222-222222222222', 'b1@example.com'); insert into public.tenants (id, name) values ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Tenant A'), ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'Tenant B'); insert into public.tenant_members (tenant_id, user_id) values ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '11111111-1111-1111-1111-111111111111'), ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '22222222-2222-2222-2222-222222222222'); insert into public.projects (id, tenant_id, name) values ('aaaa0000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'A project'), ('bbbb0000-0000-0000-0000-000000000001', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'B project');` The storage rows need real sign-ins instead: on staging, create A1 and B1 in Supabase Auth with email addresses you control, add each to their tenant, and have each upload one small invented text file to their own tenant's folder in tenant-files (matrix-a.txt under tenant A's id, matrix-b.txt under tenant B's id), and place one small invented text file, matrix-public.txt, in public-assets. These storage records persist, so each storage row that sends requests, S1 to S4, ends its limits with the clean-up; S5 sends none. The T, V, S and R rows give an expected result for each operation they run: allow, deny, or your rule decides where the answer depends on your own access rules. Cells marked not run record reach rather than a result, cells marked not part of this row name the row that covers that operation, and the P rows record settings. Change any expected result your own rules decide differently before you run anything. A write that raises no error counts as refused only when the intact check in the same transaction shows the target row unchanged, and a write that raises an error is recorded as refused with its error code. Record results, names, settings and policy text, never a key, token or password value: nothing in the matrix asks you to record one.
18 rows
Row
Object and caller
P1. Inventory
- Object and caller
- Every table and view in the schemas listed under "Exposed schemas" in your API settings, read as postgres
- Select
- Record whether anon and authenticated hold select on each table: `select has_table_privilege('anon', 'public.projects', 'select'), has_table_privilege('authenticated', 'public.projects', 'select');`
- Insert
- The same query with 'insert'. Supabase's guide says adding policies does not take grants back, so record every grant you did not intend.
- Update
- The same query with 'update'.
- Delete
- The same query with 'delete', and again with 'truncate'. PostgreSQL says operations that apply to the whole table, such as TRUNCATE, are not subject to row security, so record the truncate grant on its own.
- How to run it, and its limits
- Read-only: run as postgres in the SQL Editor or psql. No statement writes and nothing switches role.
- Policy SQL evidence to record
- `select relname, relkind, relrowsecurity, relforcerowsecurity from pg_class where relnamespace = 'public'::regnamespace and relkind in ('r', 'v', 'm');` Record every table (r) with relrowsecurity false, every view (v) and materialized view (m), and the Security Advisor findings, from Studio or supabase db advisors, with the date you read them.
P2. Keys
- Object and caller
- API keys: the "Publishable key", "Secret keys" and the legacy anon and service_role keys
- Select
- Publishable key or legacy anon key: expected in browser code and apps. Record each place it is used.
- Insert
- Secret keys: expected only in backend components. Record each component that holds one, such as a server route, a worker or an Edge Function.
- Update
- Legacy service_role key: record whether any component still uses it. Supabase calls it the legacy version of secret keys.
- Delete
- Client build: list the environment variable names the browser build reads, and record any whose name marks it as a secret or service_role key, such as a name your server code also reads for its secret key. Supabase's example .env says never to prefix the server-only names, or the bundler will ship the key.
- How to run it, and its limits
- Read-only: read the environment variable names your source code refers to and the components that use each one. Do not open a file, screen or settings page that shows key values, such as a .env file or the Dashboard screen that lists your keys. If a source file holds a key value rather than a name, record only that a key is present in that file. Never copy a key value into the matrix or print one to the screen.
- Policy SQL evidence to record
- For each key: its type, the environment variable name it is read from, the components that use it and, for secret keys, whether each component forwards the user's access token. Supabase's guide says a request carrying a user's token runs under that user's policies, and one without it bypasses RLS. Never the value.
T1. Signed-out visitor
- Object and caller
- Table public.projects, as anon
- Select
- Deny. `select count(*) from public.projects;` raises 42501 when anon holds no select grant, or returns 0. Any other count means signed-out visitors can read tenant rows.
- Insert
- Deny. `insert into public.projects (tenant_id, name) values ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'matrix');` raises an error, 42501 when anon holds no insert grant.
- Update
- Deny. `update public.projects set name = 'matrix' returning id;` raises 42501 or returns no rows. Then, as A1, A project still has its name.
- Delete
- Deny. `delete from public.projects returning id;` raises 42501 or returns no rows. Then, as A1, A project is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role anon;`, then the cell's statement, then `rollback;`. For an intact check, switch to A1 in the same transaction with `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'public' and tablename = 'projects';` Copy the policy text for each command, then record each statement's result (the rows returned, or the error code) beside the expected result, with the date.
T2. Member, own tenant
- Object and caller
- Table public.projects, as A1 on tenant A's rows
- Select
- Allow. `select name from public.projects where id = 'aaaa0000-0000-0000-0000-000000000001';` returns A project.
- Insert
- Allow. `insert into public.projects (tenant_id, name) values ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'matrix') returning name;` returns matrix.
- Update
- Allow. `update public.projects set name = 'matrix' where id = 'aaaa0000-0000-0000-0000-000000000001' returning name;` returns matrix. No error and no returned row is not a pass.
- Delete
- Your rule decides. `delete from public.projects where id = 'aaaa0000-0000-0000-0000-000000000001' returning id;` returns the id if members may delete. If they may not, it returns no rows, and A project is still there when read again.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'public' and tablename = 'projects';` Copy the policy text for each command, then record each statement's result (the rows returned, or the error code) beside the expected result, with the date.
T3. Member, other tenant
- Object and caller
- Table public.projects, as A1 on tenant B's rows
- Select
- Deny. `select count(*) from public.projects where tenant_id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb';` returns 0, with no error.
- Insert
- Deny. `insert into public.projects (tenant_id, name) values ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'matrix');` raises 42501. No error means A1 has written into tenant B.
- Update
- Deny. `update public.projects set name = 'matrix' where id = 'bbbb0000-0000-0000-0000-000000000001' returning id;` returns no rows, and as B1 B project keeps its name.
- Delete
- Deny. `delete from public.projects where id = 'bbbb0000-0000-0000-0000-000000000001' returning id;` returns no rows, and as B1 B project is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'public' and tablename = 'projects';` Copy the policy text for each command, then record each statement's result (the rows returned, or the error code) beside the expected result, with the date.
T4. Membership
- Object and caller
- Membership table public.tenant_members, as A1
- Select
- Deny for tenant B. `select count(*) from public.tenant_members where tenant_id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb';` returns 0.
- Insert
- Deny. `insert into public.tenant_members (tenant_id, user_id) values ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '11111111-1111-1111-1111-111111111111');` raises 42501. If it succeeds, A1 has joined tenant B.
- Update
- Deny. `update public.tenant_members set tenant_id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' where user_id = '11111111-1111-1111-1111-111111111111';` raises 42501, or updates no rows and, read again as A1, A1 is still a member of tenant A only.
- Delete
- Deny for tenant B. `delete from public.tenant_members where tenant_id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' returning user_id;` returns no rows, and as B1 the membership is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'public' and tablename = 'tenant_members';` Copy the policy text for each command and any helper function it calls, then record each result beside the expected one, with the date.
T5. Moving a row
- Object and caller
- Table public.projects, as A1 trying to move a tenant A row into tenant B
- Select
- Not part of this row: a move is an update. T2 and T3 cover reads.
- Insert
- Not part of this row: T3 covers an insert that names tenant B.
- Update
- Deny. `update public.projects set tenant_id = 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb' where id = 'aaaa0000-0000-0000-0000-000000000001';` raises an error, 42501 for a with check violation. If it raises no error, read the row as B1 in the same transaction: A project showing under tenant B means it moved. Supabase's guide says the with check clause decides what the resulting row may look like, which stops a user reassigning user_id to someone else.
- Delete
- Not part of this row: T2 and T3 cover deletes.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'public' and tablename = 'projects';` Copy the policy text for each command, then record each statement's result (the rows returned, or the error code) beside the expected result, with the date.
T6. Service role
- Object and caller
- Tables, views and functions, as service_role: what any secret key reaches
- Select
- Allow, every tenant. `select tenant_id, count(*) from public.projects group by tenant_id;` returns both tenants, and the same query on public.project_list does too. Supabase's API keys guide says policies never apply to a secret key, because service_role has the BYPASSRLS attribute.
- Insert
- Not run. The select shows the reach: inserts for any tenant, wherever service_role holds the grant. The API keys guide says a missing grant still returns a permission error, including for service_role.
- Update
- Not run, for the same reason. Record it as within reach of any secret key.
- Delete
- Not run, for the same reason. Record it as within reach of any secret key.
- How to run it, and its limits
- In one transaction: the seed, then `set local role service_role;`, then the select, then `rollback;`. No key is used. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- For each component that uses a secret key, read from its source code and never its key value: what it reads or writes, whether it forwards the user's access token, and the tenant filter its own code applies. Add `select has_function_privilege('service_role', 'public.project_count(uuid)', 'execute');` for each function it calls.
V1. Signed-out visitor
- Object and caller
- View public.project_list (a simple view over projects), as anon
- Select
- Deny. `select count(*) from public.project_list;` raises 42501 or returns 0. Rows here mean the view hands tenant data to signed-out visitors.
- Insert
- Deny. `insert into public.project_list (tenant_id, name) values ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'matrix');` raises an error.
- Update
- Deny. `update public.project_list set name = 'matrix' returning id;` raises an error or returns no rows. Then, as A1, A project still has its name.
- Delete
- Deny. `delete from public.project_list returning id;` raises an error or returns no rows. Then, as A1, A project is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role anon;`, then the cell's statement, then `rollback;`. For an intact check, switch to A1 in the same transaction with `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- `select relname, reloptions from pg_class where relname = 'project_list' and relkind = 'v';` Record whether the options include security_invoker=true, the result of `select version();`, since Supabase gives that setting for Postgres 15 and above, and has_table_privilege for anon on the view.
V2. Member through the view
- Object and caller
- View public.project_list, as A1
- Select
- Allow tenant A only. `select tenant_id, count(*) from public.project_list group by tenant_id;` returns tenant A alone. A count for tenant B points first to the view applying its owner's policies: check security_invoker.
- Insert
- Deny for tenant B. `insert into public.project_list (tenant_id, name) values ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'matrix');` raises 42501. No error means A1 has written into tenant B through the view.
- Update
- Deny for tenant B. `update public.project_list set name = 'matrix' where id = 'bbbb0000-0000-0000-0000-000000000001' returning id;` returns no rows, and as B1 B project keeps its name.
- Delete
- Deny for tenant B. `delete from public.project_list where id = 'bbbb0000-0000-0000-0000-000000000001' returning id;` returns no rows, and as B1 B project is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- The view's reloptions as in V1, has_table_privilege for authenticated on the view and on public.projects, and the policies on public.projects from T1, since an invoker view applies the caller's policies on its base table.
S1. Signed-out visitor
- Object and caller
- Private bucket tenant-files, with the publishable key and no session
- Select
- Deny. A download of matrix-b.txt is refused, and a listing of the bucket returns nothing.
- Insert
- Deny. An upload of a small invented file to tenant-files is refused.
- Update
- Deny. An upsert over matrix-b.txt, or a move of it, is refused.
- Delete
- Deny. A removal of matrix-b.txt is refused, and B1 can still download it.
- How to run it, and its limits
- Through the Storage API, from your staging app and the Supabase client it already sets up, signed in as the user the row names, or signed out where it says so. The app carries its own publishable key: do not copy, paste or print a key to run these rows. Limits: your own development or staging project that holds only invented data, never a live one; the invented users A1 and B1, created with email addresses you control, and small invented test files only; at most two requests per cell, each run once, with no scripts or repeated runs. Storage requests cannot be rolled back, so clean up when the storage rows are done: delete the test files, then the invented tenants and their membership rows, then both users.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'storage' and tablename = 'objects';` and `select id, public from storage.buckets;` Copy the policies that name the bucket and its public flag, then record each request's response beside the expected result, with the date.
S2. Member, own tenant
- Object and caller
- Private bucket tenant-files, as A1 in tenant A's folder
- Select
- Allow. A1 downloads matrix-a.txt, and a listing of tenant A's folder shows it.
- Insert
- Allow. A1 uploads a second small invented file to tenant A's folder.
- Update
- Your rule decides. Supabase says an upsert needs select and update permissions as well as insert, so an upsert over matrix-a.txt works only where all three allow it.
- Delete
- Your rule decides. A removal of A1's second file works if members may delete tenant files.
- How to run it, and its limits
- Through the Storage API, from your staging app and the Supabase client it already sets up, signed in as the user the row names, or signed out where it says so. The app carries its own publishable key: do not copy, paste or print a key to run these rows. Limits: your own development or staging project that holds only invented data, never a live one; the invented users A1 and B1, created with email addresses you control, and small invented test files only; at most two requests per cell, each run once, with no scripts or repeated runs. Storage requests cannot be rolled back, so clean up when the storage rows are done: delete the test files, then the invented tenants and their membership rows, then both users.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'storage' and tablename = 'objects';` and `select id, public from storage.buckets;` Copy the policies that name the bucket and its public flag, then record each request's response beside the expected result, with the date.
S3. Member, other tenant
- Object and caller
- Private bucket tenant-files, as A1 in tenant B's folder
- Select
- Deny. A1's download of matrix-b.txt is refused, and a listing of tenant B's folder returns nothing.
- Insert
- Deny. A1's upload of a small invented file into tenant B's folder is refused.
- Update
- Deny. A1's upsert over matrix-b.txt is refused, and so is a move of A1's own file into tenant B's folder.
- Delete
- Deny. A1's removal of matrix-b.txt is refused, and B1 can still download it.
- How to run it, and its limits
- Through the Storage API, from your staging app and the Supabase client it already sets up, signed in as the user the row names, or signed out where it says so. The app carries its own publishable key: do not copy, paste or print a key to run these rows. Limits: your own development or staging project that holds only invented data, never a live one; the invented users A1 and B1, created with email addresses you control, and small invented test files only; at most two requests per cell, each run once, with no scripts or repeated runs. Storage requests cannot be rolled back, so clean up when the storage rows are done: delete the test files, then the invented tenants and their membership rows, then both users.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'storage' and tablename = 'objects';` and `select id, public from storage.buckets;` Copy the policies that name the bucket and its public flag, then record each request's response beside the expected result, with the date.
S4. Public bucket
- Object and caller
- Public bucket public-assets, with the publishable key and no session
- Select
- Allowed by design for files fetched by URL: Supabase's buckets guide says anyone who has the URL of a file in a public bucket can access it. Open matrix-public.txt by its URL, record that nothing tenant-specific is stored in the bucket, and record whether a signed-out listing returns its files.
- Insert
- Deny. A signed-out upload of a small invented file is refused: Supabase says access control is still enforced for uploading in a public bucket.
- Update
- Deny. A signed-out overwrite or move of matrix-public.txt is refused, for the same reason.
- Delete
- Deny. A signed-out removal of matrix-public.txt is refused, and the file still opens by its URL.
- How to run it, and its limits
- Through the Storage API, from your staging app and the Supabase client it already sets up, signed in as the user the row names, or signed out where it says so. The app carries its own publishable key: do not copy, paste or print a key to run these rows. Limits: your own development or staging project that holds only invented data, never a live one; the invented users A1 and B1, created with email addresses you control, and small invented test files only; at most two requests per cell, each run once, with no scripts or repeated runs. Storage requests cannot be rolled back, so clean up when the storage rows are done: delete the test files, then the invented tenants and their membership rows, then both users.
- Policy SQL evidence to record
- Run as postgres: `select policyname, permissive, roles, cmd, qual, with_check from pg_policies where schemaname = 'storage' and tablename = 'objects';` and `select id, public from storage.buckets;` Copy the policies that name the bucket and its public flag, then record each request's response beside the expected result, with the date. Supabase's Advisors page warns when a public bucket also has a broad select policy that makes its contents listable.
S5. Service role
- Object and caller
- Storage, as any component that uses a secret key
- Select
- Allow, every tenant's files: Supabase's access control guide says service keys entirely bypass RLS policies, granting unrestricted access to all Storage APIs, and its API keys guide says secret keys bypass Row Level Security. Not run.
- Insert
- Not run: the same reach applies to uploads.
- Update
- Not run: the same reach applies to overwrites and moves.
- Delete
- Not run: the same reach applies to removals.
- How to run it, and its limits
- Read-only: no request is sent and no key is used. Read the code of each component that calls Storage with a secret key; if the code holds a key value rather than a name, record only that one is present.
- Policy SQL evidence to record
- Each such component, the bucket it writes to, how it chooses the tenant folder (from the signed-in user's membership or from a value in the request), and whether a request could name another tenant's folder.
R1. Signed-out visitor
- Object and caller
- Functions called with rpc(), as anon
- Select
- Deny unless meant to be public. `select public.project_count('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb');` raises a permission error when anon holds no execute grant. Supabase says any role can call a database function by default, including anon.
- Insert
- Deny. `select public.add_project('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'matrix');` raises a permission error.
- Update
- Deny. `select public.rename_project('bbbb0000-0000-0000-0000-000000000001', 'matrix');` raises a permission error.
- Delete
- Deny. `select public.remove_project('bbbb0000-0000-0000-0000-000000000001');` raises a permission error.
- How to run it, and its limits
- In one transaction: the seed, then `set local role anon;`, then the cell's statement, then `rollback;`. For an intact check, switch to A1 in the same transaction with `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- `select has_function_privilege('anon', 'public.project_count(uuid)', 'execute');` for each function and role, and `select proname, prosecdef, proconfig from pg_proc where pronamespace = 'public'::regnamespace;` Record each function's security setting, its configuration settings and who may execute it.
R2. Member, invoker function
- Object and caller
- Security invoker functions (prosecdef false), as A1 passing tenant B's ids
- Select
- Deny. `select public.project_count('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb');` returns 0. PostgreSQL runs an invoker function with the privileges of the user that calls it, so A1's own policies are the ones expected to filter the rows it reads.
- Insert
- Deny. `select public.add_project('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'matrix');` raises 42501 from the table's with check expression.
- Update
- Deny. `select public.rename_project('bbbb0000-0000-0000-0000-000000000001', 'matrix');` changes nothing, and as B1 B project keeps its name.
- Delete
- Deny. `select public.remove_project('bbbb0000-0000-0000-0000-000000000001');` changes nothing, and as B1 B project is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- prosecdef and proconfig from R1, has_function_privilege for authenticated, and the policies on each table the function touches, from T1 and T4.
R3. Member, definer function
- Object and caller
- Security definer functions (prosecdef true), as A1 passing tenant B's ids
- Select
- Deny. The project_count call returns 0 only if the function body checks A1's membership: Supabase says a security definer function can return rows the caller is not allowed to read.
- Insert
- Deny. The add_project call is refused by the body's own check, and as B1 no matrix project appears.
- Update
- Deny. The rename_project call changes nothing, and as B1 B project keeps its name.
- Delete
- Deny. The remove_project call changes nothing, and as B1 B project is still there.
- How to run it, and its limits
- In one transaction: the seed, then `set local role authenticated; set local request.jwt.claim.sub = '11111111-1111-1111-1111-111111111111';`, then the cell's statement, then `rollback;`. For an intact check, switch to B1 in the same transaction with `set local request.jwt.claim.sub = '22222222-2222-2222-2222-222222222222';` and read the row. Limits: your own local project, or a development or staging project that holds only invented data, never a live one; invented tenants, users and records only; one cell per transaction, run once, ending in rollback, so nothing it writes persists; no loops, scripts or repeated runs.
- Policy SQL evidence to record
- prosecdef true, a proconfig entry that pins search_path, the function's schema and whether it is listed under "Exposed schemas", the line of the body that checks membership, copied from the function definition and nothing else from it, and any Security Advisor finding 0028 or 0029 for it. If the body holds a key or token, record only that one is present, never its value.
Where Supabase sits in your application
An application built on Supabase can query its database from the browser.
Supabase's production security checklist says the Data API exposes your tables to anyone who has your publishable key, and that the key ships in your app. Supabase's API keys guide says every request to a project carries an API key, which identifies what is calling (a web page, a mobile app, a server or an Edge Function), while Supabase Auth identifies who is calling when someone is signed in.
Supabase's database functions guide adds that functions live inside the database and can be called from the app with rpc().
Each key resolves to a Postgres role, and the role is what your policies match on. The API keys guide sets out the mapping: the publishable key with no user signed in runs as anon, the publishable key with a user signed in through Supabase Auth runs as authenticated, and a secret key runs as service_role.
Supabase's Postgres roles page describes anon as the role the API (PostgREST) uses when a user is not signed in, authenticated as the role it uses when a user is signed in, and service_role as the role it uses to bypass Row Level Security.
That puts the boundary in the database rather than in the key. The API keys guide says the publishable key is safe to expose online and only reaches what Row Level Security allows, and it lists what the key is not meant to protect against: code analysis and reverse engineering, the browser's network inspector, cross-site request forgery, cross-site scripting, phishing and man-in-the-middle attacks. Grants and policies decide whether a request carrying that key reads one tenant's rows or every tenant's.
This page is the technical companion to the vibe coding security guide, which covers sign-up settings, payment flows and keys in apps made with AI builders. The subject here is narrower: database and storage authorisation, tested with two tenants.
What Supabase secures, and what stays with you
Supabase answers this with a shared responsibility model.
Its model says running databases is a shared responsibility, and that the customer is always responsible for their Supabase account, access management (the Supabase account, database, tables and so on), data, and applying security controls. It says the customer is responsible for making sure tables with sensitive data have the right level of access, and for managing database secrets and API keys and storing them safely in an encrypted store.
It recommends always applying Row Level Security, and says Supabase provides security alerts through Security Advisor while applying the recommendations is the customer's responsibility.
On the platform side, Supabase's security overview says the hosted platform comes with many security and compliance controls managed by Supabase, and that Supabase is SOC 2 Type 2 compliant and regularly audited. Its shared responsibility model still leaves the access level on tables with sensitive data to the customer.
Whether a member of one customer organisation in your app can read another organisation's rows depends on grants and policies your team writes. Supabase's Advisors page adds that some of its findings may be intentional and should be checked against your intended schema and access model before anything changes.
The model also leaves the third-party services a customer integrates with the customer, such as OAuth and SAML sign-in providers, SMTP and SMS sending APIs, and calls to external APIs from Postgres functions, triggers and Edge Functions. Those sit outside the matrix on this page, which stays with the database and Storage.
Grants first, then policies: how a request reaches a table
Supabase's Row Level Security guide says Postgres runs its checks before a client touches a table: grants decide whether a role can run an operation on the table at all, and policies decide which rows that operation applies to.
The guide says to set both for every table you expose, and warns that adding policies does not take grants back: a table protected only by policies still hands anon an insert path if the grant is never revoked. Its Securing your API guide says default privileges differ between projects, depending on when the project was created and its Data API settings, and gives a query on pg_default_acl that lists the privileges new objects created by postgres in public receive, leaving out the execute privilege every new function receives through PUBLIC.
The Securing your API guide also says tables created through the Supabase Dashboard have RLS enabled by default, while tables created in the SQL Editor or through another tool need it enabled explicitly. A table that arrived through a migration script is therefore worth checking by name. Grants and policies also fail differently.
The API keys guide says a missing grant returns a permission error, including for service_role, whereas a policy that matches no rows returns an empty result. The Row Level Security guide gives the code for the first: 42501, raised before any policy runs.
When RLS is on and no policy exists for the table, PostgreSQL's chapter on row security policies says a default-deny policy is used, under which no rows are visible or can be modified, and Supabase's guide says that once RLS is enabled, no data is accessible through the API with a publishable key until you create policies.
The same PostgreSQL chapter notes that operations applying to the whole table, such as TRUNCATE and REFERENCES, are not subject to row security. A truncate is therefore decided by the grant alone.
PostgreSQL also says superusers and roles with the BYPASSRLS attribute always bypass row security, and that table owners normally bypass it too unless the table is set to FORCE ROW LEVEL SECURITY. Supabase's Postgres roles page says queries run in the Dashboard execute as postgres, and its database functions guide says postgres bypasses Row Level Security.
A query typed into the SQL Editor as it stands therefore runs as postgres, and RLS filters nothing out of its result. The matrix switches role inside a transaction before each statement for that reason.
How Supabase RLS policies decide which rows a request reaches
Supabase's guide says to think of a policy as adding a WHERE clause to every query.
PostgreSQL's CREATE POLICY syntax lets a policy name a command, the roles it applies to, a using expression and a with check expression, and the guide's update example shows both expressions: `create policy "Users can update their own profile." on profiles for update to authenticated using ( (select auth.uid()) = user_id ) with check ( (select auth.uid()) = user_id );`
PostgreSQL's CREATE POLICY reference says existing rows are checked against the using expression, and new rows from an insert or update against the with check expression. Supabase's guide says the with check clause decides what the resulting row is allowed to look like, which stops a user reassigning user_id to someone else.
The guide asks for a separate policy for each of select, insert, update and delete, because Postgres does not accept multiple operations in one for clause and a for all policy hides which operation each rule was meant to cover, and it says an update needs a matching select policy to work as expected.
PostgreSQL's CREATE POLICY reference sets out a related rule: an UPDATE typically also reads the table's columns, for example in a WHERE or RETURNING clause, and then SELECT rights are also required and the SELECT or ALL policies apply in addition to the UPDATE policies. It says the same of a DELETE in most cases.
PostgreSQL combines policies in a fixed way. Permissive policies, the default, are joined with OR, so any one of them can let a row through. Restrictive policies are joined with AND, and the CREATE POLICY reference says that if there are no permissive policies, access is denied.
So one broad permissive policy, such as one whose using expression is simply true, lets its roles reach every row of the table for that command, wherever they hold the grant, whatever the other permissive policies on that command say, unless a restrictive policy narrows it. Supabase's Advisors page flags always-true conditions such as USING (true) as a policy that allows unrestricted access.
Identity details also decide who a policy covers. Supabase's guide says to name the role in every policy with a to clause, and that auth.uid() returns null for a request with no signed-in user, so a policy comparing it with user_id silently fails for signed-out visitors.
It says an anonymous user in Supabase Auth is not the anon role: anonymous users assume the authenticated role, with an is_anonymous claim in the JWT. So a policy written for every authenticated request also admits anonymous sign-ins, where the project allows them.
And the guide warns against policies that rely on the user_metadata claim, because raw_user_meta_data can be updated by the signed-in user, while raw_app_meta_data cannot.
A refusal can look like nothing happened
Not every refusal raises an error. Supabase's guide sets out how each kind of denial behaves: a missing grant raises 42501, a with check violation raises 42501, and a using clause that filters the row out raises nothing and matches zero rows. PostgreSQL's CREATE POLICY reference says the same of using: the rows it excludes are typically suppressed with no error reported.
That changes how a test is read. An update aimed at another tenant's row that returns no error has not proved anything yet. Supabase's guide says matching no rows is not proof on its own, and to pair every denied write with a check that the targeted row is intact.
It also says never to prove an allowed write with lives_ok, because it passes when the write matched zero rows, and to add returning and assert the returned value instead. The SQL write cells in the matrix follow both rules.
Writing Supabase RLS policies for two tenants
In a multi-tenant application the policy question moves from ownership to membership: may this user act on rows that belong to this tenant?
Supabase's guidance for a table users share is to assert that a member who is not the owner can perform the operations its policies allow, and that a non-member cannot. Its advanced pgTAP guide works through a multi-tenant publishing example and names cross-organisation data isolation among the areas its tests should verify.
Supabase's Row Level Security guide shows patterns that fit this question, among them a membership table read through a security definer function and a claim in the user's JWT. For the membership table, the guide shows why the function is needed: two tables whose policies read each other never resolve, and Postgres raises 42P17, infinite recursion detected in policy for relation.
The fix moves the membership lookup into private.user_list_ids(), a security definer function with search_path set to an empty string that returns the caller's list ids, revokes execute on it from public, grants it to authenticated, and calls it from the policy: `create policy "members read lists" on lists for select to authenticated using ( id in (select private.user_list_ids()) );`
The guide adds the condition this depends on. A security definer function only skips RLS when its owner can, and on Supabase the owner is postgres, which has bypassrls. A function owned by a role without bypassrls, or one reading a table set to force row level security, evaluates the membership policy again and stays recursive.
In a tenant model the list is the tenant and the membership table holds pairs of tenant and user, which is the shape the matrix uses.
For a claim in the JWT, the guide's example policy reads a teams array from app_metadata with auth.jwt(), and it carries a warning: a JWT is not always up to date, so a user removed from a team keeps the old claim until their JWT is refreshed.
If your policies work this way, add a removed-member case to your copy of the matrix and record what that user's existing session can still reach.
Writes need the same care as reads. An insert policy has to tie the new row's tenant_id to a tenant the caller belongs to, and so does whatever checks an updated row: the update policy's with check expression or, where it has none, its using expression, which Supabase's guide says then also decides which new rows are allowed.
If that check leaves the tenant open, a member can move a row into another tenant. The membership table needs its own policies, because a user who can insert a membership row for tenant B has joined tenant B.
Supabase's publishing example restricts member management to owners and admins, and its tests expect an editor's attempt to add a member to fail with 42501.
The Supabase anon key, the service role key and their replacements
Supabase's API keys guide names its key types "Publishable key", "Secret keys", "anon" and "service_role" in its key types table.
The first two have the formats `sb_publishable_...` and `sb_secret_...`. The guide calls anon the legacy version of publishable keys and service_role the legacy version of secret keys, and both legacy keys are long-lived JWTs.
The publishable key is built to be seen: the guide lists it as safe to expose online, in a web page, a mobile or desktop app, GitHub actions, CLIs and source code. The secret key is the opposite. The guide says secret keys provide full access to a project's data, bypassing Row Level Security, and are only for backend components such as servers, Edge Functions and microservices.
Its list of places a secret key must never appear includes a web page, source code, a bundled mobile, desktop or CLI package, and a browser, even on localhost.
The details matter when you reason about a leak. The guide says a secret key does not work in a browser, because Supabase matches on the User-Agent header and returns HTTP 401 Unauthorized, and it adds that an attacker can still use the key from other tools.
The Row Level Security guide says a secret key bypasses RLS only when the request carries no user access token; a request that carries one runs under that signed-in user's policies, even when the client library was initialised with a secret key.
For a test, that means any server code that queries with a secret key and no user token skips every policy in the matrix, so it has to apply the tenant boundary in its own code. The matrix records each key's existence and the components that use it, never a value. Finding a key that has already leaked, and rotating it, belong to the secrets exposure guide in this library.
Views and Supabase RLS: security_invoker and the Postgres 15 condition
A view is where a careful set of table policies can be undone without anyone touching them.
Supabase's guide says views bypass RLS by default because they are usually created with the postgres user, and that a view over a protected table hands out every row its policies were meant to withhold. Its fix carries a version condition: in Postgres 15 and above, setting security_invoker = true makes a view obey the RLS policies of its underlying tables when invoked by anon and authenticated.
On older versions it says to protect views by revoking access from anon and authenticated, or by putting them in a schema that is not exposed.
PostgreSQL's CREATE VIEW reference explains the mechanism. Where a base table has row-level security enabled, the view owner's row-level security policies are applied by default; with security_invoker set to true, the invoking user's policies and permissions are used instead, and that user then needs permissions on the base tables as well as on the view.
The same reference says simple views are automatically updatable, so an INSERT, UPDATE or DELETE on the view becomes the matching statement on the base table.
A simple view therefore needs write cases in the matrix as well as read cases, and a permission error from an invoker view points first at the grants on its base table.
Materialized views are a separate case. Supabase's Advisors page says they cannot be protected by Row-Level Security, so all their data is visible to every API user who can select from them, and it recommends revoking select from anon and authenticated. The same page flags a view in the public schema that runs with elevated privileges and ignores Row-Level Security, under the summary "View bypasses row-level security".
Supabase Storage: policies on storage.objects
Supabase Storage access rules live in the same database.
Supabase's storage schema page says Storage keeps metadata about buckets and objects in a dedicated schema called storage, and its access control guide says that by default Storage does not allow any uploads to buckets without RLS policies, and that operations are allowed selectively by creating policies on the storage.objects table.
It says the only policy an upload needs is an insert permission on storage.objects, and that overwriting a file with upsert needs select and update permissions as well.
Its folder-per-user example ties the first folder in the object's path to the signed-in user: `create policy "Allow authenticated uploads" on storage.objects for insert to authenticated with check ( bucket_id = 'my_bucket_id' and (storage.foldername(name))[1] = (select auth.jwt()->>'sub') );`
For two tenants, the same shape can compare the first folder with the tenants the caller belongs to, which is how the matrix lays out its invented bucket. The bucket setting matters as much as the policy. Supabase's buckets guide says buckets are private by default, and that in a private bucket every operation, downloads included, is subject to RLS policies, with downloads made either with the user's JWT or through a signed URL that can be accessed for a limited time.
It says a public bucket effectively bypasses access controls for retrieving and serving files, so anyone with a file's URL can open it, while access control is still enforced for other operations, including uploading, deleting, moving and copying.
Listing is its own question. A select policy on storage.objects can serve more than one Storage action, and Supabase's helper functions page describes storage.allow_only_operation() for a policy that should apply to only one of them, such as listing objects rather than downloading them.
The Advisors page warns about a public bucket that also has a broad select policy, because that combination lets API clients list the bucket's files, and a public bucket needs no select policy for its files to be fetched by URL.
The storage schema page and the access control guide also shape how the matrix tests Storage. The storage schema page says records in the Storage tables should be treated as read-only from SQL, with all operations, including uploading, copying, moving and deleting, going exclusively through the API, and that deleting the metadata leaves the object inaccessible but still billed.
So the storage rows send their requests through the Storage API as invented users, never as SQL against storage.objects.
The access control guide says service keys entirely bypass RLS policies, granting unrestricted access to all Storage APIs. A server component that calls Storage with a service key therefore decides the tenant folder in its own code.
Database functions called with rpc(): invoker, definer and execute grants
RLS protects tables, not functions.
Supabase's Securing your API guide says RLS does not apply to functions, so execute should be granted only to the roles that need to call them, and every security definer function reviewed carefully. Its database functions guide says to prefer security invoker, which is also the default, and to set the search_path whenever you use security definer.
The difference is who the function runs as. PostgreSQL's CREATE FUNCTION reference says a SECURITY INVOKER function runs with the privileges of the user that calls it, and a SECURITY DEFINER function with the privileges of the user that owns it. Supabase's functions guide spells out what that means on its platform: a security definer function can return rows the caller is not allowed to read, a function created in the Dashboard or by a migration is owned by postgres, which bypasses RLS, and any role can call it by default, including anon.
For a security definer function that reads per-user data, the guide says an execute grant controls which roles can call the function and does not limit the rows a permitted role gets back, so it says to check ownership in the function body and to narrow the execute privilege as well.
Default execute rights are wide. PostgreSQL's reference says execute privilege is granted to PUBLIC for newly created functions by default. To restrict a security definer function, it says to revoke the default PUBLIC privileges and grant execute selectively, creating the function and setting its privileges within one transaction so there is no window where it is accessible to all.
Supabase's Securing your API guide adds that the PUBLIC grant comes from a global default, which a revoke limited to one schema cannot remove.
Where a security definer function lives matters too. Supabase's Row Level Security guide says one in an exposed schema is callable over the Data API with its creator's privileges, and says never to create one in a schema listed under "Exposed schemas" in the API settings. Without a pinned search_path, it says, a caller can point an unqualified name at their own object and run it with the function owner's privileges.
The Advisors page flags a function without a fixed search path, and its lints 0028 and 0029 flag security definer functions that visitors who are not signed in, or any signed-in user, can execute.
In the matrix, invoker functions are tested like the tables they read, and definer functions are tested on their own body, because the body is the only check on which rows a permitted caller gets back.
How to run the two-tenant matrix
Run the matrix on Supabase's local stack, or on a development or staging project of your own that holds only invented data, never on a live project.
It uses two invented tenants, two invented users and invented records. Nothing on this page connects to anything: the matrix is text you copy into your own SQL editor and app, and the Supabase RLS checklist among this library's tools does not connect to or verify a live project either.
Where staging and production share a schema, build staging from the same migrations, so the policies you test are the policies you ship.
The SQL rows follow the method in Supabase's own test guide, which runs its pgTAP tests against the local database started with supabase start. Its example test file runs in one transaction that rolls back at the end, so the test data never persists, and set local role with set local request.jwt.claim.sub sets the role and user each assertion runs as, the way a signed-in user's request does.
Supabase's examples insert their invented users into auth.users inside that transaction, and the matrix's seed does the same. Supabase's test guide shows this method on a local database started with supabase start.
This page asks you to run the SQL rows only on your local stack, or on a staging project that holds only invented data. In the T, V and R rows, each cell is one transaction: start it, run the seed, switch role and user, run the cell's statement and any intact check, read the results and roll back.
A write that raises an error is recorded as refused and the cell ends there; PostgreSQL's CREATE POLICY reference says a row that fails a with check expression causes an error and the entire command is aborted.
A write that raises no error needs its intact check before the rollback, because the rollback undoes everything the transaction did. The denied insert and move cells leave out returning on purpose. PostgreSQL's CREATE POLICY reference says that when a data-modifying statement has a RETURNING clause, a newly inserted or updated row that does not satisfy the table's SELECT policies causes an error. That error would look like a with check refusal even where the with check expression is missing.
The storage rows cannot use that approach. Supabase's test guide says application-level tests through the client cannot use a transaction to keep their data from persisting, and its storage schema page says Storage operations belong to the API. Those rows use real sign-ins on staging for two invented users, created with email addresses you control, because Supabase's Auth general configuration page says that with "Confirm Email" on, users need to confirm their email address before signing in for the first time.
Each storage row that sends requests, S1 to S4, uses small invented test files, and its limits end with the clean-up: the test files, the invented tenants and their membership rows, and both users. S5 sends no request.
Fill the evidence column from the catalogue, not from memory. PostgreSQL's pg_policies view gives each policy's schema, table, name, whether it is permissive, its roles, its command, its qual and its with_check expression, and pg_class records whether RLS is enabled and forced on each table.
Supabase's test guide is clear about the limit of that evidence: a check on pg_policies passes while the policy is still wrong. The policy text records what you wrote, and the result cells record what the database did.
Supabase's guide also describes a check on the test suite itself: adding a temporary policy using (true), confirming a test fails, then dropping it. That changes the project's policies, so it is left out of this matrix.
Teams that want the matrix as a regression suite can turn each SQL row into a pgTAP file under supabase/tests and run supabase test db on their local stack, as Supabase's guide sets out.
What a review of your own project cannot show
The matrix tests the database's decisions for the roles, users and records you seeded.
A policy with a branch your invented records never reach, such as a status column or a plan limit, goes untested, so add rows for each branch your real policies contain.
It cannot see inside code that holds a secret key. Server routes, background jobs and Edge Functions that query with a secret key and no user token skip RLS, so their tenant scoping is a property of the code. The API keys guide also says Edge Functions need to authorise API keys in code, because the verify_jwt platform check alone does not authenticate a caller that sends only an API key. Testing those paths is a test of the application, not of the database.
It leaves out Realtime. Supabase's production security checklist says to enable RLS and create policies on every replicated table that holds sensitive data, and that RLS does not filter Postgres Changes DELETE events. If your app subscribes to database changes, that needs its own check.
It is a snapshot of staging. A migration that adds a table, a view or a function changes the answer, and a staging project whose grants differ from production's answers a different question. Rerun the rows that touch anything a migration changes.
And it cannot see Supabase's side of the shared responsibility model. Evidence about the hosted platform comes from Supabase, and Supabase's testing policy keeps a customer's own testing to the services within the customer's project.
Supabase's testing terms, read before any active test
Supabase publishes a penetration testing policy for its customers.
It says customers of Supabase are permitted to carry out security assessments or penetration tests of their hosted Supabase project components, and may do so without prior approval for the services it lists as permitted: Authentication, Database, Edge Functions, Storage and Realtime, at the project's own supabase.co and db.supabase.co addresses.
It says this section of the policy is covered by Supabase's Acceptable Use Policy, and that it is the customer's responsibility to ensure testing activities are aligned with the policy.
Its prohibited list names any activity contrary to the Acceptable Use Policy, denial of service and distributed denial of service testing, request flooding, and cross-tenant attacks, which it describes as testing that directly targets other Supabase customers' accounts, organisations and projects not under the customer's control.
Supabase does not permit hosting security tooling that may be perceived as malicious or part of a campaign against Supabase customers or external services. Testing outside the policy will be seen as testing directly against Supabase and may be flagged as abuse.
Under the policy's terms and conditions, the customer agrees that security testing will be limited to the services within the customer's project, is subject to the general Terms of Service, is within the Acceptable Usage Policy, and will be stopped if Supabase makes contact about a breach of those terms or a negative impact on Supabase and its customers, and that any vulnerabilities discovered directly in a Supabase product will be reported to Supabase Security within 24 hours of completion of testing. Customer penetration testing is not part of the vulnerability disclosure program Supabase runs with HackerOne.
The word tenant means something different in Supabase's policy and in the matrix. In the policy, cross-tenant attacks are those that directly target other Supabase customers. The two tenants in the matrix are customer organisations inside your own application, on a project you control. Read the policy, the Acceptable Use Policy and the Terms of Service as they stand on the day, and keep that date with your test records.
Where a Clever Ops assessment fits
This guide is informational.
The Clever Ops methodology puts services run by other businesses and your host's platform outside the method. Supabase's policy, for its part, keeps a customer's testing to the services within the customer's own project.
Active testing of your own application sits within a scoped assessment. For an app made with an AI builder, such as one on Supabase or Firebase, the vibe-coded app security check concentrates on data exposure, authentication, secrets, payments and abuse, including database rules that let one user read another user's data and keys shipped to the browser.
For a custom application with an API behind it, the web application and API penetration test is a signed-in test of the application and the API behind it, run from test accounts in each role the scope names. Larger and multi-tenant applications are scoped individually after a longer call.
The scope asks for two test accounts for each role, and accounts in two separate customer organisations if your application serves more than one, because only accounts on both sides of the boundary can show whether cross-tenant controls hold. Testing begins once the owner of each target has signed an authorisation and the hosting provider's testing policy has been checked, and read-only code access to named areas, such as the permission checks, can be added when it is part of the agreed scope.
If Clever Ops built or hosts your application, the work is a security review rather than an independent test, and the report says who built it and who hosts it. The report is evidence for a decision a customer or auditor makes, and it is not a certificate for the application.
Clever Ops is not CREST accredited, so where a tender or contract requires CREST, we refer that work to a provider that is. No Clever Ops service includes load testing, and Supabase's policy prohibits denial of service testing.
Frequently asked questions
Supabase's API keys guide calls anon the legacy version of publishable keys and gives both low privileges, and it lists the publishable key as safe to expose online, reaching only what Row Level Security allows. Supabase's Advisors page says the anon key maps to the anon Postgres role. What that role, and authenticated once a user signs in, can reach is decided by your grants and policies, so the question to ask is whether every table, view, bucket and function those roles can reach has the policies you intended.
Supabase's Postgres roles page describes service_role as the role the API (PostgREST) uses to bypass Row Level Security, and its API keys guide calls the service_role key the legacy version of secret keys. The API keys guide says secret keys work through the service_role Postgres role, which has the BYPASSRLS attribute, so policies never apply to a secret key. Its Row Level Security guide adds that a secret key bypasses RLS only when the request carries no user access token, and that a request carrying one runs under that user's policies. The API keys guide says never to put a secret key in a browser, a shipped application or source control.
A using expression that filters a row out raises no error. Supabase's Row Level Security guide says such a statement matches zero rows, while a missing grant and a with check violation each raise 42501. It also says an update needs a matching select policy to work as expected, and PostgreSQL's CREATE POLICY reference says an update that reads the table's columns, for example in a WHERE or RETURNING clause, typically needs select rights too, with the select policies applied in addition. Add returning to an allowed update to see which rows it touched.
Not by default. Supabase's guide says views bypass RLS by default because they are usually created with the postgres user. In Postgres 15 and above, setting security_invoker = true makes a view obey the policies of its underlying tables for anon and authenticated; on older versions, Supabase says to revoke the view from those roles or keep it in a schema that is not exposed. Supabase's Advisors page says materialized views cannot be protected by Row-Level Security.
Supabase's test guide runs pgTAP tests against a local database with supabase test db, inside a transaction that rolls back, switching role and user with set local role and set local request.jwt.claim.sub. Supabase's test guide shows that method on a local database. The matrix on this page uses the same switches on your local stack, or on a development or staging project of your own that holds only invented data. Storage requests cannot be rolled back, so those rows use invented users and test files that you remove afterwards.
Supabase answers with a shared responsibility model rather than a verdict. Its model says the customer is always responsible for their account, access management, data and applying security controls. It also makes the customer responsible for the right level of access on tables with sensitive data, and it recommends always applying Row Level Security. Whether one customer organisation in your app can read another's rows depends on those settings, which is what the matrix checks.
Scope the right test for your application
Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.