I have analyzed the vulnerability GHSA-99f4-grh7-6pcq in @grpc/grpc-js. The vulnerability lies in the handling of malformed compressed messages, which can lead to a client or server crash.
The investigation of the provided reference URLs and the grpc/grpc-node repository led me to the commits that patch this vulnerability. The fix involves adding a check to ensure that the decompressed message size is not zero. If it is, an error is thrown, preventing the application from crashing.
The vulnerable function is http2.onData, which is an event handler for incoming data chunks. Inside this handler, the code attempts to decompress the message. The vulnerability is triggered when a malformed compressed message results in a zero-length buffer after decompression, which was not handled correctly, leading to a crash.
The patch was applied in multiple branches, and I have identified the relevant commits. For example, in the 1.9.x branch, the fix is in commit c5355957479009126b1342b382833c44a61b1c3a. The key change is in the http2.ts file, where a check for the decompressed message length is added.