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/zstd/ZstdFrameDecompressor.java, src/test/java/io/airlift/compress/zstd/TestZstd.java
Commit date: 2024-02-13 08:10:53 -0800
Commit message: Fix bounds checks

Diff: diff --git a/src/main/java/io/airlift/compress/zstd/ZstdFrameDecompressor.java b/src/main/java/io/airlift/compress/zstd/ZstdFrameDecompressor.java
index 617469f..8476eec 100644
--- a/src/main/java/io/airlift/compress/zstd/ZstdFrameDecompressor.java
+++ b/src/main/java/io/airlift/compress/zstd/ZstdFrameDecompressor.java
@@ -168,21 +168,21 @@ class ZstdFrameDecompressor
                 int blockSize = (header >>> 3) & 0x1F_FFFF; // 21 bits
 
                 int decodedSize;
                 switch (blockType) {
                     case RAW_BLOCK:
-                        verify(inputAddress + blockSize <= inputLimit, input, "Not enough input bytes");
+                        verify(input + blockSize <= inputLimit, input, "Not enough input bytes");
                         decodedSize = decodeRawBlock(inputBase, input, blockSize, outputBase, output, outputLimit);
                         input += blockSize;
                         break;
                     case RLE_BLOCK:
-                        verify(inputAddress + 1 <= inputLimit, input, "Not enough input bytes");
+                        verify(input + 1 <= inputLimit, input, "Not enough input bytes");
                         decodedSize = decodeRleBlock(blockSize, inputBase, input, outputBase, output, outputLimit);
                         input += 1;
                         break;
                     case COMPRESSED_BLOCK:
-                        verify(inputAddress + blockSize <= inputLimit, input, "Not enough input bytes");
+                        verify(input + blockSize <= inputLimit, input, "Not enough input bytes");
                         decodedSize = decodeCompressedBlock(inputBase, input, blockSize, outputBase, output, outputLimit, frameHeader.windowSize, outputAddress);
                         input += blockSize;
                         break;
                     default:
                         throw fail(input, "Invalid block type");
diff --git a/src/test/java/io/airlift/compress/zstd/TestZstd.java b/src/test/java/io/airlift/compress/zstd/TestZstd.java
index ba3dd22..a02bddf 100644
--- a/src/test/java/io/airlift/compress/zstd/TestZstd.java
+++ b/src/test/java/io/airlift/compress/zstd/TestZstd.java
@@ -256,8 +256,8 @@ public class TestZstd
 
         byte[] data = buffer.toByteArray();
 
         assertThatThrownBy(() -> new ZstdDecompressor().decompress(data, 0, data.length, new byte[10], 0, 10))
                 .isInstanceOf(MalformedInputException.class)
-                .hasMessageStartingWith("Input is corrupted");
+                .hasMessageStartingWith("Not enough input bytes");
     }
 }

Vulnerable code:                         verify(inputAddress + blockSize <= inputLimit, input, "Not enough input bytes");
                        verify(inputAddress + 1 <= inputLimit, input, "Not enough input bytes");
                        verify(inputAddress + blockSize <= inputLimit, input, "Not enough input bytes");
                .hasMessageStartingWith("Input is corrupted");
Fixed code:                         verify(input + blockSize <= inputLimit, input, "Not enough input bytes");
                        verify(input + 1 <= inputLimit, input, "Not enough input bytes");
                        verify(input + blockSize <= inputLimit, input, "Not enough input bytes");
                .hasMessageStartingWith("Not enough input bytes");