Summary
A cache key authorization flaw in Directus allows responses generated under one access context to be reused for other clients that share the same URL and query but have different permissions.
When response caching is enabled, missing authorization attributes in the cache key can cause share tokens and anonymous users to receive data filtered for a different permission set, making the issue risky anywhere diverse roles or share links are used.
Affected context
This vulnerability appears in Directus deployments that have HTTP response caching enabled in the API layer.
It manifests when cache keys are derived only from request-specific fields (version, path, query, accountability.user) while omitting critical authorization context such as share, role, roles, admin, app, and policies.
In environments that rely heavily on share tokens, anonymous access, or fine-grained role-based policies, the missing authorization attributes in the cache key can lead to cross-context reuse of permission-filtered responses.
Exploit preconditions
- Attack surface: Directus API endpoints with response caching enabled.
- Required access: Ability to issue HTTP requests (as an anonymous client, via share tokens, or as any user with differing roles/policies).
- Trigger point: Two or more requests with identical URL, query parameters, and user null state, but distinct authorization contexts (e.g., different share tokens or policies).
- Why exploitation is possible: The cache key omits authorization attributes (share, role, roles, admin, app, policies), allowing a response computed under one permission model to be served to another client whose request collapses to the same cache key.
Why this happens
The root cause is an incomplete cache key design that fails to encode all security-relevant facets of the caller's authorization state.
By relying primarily on path, query, version, and a single user identifier, the implementation treats multiple distinct authorization contexts as equivalent, particularly when accountability.user is null for both share tokens and anonymous clients.
This maps to CWE-639: Insecure Direct Object Reference in the sense that access control checks effectively become bypassable through cached state, and CWE-524: Use of Cached Data without Proper Validation because the cached response is reused without re-validating permissions for each new requester.
Potential impact
- Clients with weaker or different permissions may receive data filtered for a more privileged share or role.
- Sensitive records that should be hidden can be exposed to anonymous or low-privileged users.
- Share links intended for narrow audiences can unintentionally leak broader dataset views.
- Inconsistent enforcement of policies can undermine auditability and compliance efforts.
General mitigation guidance
Mitigation centers on making authorization context a first-class component of cache design and minimizing trust in previously computed responses.
Recommended high-level patterns include:
- Incorporate all relevant authorization attributes (user identity, share token, role/roles, policy identifiers, admin/app flags) into cache keys or segregate caches per security principal.
- Treat anonymous access and share-based access as distinct contexts with explicitly separate caching strategies.
- Favor caching of non-sensitive, role-agnostic responses and avoid caching outputs that depend heavily on fine-grained policies, especially for multi-tenant or public APIs.
- Re-evaluate permission filters on cache hits when feasible, or store sufficient policy metadata alongside cached entries to validate that the current requester's authorization matches the cached context.
- Apply least-privilege principles to share tokens and roles so that any unintended data reuse is constrained.
How teams detect issues like this
High-level detection approaches include:
- Reviewing cache key derivation functions for omission of security-relevant attributes such as roles, share identifiers, tenant IDs, and policy markers.
- Using static analysis or configuration lints to flag caching logic that depends only on URL and query without incorporating authorization state.
- Inspecting access logs for patterns where different principals (anonymous vs. share vs. authenticated users) receive identical payloads for policy-dependent endpoints.
- Instrumenting cache middleware to log authorization context associated with each cached entry and monitoring for cross-context reuse.
- Applying automated code review tools or custom rules in CI to enforce that any new caching mechanisms explicitly account for authentication and authorization boundaries.

