CVE-2024-36114: Insufficient Information (NVD-CWE-noinfo)
value: Aircompressor is a library with ports of the Snappy, LZO, LZ4, and Zstandard compression algorithms to Java. All decompressor implementations of Aircompressor (LZ4, LZO, Snappy, Zstandard) can crash the JVM for certain input, and in some cases also leak the content of other memory of the Java process (which could contain sensitive information). When decompressing certain data, the decompressors try to access memory outside the bounds of the given byte arrays or byte buffers. Because Aircompressor uses the JDK class `sun.misc.Unsafe` to speed up memory access, no additional bounds checks are performed and this has similar security consequences as out-of-bounds access in C or C++, namely it can lead to non-deterministic behavior or crash the JVM. Users should update to Aircompressor 0.27 or newer where these issues have been fixed. When decompressing data from untrusted users, this can be exploited for a denial-of-service attack by crashing the JVM, or to leak other sensitive information from the Java process. There are no known workarounds for this issue.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
Published: 2024-05-29T21:15Z
Repository: https://github.com/airlift/aircompressor
Language: Java
Files changed: src/main/java/io/airlift/compress/snappy/SnappyRawDecompressor.java, src/test/java/io/airlift/compress/snappy/TestSnappy.java
Commit date: 2024-02-13 08:10:53 -0800
Commit message: Verify length is positive

Diff: diff --git a/src/main/java/io/airlift/compress/snappy/SnappyRawDecompressor.java b/src/main/java/io/airlift/compress/snappy/SnappyRawDecompressor.java
index 2871b9a..b11907b 100644
--- a/src/main/java/io/airlift/compress/snappy/SnappyRawDecompressor.java
+++ b/src/main/java/io/airlift/compress/snappy/SnappyRawDecompressor.java
@@ -304,10 +304,13 @@ public final class SnappyRawDecompressor
                         }
                     }
                 }
             }
         }
+        if (result < 0) {
+            throw new MalformedInputException(compressedAddress, "negative compressed length");
+        }
         return new int[] {result, bytesRead};
     }
 
     private static int getUnsignedByteSafe(Object base, long address, long limit)
     {
diff --git a/src/test/java/io/airlift/compress/snappy/TestSnappy.java b/src/test/java/io/airlift/compress/snappy/TestSnappy.java
index b2e92d7..36f39fe 100644
--- a/src/test/java/io/airlift/compress/snappy/TestSnappy.java
+++ b/src/test/java/io/airlift/compress/snappy/TestSnappy.java
@@ -65,6 +65,16 @@ public class TestSnappy
         };
 
         assertThatThrownBy(() -> new SnappyDecompressor().decompress(data, 0, data.length, new byte[1024], 0, 1024))
                 .isInstanceOf(MalformedInputException.class);
     }
+
+    @Test
+    public void testNegativeLength()
+    {
+        byte[] data = {(byte) 255, (byte) 255, (byte) 255, (byte) 255, 0b0000_1000};
+
+        assertThatThrownBy(() -> SnappyDecompressor.getUncompressedLength(data, 0))
+                .isInstanceOf(MalformedInputException.class)
+                .hasMessageStartingWith("negative compressed length");
+    }
 }

Fixed code:         if (result < 0) {
            throw new MalformedInputException(compressedAddress, "negative compressed length");
        }

    @Test
    public void testNegativeLength()
    {
        byte[] data = {(byte) 255, (byte) 255, (byte) 255, (byte) 255, 0b0000_1000};

        assertThatThrownBy(() -> SnappyDecompressor.getUncompressedLength(data, 0))
                .isInstanceOf(MalformedInputException.class)
                .hasMessageStartingWith("negative compressed length");
    }