Host and Tenant Derivation Robustness
Confirm tenants are derived from server-verified context, so host headers, subdomain aliases or client hints cannot redirect a request into another tenant's view
Use when: the product resolves tenant context from hostnames, subdomains or path hints rather than from tokens alone
Avoid when: tenant context lives solely in a signed token claim that the server verifies and nothing derives from the request
Procedure
- Record the derivation order: host, subdomain, port, token claim and header, noting which inputs the server actually trusts.
- Call identical endpoints with each of your two tenants' hostnames while holding both credentials, and record the pairing outcomes.
- Test with manipulated hosts inside your own test domain: alternate case, added slash, trailing dot and unknown subdomain names.
- Check requests where the token's tenant claim differs from the derived host, and verify the server has a defined precedence rule.
- Inspect caches and background jobs, since they may persist the derived tenant longer than the request needs it.
- Record the derivation rule per endpoint and any call that conflicts with it for the pairing you measured.
Signals
- A request initiated deliberately under one hostname resolves to the other tenant when the host header is adjusted inside your own domain.
- Tokens carry tenant claims the host header overrides regardless or, vice versa, the server merely ignores the host context it classified.
- A trailing-dot or case variation on the hostname resolves into the same or a different tenant computation depending on arrival order.
- Cached views or CDS records key on a hostname that a caller can also manipulate inside the next request.
Patterns
1. Pairings
credential=tenant-A host=app.other-tenant-officer.test -> response scope? -> A or B?
2. Ordering
token claim=tenant-A host=tenant-B => precedence documented=no conflict-unresolved
3. Result row
derivation=host-first claim-check=skipped cross-tenant-call-performed=yes-leak-found
Pitfalls
- Assuming host-derived tenant context is safe because the caller cannot own the hostname, while internal routers and caches still do.
- Ignoring inserts with a token-report mismatch because both signals conflicted, yet the server honored whichever came with precedence.
- Publishing an ambiguous result without the exact host, credential and ordering that produced the tenant selection.
Done when
- The derivation order is recorded with proven precedence rules and no call has an undocumented pairing.
- Cross-tenant host manipulations are tested and every response derived state is attributed to its chosen context.