# Use Case: Tenant Isolation Testing in a B2B SaaS, Before a Customer Finds the Gap

Dokimore Security Team · October 28, 2026, updated 2026-11-01 · 8 min read

Format: Scenario walkthrough · Written for: Security and compliance reviewers, Developers who own their tests, SDETs and automation engineers · Where it applies: every market

> The endpoint checks the caller’s role and forgets to check the record. One guessed identifier later, a customer is reading another customer’s data.

## In short

- Most tenant-isolation failures are one missing check: the endpoint confirms the caller is signed in and holds a role, then fetches the record by the identifier in the URL without confirming the record belongs to the caller’s tenant. OWASP calls it broken object level authorization and has ranked it first among API risks since 2019.
- The test is a matrix, not a scanner: two tenants with known records, every endpoint called with the other tenant’s identifiers in the path, the body and the query, and an expected 403 or 404 for each cell. A scanner cannot know which identifiers belong to whom; the matrix does.
- Defence in depth means the matrix is not the only line. On our own platform every tenant-scoped table carries a row-level security policy that is forced for the table’s owner too, a database event trigger refuses a new tenant table that lacks one, and a test pins which role may reach which route.

This is a scenario walkthrough of how a team tests tenant isolation. It is not a customer story; the company and its API are invented so the matrix is concrete, and the outside facts are in the sources at the end.

## The scenario

A B2B SaaS serves about 400 customer organisations from one database. It adds a reporting API: GET /reports/{reportId} returns a report, POST /reports creates one, and GET /exports/{exportId}/download returns a file. The handlers check that the caller has a session and the "analyst" role. They do not check that the report belongs to the caller’s organisation, because the front end only ever shows a user their own report identifiers. The identifiers are sequential. A customer’s analyst, curious, changes 4,812 to 4,811 in the address bar.

## What OWASP says about it

The OWASP API Security Top 10 has had two editions, 2019 and 2023, and in both the first entry is broken object level authorization: an API endpoint that accepts an object identifier and returns the object without checking that the caller is allowed to see it. The 2023 edition rates its exploitability easy, its prevalence widespread and its detectability easy, and its first example is a shop platform whose revenue endpoint accepts any shop name. Its prevention advice is four lines long: an authorisation mechanism built on the user’s policies and hierarchy, a check on every function that uses a client-supplied identifier, random and unpredictable identifiers, and tests written to evaluate the authorisation mechanism. The last line is the one most teams skip, and it is the subject of this walkthrough.

## Why scanners miss it

A dynamic scanner sends requests and reads responses, and a response that returns another tenant’s report looks exactly like a response that returns your own: a 200 and a JSON body. There is no syntactic signature. To see the failure you need two things a scanner does not have: a session in one tenant and the identifiers of objects that belong to another. Our own scanner reports a finding as confirmed only with a request, a response and a replay, and it cannot know which of your identifiers belong to which tenant; a cross-tenant gap is proven by the matrix below, run with the identifiers you seeded, not by a pattern a scanner finds.

## The two-tenant matrix

Create two tenants, A and B, each with a user, and seed each with known objects: a report, an export, a saved filter, a member. Write down every identifier. Then build the matrix: rows are endpoints, columns are the two sessions, and each cell is a request for the other tenant’s object. GET /reports/{A’s report} with B’s session expects 403 or 404 and a body that names nothing. POST /reports with B’s session and A’s organisation identifier in the body expects a refusal, not a report created under A. GET /exports/{A’s export}/download with B’s session expects no file. Every list endpoint is called with B’s session and checked for A’s identifiers anywhere in the payload, not only at the top level, because a nested object three levels down can carry the foreign identifier the top level hides.

Run the matrix in both directions and on every change to the API. In the scenario it is forty endpoints, eighty cells, and the first run fails eleven of them. The fix is one function, called from every handler: resolve the object, compare its tenant with the session’s, refuse before the body is built. The second run passes, and the matrix stays in the suite so the next endpoint cannot ship without a cell.

## Running the matrix with Dokimore

The API testing studio runs it as two environments, one per tenant, each holding that tenant’s session token in the credential vault and that tenant’s known identifiers as variables. One collection holds the forty requests; each request references the other environment’s identifiers and carries assertions on status and body: the status is 403 or 404, and the body does not contain any of tenant A’s identifiers. The collection runs on demand after each change, or on a schedule as a monitor against staging so a regression is caught the night it is merged. Importing a Postman or OpenAPI collection gives the request list in minutes; the assertions and the seeded identifiers are the work. There is no CI trigger from the platform yet; a team that needs the matrix inside its pipeline exports it and runs it there.

