Cache Key Authorization Alignment
Verify response caches key on identity and tenant, so one caller's authorization state never serves another caller its content
Use when: the stack includes response caches, CDNs, edge caches or per-tenant intermediaries in front of authorized endpoints
Avoid when: the API is uncached end to end and you can prove every request runs through the authorization check directly
Procedure
- Trace which layers cache: edge proxy, application-instance memo, browser directive and service-level deduplication.
- Issue the same authorized operation repeatedly with each of your two identities and diff response bodies where caching may differ.
- Inspect cache-related response headers for which content is shared and which carries identity-sensitive state across callers.
- Test whether identity-changing request attributes alter the served copy: credential, tenant, locale and client version headers.
- Check writes after reads, since a cached authorized response may continue serving content after state changed beneath it.
- Record each cache layer with its key inputs so the report can state exactly which parts of the pipeline are identity-aware.
Signals
- A response addressed to one caller is also served to a second caller, or partial body differs only by call count rather than identity.
- Identity-specific cache key parts exist only for a few endpoints while the majority forget them.
- After role or ownership change downstream, the served copy does not re-authorize and instead serves stale authorized output.
- Tenant-specific details leak to another tenant when the cache sees a similar parameter set with a different credential.
Patterns
1. Key inventory
layer=app-cache key_path=credential,tenant,locale since_billed=Vary:Authorization
2. Shared cache
alice-request cached -> bob plans same -> served alice's body -> identity skipped from key
3. Result row
endpoint=/api/me cache=edge key=vary=none identity-served-to-others=yes
Pitfalls
- Estimating caches by the response headers you saw in browser tools, missing intermediaries that never emit headers.
- Testing reads without also testing the write-invalidation path, which is where staleness becomes a real authorization break.
- Attributing the leak to the incorrect layer without isolating which cache involved actually carries the identity-erred key set.
Done when
- Every cache layer in the pipeline has a documented key inventory, including upstream and internal ones without response headers.
- Identity-erred keys, if found, are located at a specific layer with reproducible requests showing the wrong body served to the wrong caller.