The vulnerability in OpenFGA (CVE-2026-41131) is a case of improper policy enforcement due to a cache key collision. When caching is enabled, specially crafted check requests with control characters in the condition name or context could generate the same cache key as a different, legitimate request. This could lead to the wrong authorization result being returned from the cache.
The root cause was improper input sanitization. Instead of rejecting inputs with control characters, the cache key generation logic attempted to sanitize them by replacing them with a placeholder. This created the possibility for different inputs to be normalized to the same cache key.
The fix addresses this issue at multiple levels:
- Input Validation: Stricter validation was added at the beginning of the request lifecycle. The
validateCheckRequest and validateCondition functions were updated to reject any requests containing control characters in the context or condition names.
- Cache Key Generation: The cache key generation logic in
writeValue was changed to stop sanitizing inputs. Instead, it now assumes that inputs have been validated and will error if it encounters any forbidden characters, preventing the creation of ambiguous cache keys.
By rejecting invalid inputs early and removing the flawed sanitization, the patch ensures that each unique check request generates a unique cache key, thus resolving the vulnerability.