## What we do on our own platform

Dokimore is itself a multi-tenant SaaS, and the matrix is not our only line. Three controls sit behind it. Tenant-scoped tables in our Postgres database carry row-level security policies, forced so that the table’s owner cannot bypass them either, because a policy the application’s own role can skip is a comment, not a control. A database event trigger watches every new row-level policy and adds the tenant restriction when a table arrives without it, including the tables a database function creates at runtime; we added it after an audit found tables created after the first sweep that had none. And a test pins the route-authorisation matrix, which role may reach which route, so a route that loses its guard fails that test. The row-level policy is the last line, and it is there because the matrix catches the handler bug and the policy catches the handler bug nobody wrote a cell for.

## For the manager reading this

Ask one question of the API team: for which endpoints does a test request another tenant’s object and expect a refusal. If the answer is a list, read it against the endpoint inventory. If the answer is "the framework handles it", the matrix has never been run. It costs two tenants, an afternoon of seeding and a collection that runs after every change, and it is the cheapest security test a SaaS can own.

## What to do next

1. Ask the API team for the list of endpoints where a test requests another tenant’s object and expects a refusal; “the framework handles it” means the matrix has never been run.
2. Create two tenants with known seeded objects, write every identifier down, and build the matrix: rows are endpoints, columns are the two sessions, each cell the other tenant’s object.
3. Expect a 403 or a 404 with a body that names nothing, and check nested objects in list responses, not only the top level.
4. Run it in both directions on every change to the API; in the studio that is two environments, one collection and assertions on status and body ([API testing studio](https://dokimore.com/documentation/api-testing-studio)).
5. Add the database’s own last line: a row-level security policy on every tenant-scoped table, forced for the table’s owner too, and a guard that refuses a new table without one.

## Questions people ask

### What is broken object level authorization?

An API endpoint that accepts an object identifier from the client and returns or modifies the object without checking that the caller is allowed to act on it. OWASP lists it as API1 in the API Security Top 10 of 2019 and 2023, rates its exploitability and detectability easy and its prevalence widespread, and names "write tests to evaluate the vulnerability of the authorization mechanism" among its four prevention steps.

### Can a security scanner find tenant isolation bugs?

Rarely on its own, because a response with another tenant’s data has no syntactic signature; a 200 with a JSON body looks the same either way. A scanner needs a session in one tenant and the known identifiers of another, which is what the two-tenant matrix supplies. Dokimore’s scanner reports a finding as confirmed only with a request, a response and a replay; a cross-tenant gap is proven by the matrix, run in the API testing studio with the identifiers you seeded.

### How many tenants does the test need?

Two, with known seeded objects in each and the identifiers written down. Every endpoint is called with one tenant’s session and the other tenant’s identifiers in the path, the body and the query, in both directions, and each cell expects a 403 or a 404 with a body that names nothing of the other tenant, including in nested objects.

### Is row-level security enough on its own?

No, and it is not meant to be. A row-level security policy in the database is the last line: it catches the handler that forgot the check. It must be forced for the table’s owner, or the application’s own database role bypasses it, and a new table must not be able to ship without one. The matrix in the API tests is the first line, because it fails the build before the handler reaches the database.

### Should object identifiers be random?

OWASP recommends random, unpredictable identifiers, and they raise the cost of guessing. They are not a substitute for the authorisation check: an identifier that leaks in a shared link, a log or a support ticket is as good as a sequential one to whoever holds it, and the check on ownership is what refuses the request.

## How we measured this

- The company, its 400 tenants, its forty endpoints and the eleven failing cells are a scenario chosen so the matrix is concrete; no customer is described.
- Dokimore’s behaviour is the product on the article date: environments and a credential vault per tenant, assertions on status and body, collection runs on demand or on a schedule, Postman and OpenAPI import, and no CI trigger from the platform. Our own controls are stated at the level of the pattern, from our decision records; the policy, trigger and test names are internal.

## Sources

1. [OWASP API Security Top 10 2023, API1:2023 Broken Object Level Authorization: ratings, the revenue-endpoint scenario and the four prevention steps](https://api-security.owasp.org/editions/2023/en/0xa1-broken-object-level-authorization) (read 2026-10-28)
2. [OWASP API Security Top 10 2019, API1:2019 Broken Object Level Authorization: the first entry of the first edition](https://api-security.owasp.org/editions/2019/en/0xa1-broken-object-level-authorization) (read 2026-10-28)

Source: https://dokimore.com/blog/tenant-isolation-testing-before-a-customer-finds-the-gap
