The vulnerability is an unbounded memory allocation (CWE-409) that occurs during the decompression of LZ4 compressed payloads in MessagePack-CSharp. The advisory explicitly mentions the internal routine MessagePackSerializer.TryDecompress as the location of the flaw. To pinpoint the exact vulnerable code, I analyzed the changes between a vulnerable version and the patched version 2.5.301. The key fixing commit is 853429a0f438fcdc8a7ee3c158ee838f12a5be48, with the message "Guard LZ4 decompression length for CWE-409".
This commit modifies src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs. The patch changes the signature of the TryDecompress method to accept MessagePackSerializerOptions, which carries security limits. Crucially, it introduces a new method, ThrowIfInvalidLz4BlockLength, which is called to validate the declared uncompressedLength against a MaximumDecompressedSize before the memory for the decompressed data is allocated with writer.GetSpan(uncompressedLength). The absence of this check in prior versions is the root cause of the vulnerability, making TryDecompress the function where the vulnerability is triggered during runtime.