In April 2023 a security researcher named Charan Akiri started poking at public Salesforce Community sites and found he could read other organizations' records without logging in. There was no exploit and no zero day. The guest user profile on those sites carried permissions nobody meant to grant, and the Aura API answered questions it should have refused. Vermont's pandemic unemployment portal was among the sites affected, leaking names, Social Security numbers and bank account details to anyone who knew the endpoint.
Salesforce's public response was accurate and also the point: the platform was not broken, customer configuration was. Every one of those organizations believed its data was isolated, and at the record level it probably was. The failure sat somewhere else entirely.
That is how most tenant isolation failures look. The database does what you told it to. Something adjacent, a cache, a search index, a background worker, a support export, answers a question nobody asked it to answer. Multi-tenant architecture gets discussed as a schema decision, and it is partly that, but the schema decision is the part that gets reviewed. The copies rarely get the same treatment, and they are what leak.
Pick a model, then admit what it does not cover
AWS Well-Architected's SaaS Lens splits tenancy into three shapes. Silo gives each tenant its own infrastructure, so the isolation boundary is physical and a cross-tenant read is architecturally impossible. Pool shares everything and separates tenants with a tenant_id column plus runtime enforcement. Bridge mixes the two, often pooled for a self-serve tier and siloed for accounts that pay for dedicated capacity or carry a data residency requirement.
The cost curve is the reason pool wins by default. Silo is commonly quoted at ten to a hundred times the per-tenant infrastructure cost, and the operational overhead grows with every customer you add. That does not make pool the cheap option once you price the engineering. In a pooled system the isolation boundary is logic, and logic has to be correct at every point where tenant data is touched. Miss one and the blast radius is every customer on the cluster. Silo pushes the mistake out of reach and keeps the damage inside one account, which is worth something when a contract renewal is on the line.
What most teams actually run is a bridge without naming it: one shared Postgres cluster for everyone, with a separate database for the two customers whose contracts mention auditors. That is a reasonable place to land. The failure mode is treating the shared part as if it inherited the siloed part's guarantees. It does not. The dedicated database has a wall around it. The shared one has a policy, and a policy is a piece of code that runs in the database whether or not anybody remembers it exists.
What Postgres row-level security actually enforces
Row-level security is the right default for a pooled schema, and it is easy to switch on in a way that looks done and does nothing. Several of the traps below are documented in the Postgres manual and still show up in production systems, so treat this as a checklist rather than a warning about exotic edge cases.
Table owners bypass row security unless you force it. You enable RLS, you write a policy, you test it as the application user, everything behaves, and then the service connects as the role that owns the tables and the policy never runs. ALTER TABLE invoices FORCE ROW LEVEL SECURITY is the fix, paired with an application role that is not the owner and does not hold BYPASSRLS. Superusers ignore policies entirely, which matters more than it sounds, because a good number of "it works on staging" investigations end with someone connecting as the superuser to check something.
A policy with a USING clause and no WITH CHECK stops reads across tenants and lets writes through. The tenant reads only its own rows, then inserts a row stamped with someone else's tenant_id. That break is quieter than a leak, since nobody sees the data leaving, and it takes a deliberate test to find.
Unique constraints and foreign key checks ignore row security, because the database has to preserve referential integrity across the whole table. The practical consequence is a covert channel. Put a global UNIQUE on users.email and a duplicate-key error tells tenant B that tenant A already registered that address. Postgres will not show the row, but it will confirm the row exists. Scope the constraint to the tenant, UNIQUE (tenant_id, lower(email)), and include tenant_id in primary and foreign keys so the checks compare rows within a boundary rather than across it.
Then there is connection state. The recommended pattern is to set tenant context inside a transaction with set_config('app.tenant_id', $1, true), which is the local variant and resets at commit, run every query for that request on the same client, and release it after. Use the session-scoped version with a connection pooler and the context sticks to the connection. The next request that picks up that connection inherits the previous tenant. PgBouncer in transaction mode makes this harder to reason about than it looks, and prepared statements cached per connection will happily reuse a plan built under a different tenant setting.
All of that argues for a test suite that connects as the application role, sets context through the same path the application uses, and asserts what comes back, rather than against RLS.
The copies are where isolation dies
There is a well documented incident pattern that goes like this. A user in tenant A opens invoice 1001. The cache misses, the query runs, RLS filters correctly to tenant A, and the application stores the result under invoice:1001. A user in tenant B opens their own invoice 1001, the cache hits, and tenant B reads tenant A's invoice. Postgres never saw the second request. There was nothing for the policy to filter.
One missing field in one key string, and the database was configured correctly the whole time. The policy was tested. The leak went through a system the policy does not govern.
The fix that generalizes is to stop letting keys be assembled by hand. Every cache key comes from one function that reads the current tenant from the request context and throws if there is no tenant, so the key is t:{tenantId}:invoice:{id} or the call fails during development instead of leaking in production. Apply the same rule to queue payloads, object storage paths, search document IDs, cache tags, and rate limit buckets.
Worth an audit in every system that added AI features recently: the vector store. Embeddings retrieved without a tenant filter produce a knowledge base that blends customers together, and the failure is invisible because the output looks like a confident answer rather than a data breach. Namespaces per tenant, or a metadata filter enforced in the retrieval layer rather than the prompt. The retrieval layer is the trust boundary. If it depends on a prompt instruction to stay in its lane, it is not a boundary.
The honest accounting move is to list every place tenant data lives (Postgres, Redis, the search cluster, the object store, the queue, the warehouse, the log pipeline, the backups) and write down what enforces the boundary in each one. In most systems the database column reads "RLS" and three of the others read "convention." Convention is a person remembering, and people rotate.
Noisy neighbors are a boundary problem too
Isolation gets framed as confidentiality, which leaves out the other half: one tenant's load should not become another tenant's outage. A global rate limit of 500 requests per second is not a limit on any tenant, it is a limit on all of them together, and one customer importing a catalog can consume the entire allowance while everyone else gets 429s. Postgres max_connections defaults to 100. A burst from a single tenant can exhaust an application connection pool that was sized for the whole customer base.
Layered controls work better than one clever one. A token bucket per tenant_id at the gateway, with burst and sustained rates separate, gives every tenant a ceiling without punishing anyone for a legitimate spike. Per-user pool sizes in PgBouncer cap how much of the shared connection budget one tenant can claim. Queues need partitions or per-tenant concurrency caps, otherwise a tenant's 400,000-row backfill puts every other tenant's report behind it in line. Heavy jobs belong on a separate lane from interactive traffic. Weighted fair queuing is a step past hard limits: each tenant gets a share proportional to its tier, so a free account slows down instead of stopping while an enterprise account keeps moving.
None of this needs new infrastructure. What it needs is per-tenant instrumentation, so you can answer which customer caused the slowdown. Most teams cannot answer that question because their metrics aggregate across the whole estate. A single tenant_id label on request latency, queue wait, and pool checkout turns an argument into a dashboard.
Tests that would have caught all of this
Cross-tenant testing is unglamorous and it is the only way to know. Seed two tenants with overlapping identifiers, which is the realistic case, then for every resource type take tenant B's object ID and request it as tenant A. Assert a 404, not a 403. A 403 confirms the record exists and belongs to someone else, which is a small leak and a useful signal for an attacker enumerating IDs.
Then extend the suite past the request path, because that is where the coverage usually stops. Run the same checks against the list endpoints with pagination, the export and reporting jobs, the search API, the graph endpoints, and any bulk update. Fire the background workers directly with tenant A's job payload, since queue consumers typically run under a system role that spans tenants and therefore tests nothing. Attempt an insert with a foreign tenant_id and confirm it fails. Register the same email in both tenants and check what the error message says. Ask for a signed file URL and try it against the other tenant's object. Delete a tenant and verify the cascade reaches the cache, the index, and the backups, because restores that have never been tested are the other half of that story.
The last test is a grep. Search the codebase for query construction that touches tenant tables and confirm every path either relies on RLS or filters explicitly, with no exceptions for the admin dashboard that shipped at 2am. Admin tooling is where the filters go missing, and it is usually reachable by more people than the team assumes.
Order of work
- Turn on RLS with
FORCE, separate the application role from the owner, and addWITH CHECKto every policy. - Move tenant keys into one constructor function and make a missing tenant a hard failure.
- Scope unique and foreign key constraints to the tenant.
- Add per-tenant rate limits, pool caps, and queue partitions, in that order of effort.
- Build the cross-tenant test suite, run it in CI, and keep two tenants seeded permanently for it.
- Write the inventory of tenant data locations and the control that protects each one. Update it when a new store appears.
Any one of those steps is a week of work. Doing none of them is fine right up until the second customer signs, which is the point where a single missing filter becomes a breach notification with a legal budget attached. The architecture decision is the part that gets the meeting, and the copies are the part that produces the incident.
If your team runs a pooled multi-tenant platform and cannot say what enforces the boundary in the cache, the search index and the queue without looking it up, that gap is worth closing before the next enterprise contract asks about it. Tech Hub Services reviews Laravel, Node and Postgres estates for this, and the deliverable is a list of specific gaps with reproductions attached, not a maturity score.