You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Missing bound check on uncompress() in snappy-java can lead to Denial of Service (DoS) impact #625
The uncompress() method in snappy-java lacks proper validation of the uncompressedLength, which leads to a potential Denial of Service (DoS) vulnerability. Specifically, with only 5 bytes of input, the library becomes vulnerable to DoS attacks.
Details
In the Snappy.java, the uncompress() method is implemented as follows:
When creating the new byte[] array, there is no upper bounds check on the uncompressedLength. As a result, if uncompressedLength is too large, it can lead to an OutOfMemoryError, similar to the vulnerability of snappy-java described in GHSA-55g7-9cwv-5qfv (GitHub advisory).
This will produce the following exception: java.lang.OutOfMemoryError
Similarly, as seen in GHSA-pqr6-cmr2-h8hf (GitHub advisory), the absence of lower bounds checks on uncompressedLength can lead to a NegativeArraySizeException due to integer overflow.
This will produce the following exception: java.lang.NegativeArraySizeException
Impact Denial of Service (DoS).
Mitigation
To resolve this issue, we suggest adding bounds validation in the uncompress() method before allocating the array. Specifically, ensure that Snappy.uncompressedLength(input) is greater than 0 and below a reasonable upper limit, similar to the fix applied in GHSA-55g7-9cwv-5qfv.
Fixed in #739 (merged to main), which adds Java-side validation before every native call. Snappy.uncompressedLength() now rejects negative lengths and lengths larger than any valid stream of the given size can produce, so Snappy.uncompress(byte[]) throws SnappyIOException(PARSING_ERROR) for these inputs instead of OutOfMemoryError / NegativeArraySizeException. The fix will ship in the next release (1.1.10.9).
Activity
Validate buffer bounds and declared lengths before calling native code (
xerial commentedon Oct 3, 2026
Fixed in #739 (merged to main), which adds Java-side validation before every native call. Snappy.uncompressedLength() now rejects negative lengths and lengths larger than any valid stream of the given size can produce, so Snappy.uncompress(byte[]) throws SnappyIOException(PARSING_ERROR) for these inputs instead of OutOfMemoryError / NegativeArraySizeException. The fix will ship in the next release (1.1.10.9).