Multi-Tenant Access Control Prompt
Keep tenants out of each other's data — design the isolation model, the tenant-scoping rule every query must obey, and the cross-tenant leaks to test for.
Overview
In a multi-tenant system, the worst bug is one tenant seeing another's data, and it's one missing WHERE clause away. This prompt designs tenant isolation: the model (row-level, schema, or database), the scoping rule every data access must enforce, where the tenant context comes from (and why it can't be client-trusted), and the cross-tenant leak paths to test — shared caches, background jobs, admin tools.
Why This Works
- Central scoping beats per-query filters you can forget — the #1 leak cause
- Deriving tenant from auth (not the request) closes the obvious tampering path
- The leak-path list catches caches and jobs that bypass the main scoping
Best for
- Multi-tenant SaaS handling separate customers' data
- Marketplaces and B2B apps with strict data boundaries
- Teams adding multi-tenancy to a single-tenant app
Not for
- Single-tenant apps
- General authorization within one tenant — use the Authorization Review Prompt
Use cases
- Designing data isolation for a SaaS platform
- Preventing the missing-WHERE-clause cross-tenant leak
- Listing the cross-tenant paths a security review must test