Skip to content
cloudgrip

$ cat labs/testing-tenant-isolation.md

//labs

Testing tenant isolation

How to test tenant isolation properly: two tenants, two accounts, every object reference, and why a 200 response with the wrong owner is the whole finding.

  • Nov 6, 2026
  • 4 min read
  • Cloudgrip team

In a multi-tenant product, many customers share one application and often one database, and the code is supposed to keep each customer's data separate. Tenant isolation is that separation. When it fails, one customer can read or change another customer's data, which is about as serious as a web application bug gets.

Testing it properly is not complicated. It needs the right accounts, a complete list of object references, and a strict rule for reading results. This note describes the method Hydra agents are designed to follow. You can run the same method by hand.

The setup: two tenants, three accounts

You cannot test a boundary from one side. The minimum setup is two tenants that have nothing to do with each other, with accounts in both.

Account Tenant Role Purpose
user_a Acme Member The attacker in most tests
admin_a Acme Admin Separates cross-user bugs from cross-tenant bugs
user_b Globex Member The victim, who owns the records we try to reach

The second account inside Acme matters. If user_a can read a private record that belongs to admin_a, that is a permissions bug within a tenant. If user_a can read a record that belongs to user_b, the tenant boundary is broken. The fixes are different, so the test should tell the two apart.

Two logins, one in each tenant, are enough to start: they show whether the tenant boundary holds. The third account adds the cross-user and role checks.

Next, give each tenant something to protect. As user_b, create one of every object type the product has: a project, a file, an invoice, an API key, a comment, an export. Put a unique marker string in each one, such as globex-marker-7f3a, and record every ID the application returns.

Walk every object reference

An object reference is any place where a request names a specific record. Isolation has to hold for every one of them, and the failures tend to sit in the places that are easy to overlook.

  • Path segments. /api/v1/projects/prj_2001
  • Query strings. /api/v1/export?project_id=prj_2001
  • Request bodies. {"comment": "hi", "project_id": "prj_2001"}
  • Nested references. /api/v1/projects/prj_1001/files/file_2001, where the project is yours and the file is not
  • Headers. A tenant or workspace ID that the client sends, for example X-Workspace-Id
  • Indirect references. Download links, export job IDs, webhook IDs, and anything else that points to a record through another record

For each reference, replay the request as user_a with the ID of the matching object owned by user_b. Do it for every HTTP method, because an endpoint that protects GET may not protect PATCH or DELETE.

Unguessable IDs do not change the test. Random identifiers make records harder to find, but IDs leak through logs, shared links, emails and other endpoints. The server still has to check who is asking. This flaw is known as broken object level authorization, and it belongs to the wider family of broken access control.

A worked example

Here is one check from start to finish, on a made-up API. user_b in Globex has created a project and received the ID prj_2001. Now user_a in Acme asks for it.

output
GET /api/v1/projects/prj_2001 HTTP/1.1
Host: api.acme.test
Authorization: Bearer <token for user_a>

A correct application answers like this.

output
HTTP/1.1 404 Not Found
Content-Type: application/json

{"error": "project not found"}

A broken one answers like this.

output
HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "prj_2001",
  "tenant": "globex",
  "name": "Q4 pricing review globex-marker-7f3a"
}

Why a 200 with the wrong owner is the whole finding

That second response is the complete finding. A user in Acme sent an ordinary request and received a record owned by Globex, with the Globex marker in the body. No further step is needed to show impact, because reading another tenant's data is the impact. This is the standard of evidence we describe in what counts as proof.

It pays to be strict about what counts, because status codes can mislead in both directions.

  • A 200 is not always a failure. Some applications return 200 with an empty list, or with an error in the body. Look for the marker, and do not rely on the code.
  • An error is not always a pass for writes. Send the PATCH as user_a, then read the record as user_b. If the change is there, the write went through, whatever the response said.
  • A 403 where other IDs get a 404 leaks existence. If a real ID in another tenant returns 403 and a made-up ID returns 404, an attacker can learn which IDs exist. That is a smaller finding, and still worth fixing.
  • Check the neighbors. An endpoint can protect the object itself and leak it through a list, a search or an export. Search for the marker string as user_a everywhere the product returns data.

Because both tenants are test tenants, the whole exercise is safe to run against production. No real customer's record is requested at any point.

Try this on your own system

  • Create two test tenants. Use separate email domains and no shared users. Add a marker record of every object type to each.
  • Test your five most sensitive endpoints by hand. Replay each one as a user from the other tenant, for reads and for writes, and look for the marker.
  • Find where tenant scoping lives in your code. If every query adds its own tenant filter, each new endpoint is a chance to forget one. A single enforced layer is easier to trust.
  • Add one isolation test to your test suite. One automated cross-tenant request per object type will catch a regression before release.

See what an attacker would find.

Give us a URL and two test logins. If there’s something to find, your first exploited findings land within 24 hours.

You talk to the people who build Hydra and Cerberus. No sales script.

or write to founders@cloudgrip.ai