The vulnerability is a cache key collision issue within the BatchCheck functionality of OpenFGA. When multiple checks for the same user, object, and relation are sent in a single BatchCheck request with slightly different context values, the caching mechanism could generate the same cache key for them. This is because the storage.writeValue function, which serializes the context for the cache key, did not properly handle cases like a single list item containing a comma versus multiple list items. This could lead to incorrect authorization decisions as a cached (and potentially incorrect) decision for one check could be returned for another.
The patch addresses this by modifying storage.writeValue to prepend the length of string values during serialization. This ensures that different context structures will produce unique cache keys, preventing collisions. The commands.generateCacheKeyFromCheck function is directly responsible for creating the cache key and utilizes the flawed writeValue function. The server.BatchCheck function is the public API endpoint that serves as the entry point for triggering this vulnerability.