# 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

- Skill: `wsh7ash/cache-key-authorization-alignment` (Agent Skill)
- Install (CLI): `npx get-skill add wsh7ash/cache-key-authorization-alignment`
- Raw SKILL.md: https://api.skillmd.com/api/skills/wsh7ash/cache-key-authorization-alignment/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Wsh7Ash (https://skillmd.com/u/wsh7ash)
- Updated: 2026-11-22
- Page: https://skillmd.com/skills/wsh7ash/cache-key-authorization-alignment

---


# 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

1. Trace which layers cache: edge proxy, application-instance memo, browser directive and service-level deduplication.
2. Issue the same authorized operation repeatedly with each of your two identities and diff response bodies where caching may differ.
3. Inspect cache-related response headers for which content is shared and which carries identity-sensitive state across callers.
4. Test whether identity-changing request attributes alter the served copy: credential, tenant, locale and client version headers.
5. Check writes after reads, since a cached authorized response may continue serving content after state changed beneath it.
6. 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**

```text
layer=app-cache  key_path=credential,tenant,locale  since_billed=Vary:Authorization
```

**2. Shared cache**

```text
alice-request cached -> bob plans same -> served alice's body -> identity skipped from key
```

**3. Result row**

```text
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.

## References

- [MDN - HTTP caching](https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching)
- [OWASP - session and request isolation cheating](https://cheatsheetseries.owasp.org/)

