· Engineering notes
BOLA in multi-tenant SaaS: a tenant-swap test protocol
API1 gets expensive when object IDs cross tenants. Use this protocol to prove a user from tenant B cannot read or change tenant A?s objects ? with evidence you can paste into a ticket.

OWASP names this API1:2023 Broken Object Level Authorization. This post is only the multi-tenant protocol ? for the full Top 10 sprint checklist see API testing checklist (OWASP).
Why SaaS tenancy makes BOLA worse
- Object IDs are often sequential or guessable inside a shared schema.
- ?Admin? or support tools reuse the same object endpoints with a wider principal.
- Nested resources (
/tenants/{tid}/invoices/{iid}) get checked on the parent and skipped on the child. - Batch and export endpoints accept arrays of IDs and forget per-item authz.
Minimum lab setup
- Tenant A + user A1 (member).
- Tenant B + user B1 (member).
- One object type with a stable ID in the path or body (account, invoice, project, message).
- Two tokens; no shared ?god? API key in the test.
Artifact: tenant-swap protocol
1. Login as A1 ? store TOKEN_A
2. As A1, create or list an object ? store OBJECT_ID_A (and TENANT_A if needed)
3. Login as B1 ? store TOKEN_B
4. Replay the exact request that reads/updates OBJECT_ID_A with TOKEN_B
5. Expect: 403 or 404 (or empty list). Never 200 with A?s payload.
6. Repeat for: PUT/PATCH, DELETE, export, batch GET, webhook replay if applicable
Example HTTP evidence (replace host and IDs)
# A1 reads own invoice
curl -sS -D - -o /tmp/a.json \
-H "Authorization: Bearer $TOKEN_A" \
https://api.example.com/v1/invoices/INV_A
# B1 replays same object id
curl -sS -D - -o /tmp/b.json \
-H "Authorization: Bearer $TOKEN_B" \
https://api.example.com/v1/invoices/INV_A
# Pass: status 403/404 AND body must not contain tenant A fields
Variants that usually slip
| Variant | What to try | Pass |
|---|---|---|
| Nested ID | Valid tenant B in path + object ID from A | Denied |
| Batch | ids=[INV_A, INV_B] as B1 | Only B?s objects returned |
| Export / async job | Start export for A?s filter as B1 | Job rejected or empty |
| Search | Query param with A?s customer email as B1 | No A rows |
| Webhook | Replay A?s signed event with B?s endpoint config | Signature/tenant bind fails |
Payment-style follow-ups: payment API idempotency testing. Product context: SaaS testing.
Evidence pack for the ticket
- Request line + auth principal (user/tenant ids)
- Response status + redacted body hash or field list
- Expected vs actual (one sentence)
- Whether the defect is read, write, or delete
- Regression test name you added
Automate without flaking
- Provision tenants in test setup; never scrape IDs from shared staging pollution.
- Assert on status and absence of foreign tenant markers (id, name, amount).
- Keep a dedicated ?negative authz? suite in CI; quarantine only with an owner and expiry.
When to involve Assertwise
For a scoped API authz pass (OWASP-mapped findings with curl evidence, suite left in your repo), see API testing or book a free 20-min test audit.
Sample report context: how to read the sample report.