Summary
OpenFGA versions prior to 1.13.1 contain a flaw in how cache keys are derived for authorization checks that use conditions, allowing two distinct requests to generate the same cache key.
Under specific modeling patterns with condition-based relations and caching enabled, OpenFGA may reuse a cached decision from a different request, potentially granting or denying access incorrectly.
Affected context
This issue arises in OpenFGA deployments that:
- Use models with relations relying on condition evaluation (e.g., context-dependent access rules), and
- Have caching enabled for authorization checks.
In these scenarios, the cache key derivation logic may not fully capture all inputs that influence the decision (such as specific condition parameters or contextual attributes). When two semantically different authorization checks collapse to the same cache key, OpenFGA may return a prior cached result instead of computing the correct one for the new request.
Exploit preconditions
- Attack surface: Authorization/check API endpoints exposed by OpenFGA.
- Required access: Ability to issue or influence authorization check requests (e.g., as an application client or user whose requests are checked through OpenFGA).
- Trigger point: Check operations against relations that rely on conditional logic while the cache is enabled.
- Why exploitation is possible: The cache key does not uniquely represent all decision-relevant inputs (including condition parameters and contextual data), so different checks can collide on the same key and cause the engine to reuse a stale or incorrect authorization result.
Why this happens
The vulnerability stems from insufficiently robust cache key construction for conditional authorization checks.
Instead of including all security-sensitive inputs (such as relation, user, object, and condition parameters) into the cache key, the implementation allows logically distinct requests to hash to the same key.
This aligns with:
- CWE-345: Insufficient Verification of Data Authenticity, because the system trusts a cached result without adequately verifying that it was produced for the exact same decision context.
- CWE-20: Improper Input Validation, as the inputs that drive authorization logic are not fully reflected or validated in the caching layer.
- CWE-1289: Improper Validation of Syntactic Correctness of Input, in that the structural distinctions between different conditional inputs are not reliably encoded when deriving cache identifiers.
Abstractly, this is a logic bug where an optimization (caching) breaks the invariant that each authorization decision is bound to its full set of inputs.
Potential impact
- Authorization checks may incorrectly grant access to resources that should be denied.
- Authorization checks may incorrectly deny access to resources that should be permitted.
- Confusing or inconsistent behavior in applications relying on OpenFGA, potentially undermining auditability and trust in access control decisions.
- Depending on the protected data, could contribute to data exposure, privilege escalation, or bypass of business rules.
General mitigation guidance
Mitigation typically focuses on ensuring that caching cannot conflate distinct authorization contexts:
- Design cache keys so they uniquely encode all decision-relevant inputs, including user, object, relation, and every condition parameter or contextual attribute that affects the outcome.
- Treat condition evaluation inputs as part of the security boundary; avoid any normalization or truncation that can cause distinct inputs to collide in the cache.
- Where modeling patterns are complex, prefer defensive defaults: disable or narrow caching on relations that depend heavily on dynamic context or fine-grained conditions.
- Apply the principle of least privilege in model design so that accidental cache reuse tends to under-grant rather than over-grant access.
- Introduce invariants and tests around authorization behavior to ensure that changes to caching or modeling do not alter expected decisions.
These measures help ensure that performance optimizations do not compromise authorization correctness.
How teams detect issues like this
Detection efforts can combine code analysis, configuration review, and behavioral monitoring:
- Static analysis and code review:
- Look for cache implementations where keys omit condition-related inputs or contextual parameters.
- Flag any caching layer that keys only on user/object/relation while the authorization logic also depends on additional context.
- Review helper functions that build cache keys, ensuring they evolve alongside changes to the authorization model.
- Policy and configuration review:
- Examine models to identify relations heavily dependent on conditions and confirm that caching strategies are appropriate for them.
- Establish architectural guidelines that condition-based relations receive special scrutiny before being cached.
- Runtime and log-based analysis:
- Analyze logs for suspicious patterns, such as users gaining access in contexts where conditions should differ (e.g., different times, locations, or attributes) but responses are identical and served from cache.
- Correlate cache hits with input variability to detect potential key collisions.
- Automated code review or security scanning tools can be configured with rules to flag risky cache key patterns in authorization code.

