TL;DR
- Cross-tenant testing verifies that one customer cannot read, change, infer, or trigger work on another customer’s resources.
- Use separate synthetic tenants and principals with known ownership. Test every route and data path with identifiers from a different tenant.
- The 15 cases below cover object IDs, nested resources, writes, bulk APIs, roles, tokens, asynchronous work, caches, PostgreSQL row-level security, identity provisioning, and side channels.
- Run the application-only suite with PostgreSQL RLS disabled, then run it with RLS enabled using the production-equivalent application role. A test role that owns tables or bypasses RLS can hide failures.
- Keep evidence reproducible: record endpoint, principal, tenant, fixture, expected result, observed result, and build or commit identifier. Passing a checklist is not a certification.
Define the isolation boundary before testing it
A multi-tenant penetration test asks whether a principal acting for tenant A can reach data or perform actions belonging to tenant B. The boundary includes more than a database row. It covers object identifiers, child records, files, search results, API tokens, background jobs, webhooks, caches, exports, logs, and identity provisioning.
Broken Object Level Authorization (BOLA), also called insecure direct object reference (IDOR), occurs when the server uses a client-supplied object identifier without verifying that the authenticated principal may access that specific object. IDs can be sequential, UUIDs, slugs, or opaque strings; randomness does not replace authorization. OWASP recommends object-level authorization checks in every function that uses an input ID to access data. OWASP API1:2023 Broken Object Level Authorization · OWASP IDOR Prevention Cheat Sheet
Write a short isolation contract before building the test environment. Define tenant identity source, membership rules, cross-tenant administrator capabilities, service-account scope, expected response behavior for inaccessible objects, and whether any data is intentionally shared. Document the exception paths. “Admins can see everything” is too broad unless it names which administrators, which tenants, which fields, and which auditable workflows.
Use an isolated staging environment with synthetic data. Create at least two tenants with deliberately similar names, users, records, and file paths so tests cannot pass through accidental nonexistence. Add separate owner, administrator, editor, reader, and unprivileged principals. Issue real test credentials through the normal login and token flows. Never use production customer data or a production admin token for this exercise.
Set up a repeatable role and ownership fixture
Give every fixture an explicit owner tenant and keep a manifest of generated object IDs. Include records with nested children, attachments, long-running jobs, and searchable text. Place distinctive canary strings in fields and files for each tenant. Use these only in the isolated test environment so a leak is easy to identify in a response, export, log sink, or search result.
For each request, vary one factor at a time: principal, tenant membership, HTTP method, object ID, parent ID, token type, or RLS setting. Send the same request first as the owning user, then as the cross-tenant user, then as a revoked or unauthenticated principal. The authorized control request proves the resource exists and makes a denial meaningful.
Test denial consistently. Depending on product policy, a server may return 404 to avoid confirming resource existence or 403 when disclosure is acceptable. Either response can be valid if it does not include protected content or trigger a side effect. Verify database state, event queues, and external calls as well as the HTTP status.
The 15 cross-tenant test cases
1. Swap a direct object identifier
As tenant A’s reader, request a record owned by tenant B using B’s known ID in the path, query string, and JSON body. Repeat with sequential IDs, UUIDs, slugs, and IDs discovered through a test fixture. Expect no protected data and no indication that a guessed identifier is valid unless the API deliberately discloses that fact.
2. Cross the parent-child boundary
Request a child resource such as an invoice line, message attachment, project task, or comment by its own ID while supplying a parent ID from tenant A. Also try tenant B’s parent with tenant A’s child. Verify the server checks ownership of both objects and their relationship rather than trusting either identifier independently.
3. Attempt cross-tenant mutation and deletion
Send PUT, PATCH, and DELETE requests for tenant B’s record using tenant A credentials. Include legitimate field changes as well as attempts to change state, ownership, or status. Confirm the record is unchanged, no event or notification was emitted, and audit logs identify the denial without recording sensitive values.
4. Test list, search, filter, sort, and pagination
Call collection endpoints without tenant filters, then add filters for another tenant’s ID, email, status, owner, and time range. Test search terms containing B’s canary string. Follow next-page cursors after authorization changes. Verify every page and aggregate count reflects only records visible to A, including when the filter returns zero matches.
5. Test exports, downloads, and generated reports
Try to create or download tenant B’s CSV, PDF, backup, or report by swapping its job ID, file key, or signed download token. Test a report that aggregates multiple tenants and a report generated asynchronously. Confirm that the authorization decision is repeated when a file is downloaded, not only when its generation was requested.
6. Probe mass assignment and ownership fields
Submit otherwise valid create and update payloads containing tenant_id, owner_id, created_by, role, plan, billing_account, or internal status fields. Try nested objects and alternate casing or aliases. Expect unknown or unauthorized properties to be rejected or ignored under a documented policy, and verify the stored owner remains server-derived.
7. Switch tenant context and user roles
Change tenant IDs in headers, subdomains, route parameters, cookies, and token claims. Try a reader’s token against an admin route and an administrator’s token in a different tenant. Exercise role changes and membership revocation while a session remains open. Verify each request resolves current authorized membership rather than trusting stale client context.
8. Call privileged functions through alternate routes
Attempt administrative actions using the ordinary endpoint with a changed HTTP method, GraphQL mutation, bulk operation, mobile API, legacy version, or undocumented route discovered in the test inventory. Try exports, user invitations, role changes, impersonation, and billing operations. Authorization must follow the action and resource, not the URL prefix or UI visibility.
9. Reassign queued and scheduled work
Create a report or background task as tenant A, then try to alter its tenant, payload, callback, or resource ID before execution. Trigger retries and scheduled jobs after membership revocation. Confirm the worker obtains tenant scope from trusted persisted state, revalidates the resource, and does not accept a client-supplied tenant field as authority.
10. Reuse and broaden tokens
Use a tenant A API key, personal access token, refresh token, service credential, or webhook secret against tenant B endpoints. Try changing audience, scope, tenant claim, token subject, and resource identifier. Revoke the token and verify the old credential stops working across every route, worker, and cache that accepts it.
11. Check caches and shared infrastructure
Request a record as tenant A, then make the same URL request as tenant B and inspect the response, CDN, application cache, and rendered page. Repeat for export URLs and signed media links. Cache keys must include the effective authorization scope or store only content safe for every caller. Revoke access and check that cached data expires or is invalidated.
12. Repeat application checks with PostgreSQL RLS disabled
Run the same API suite against a test database where RLS is disabled. The application’s tenant-scoped query and service authorization should still prevent cross-tenant access. This isolates whether the application layer works on its own and prevents the database policy from masking missing checks in handlers.
13. Repeat with RLS enabled as the runtime role
Enable policies and connect using the same restricted runtime role used by the application, not the migration owner or a superuser. Try a missing tenant context, an invalid tenant context, a query with no tenant predicate, and a direct SQL path. Verify SELECT, INSERT, UPDATE, and DELETE behavior, including that tenant ownership cannot be changed across boundaries. PostgreSQL documents that table owners and roles with BYPASSRLS can bypass policies unless the configuration accounts for them. PostgreSQL row security policies
14. Test connection reuse and tenant-context reset
With the production pooling mode, run tenant A and B requests sequentially and concurrently through the same pool. Force exceptions and rollbacks between requests. Confirm transaction-local tenant state is set before protected SQL and does not survive into another transaction. Test a worker that resumes after lease expiry and a request that exits early. A stale session setting can turn connection reuse into cross-tenant access.
15. Verify identity provisioning, files, and telemetry boundaries
Attempt to provision a tenant B user or group through tenant A’s SCIM configuration, identity-provider mapping, webhook, or invitation flow. Try a file path from another tenant and search audit logs, traces, analytics, and error reports for the canary string. Confirm tenant identity comes from the authenticated integration configuration and that diagnostic systems do not expose protected records across customer access boundaries.
Run each case as a controlled experiment
For every test case, preserve the request, identity, expected behavior, observed status, response body classification, database assertion, and side-effect assertion. A compact evidence record might look like:
case: cross-tenant invoice read
principal: tenant-a-reader
resource_owner: tenant-b
request: GET /api/invoices/{tenant-b-id}
expected: no invoice fields, no related events
observed: 404, zero rows returned, no event emitted
environment: staging build 4f2c1d, RLS enabled, app_runtime role
The values above illustrate an evidence format only, not a measured test result. Store evidence in a restricted location, redact tokens and personal data, and keep enough information for an independent engineer to reproduce the case. Link each regression test to a finding and remediation. Do not call a test passed based only on a browser screenshot when database state or queued side effects could still be wrong.
Automate stable cases at the API and service layer. Use a small number of integration tests against the real database role and connection pool configuration for RLS and session-context cases. Add concurrency tests where the failure depends on two requests racing. Keep a manual test step for flows that depend on a real identity provider or cloud storage provider, and document how the test identity is reset after the exercise.
Test with RLS both disabled and enabled, as described in cases 12 and 13. If the suite passes only when RLS is enabled, application handlers may be missing tenant authorization. If it passes only with RLS disabled, policies or tenant context may be incorrect. The two modes are different evidence about defense in depth, not substitutes for one another. For a deeper discussion of policy context, see PostgreSQL RLS in multi-tenant applications.
Interpret findings and prioritize remediation
Prioritize actual data access and state-changing actions, then determine which shared systems amplify the impact. A BOLA read can disclose customer records. A write can alter or delete another tenant’s state. A cross-tenant export or search index may expose a much larger population. A stolen service token or weak provisioning rule can establish durable access. Record affected data classes, required attacker privileges, reachability, and any evidence of real exposure.
Fix the authorization boundary at the server-side service or repository layer used by all routes. Add object-level checks for the verified principal, derive tenant scope from trusted membership, and reject forbidden property changes. Add RLS as defense in depth where it fits the architecture, then retain application checks. Avoid hiding failures by changing every denial into a generic error without validating that no side effect occurred.
Retest the original exploit path and neighboring operations after remediation. Add the reproduced case to CI with a control test showing the owning principal still succeeds. Review whether the same pattern exists in GraphQL, exports, workers, webhooks, and old API versions. Close a finding only when its scope is understood, the control is deployed, and the regression proof runs in the supported environment.
What this checklist does not establish
These 15 scenarios are a practical starting set, not a complete penetration test plan for every SaaS product. Real systems may include shared workspaces, delegated administrators, data residency partitions, regional replicas, partner integrations, or deliberate cross-tenant analytics. Extend the matrix for those paths and obtain authorization before testing third-party systems.
A passing suite is evidence about the cases and environment tested. It does not prove there are no other vulnerabilities or automatically satisfy SOC 2, ISO 27001, or a customer’s security review. Use the results alongside threat modeling, secure development controls, monitoring, incident response, and an independently scoped assessment where required.
Frequently asked questions
Should an inaccessible tenant object return 403 or 404?
Choose a consistent product policy. A 404 can avoid confirming that another tenant’s object exists, while 403 communicates a known resource with denied access. In either case, return no protected fields, preserve the object state, and emit no unauthorized side effects. Test the policy across direct reads, lists, exports, and nested resources.
Do PostgreSQL row-level security policies replace application authorization?
No. Application code still authenticates the principal, checks tenant membership and action-level permissions, and sets the intended tenant context. RLS can limit accidental broad queries, but table owners and bypass roles require care. Test with the application runtime role and run a separate suite with RLS disabled.
Are UUIDs enough to prevent cross-tenant IDOR?
No. Unpredictable identifiers can make guessing harder, but IDs can leak through logs, links, browser history, integrations, or other endpoints. Verify authorization for every object identifier on every read and write operation, regardless of its format.
Does a passing 15-case checklist prove tenant isolation?
No. It documents evidence for those scenarios in the tested environment. Map the full product attack surface, add cases for its unique integrations and data flows, and rerun tests after changes. A checklist supports an assessment; it does not replace threat modeling or establish a certification.
Preparing a tenant-isolation review? Talk to Dumb Potato about test scope, RLS verification, and reproducible regression evidence.
