· 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.

Assertwise lab: OWASP API1 BOLA checklist card
Lab checklist card for BOLA checks.

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

  1. Tenant A + user A1 (member).
  2. Tenant B + user B1 (member).
  3. One object type with a stable ID in the path or body (account, invoice, project, message).
  4. 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

VariantWhat to tryPass
Nested IDValid tenant B in path + object ID from ADenied
Batchids=[INV_A, INV_B] as B1Only B?s objects returned
Export / async jobStart export for A?s filter as B1Job rejected or empty
SearchQuery param with A?s customer email as B1No A rows
WebhookReplay A?s signed event with B?s endpoint configSignature/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.