Summary
When LZ4BlockInputStream is configured with stopOnEmptyBlock = false (the mode for reading concatenated block streams), it handles each empty block by calling refill() recursively. A long run of empty blocks exhausts the thread stack and throws StackOverflowError out of read() or skip().
Details
In net.jpountz.lz4.LZ4BlockInputStream.refill():
java if (originalLen == 0 && compressedLen == 0) { if (check != 0) { throw new IOException("Stream is corrupted"); } if (!stopOnEmptyBlock) { refill(); } else { finished = true; } return; }
Each well-formed empty block is 21 bytes and adds one stack frame, with no limit on nesting depth. In local testing, around 10,000 to 100,000 consecutive empty blocks (about 210 KB to 2.1 MB, depending on JIT state and thread stack size) threw StackOverflowError. StackOverflowError is an Error, not an IOException, so callers that only handle I/O errors for corrupt input don't catch it.
Impact
Applications that decode attacker-controlled LZ4Block streams with LZ4BlockInputStream.newBuilder().withStopOnEmptyBlock(false) or the deprecated LZ4BlockInputStream(InputStream, boolean) constructor can have the decoding thread fail with StackOverflowError. The default configuration (stopOnEmptyBlock = true) is not affected. There is no memory corruption. Availability impact only.
Patch
Fixed in lz4-java 1.11.4. Empty blocks are now skipped in a loop instead of by recursion, so any number of consecutive empty blocks uses constant stack space.
For older versions, the workaround is to use the default stopOnEmptyBlock = true for untrusted input, or catch StackOverflowError around the read loop.
Summary
LZ4DecompressorWithLength.decompress(byte[], int) allocates whatever size the 4-byte length header declares, before it reads a single byte of compressed data. A 5-byte input whose header says 0x40000000 makes the JVM commit a gigabyte and can cause heap exhaustion.
Details
net.jpountz.lz4.LZ4DecompressorWithLength reads the header and passes it straight on:
java final int destLen = getDecompressedLength(src, srcOff); return fastDecompressor.decompress(src, srcOff + 4, destLen);
and net.jpountz.lz4.LZ4FastDecompressor allocates it:
java public final byte[] decompress(byte[] src, int srcOff, int destLen) { final byte[] decompressed = new byte[destLen]; decompress(src, srcOff, decompressed, 0, destLen); return decompressed; }
getDecompressedLength performs no validation: no comparison against src.length, no ceiling, no rejection of negatives. LZ4SafeDecompressor.decompress(byte[], int, int, int) has the same shape with maxDestLen.
The sibling overload that callers pass their own buffer to, decompress(src, srcOff, dest, destOff, destLen), is fine, because there destLen is chosen by the caller rather than by the input. The bug is specific to the convenience overloads that take the size from the header, and that difference is the whole finding.
Impact
Any application that decompresses attacker-supplied LZ4 frames through the with-length convenience API can be made to allocate up to 2 GiB per call from a 5-byte message. On a service that decompresses request bodies, a few concurrent 5-byte requests exhaust the heap. No privileges are needed, only the ability to get bytes into the decompressor. Confidentiality and integrity are untouched.
Out-of-bounds memory operations in org.lz4:lz4-java 1.8.0 and earlier allow remote attackers to cause denial of service and read adjacent memory via untrusted compressed input.
https://github.com/yawkat/lz4-java/security/advisories/GHSA-cmp6-m4wj-q63q discloses: Java-based decompressor implementations can leak information from uninitialized output buffer
yawkat published GHSA-cmp6-m4wj-q63q Dec 5, 2025
Package Affected versions Patched versions ------- ----------------- ---------------- at.yawk.lz4:lz4-java (Maven) <= 1.10.0 1.10.1 net.jpountz.lz4:lz4 (Maven) <= 1.8.1 None org.lz4:lz4-java (Maven) <= 1.8.1 None org.lz4:lz4-pure-java (Maven) <= 1.8.1 None
Description ===========
Summary ------- Insufficient clearing of the output buffer in Java-based decompressor implementations in lz4-java 1.10.0 and earlier allows remote attackers to read previous buffer contents via crafted compressed input. In applications where the output buffer is reused without being cleared, this may lead to disclosure of sensitive data.
JNI-based implementations are not affected.
Details -------
During the decompression process, the lz4 algorithm may have to repeat data that was previously decompressed in the same input frame. In the Java implementation, this is implemented by copy operations within the output buffer.
With a crafted input, an attacker may induce the Java implementation to copy from a region in the output buffer that does not contain decompressed data yet. If that region contains sensitive information because the output buffer was not cleared prior to decompression, that data will then be copied to the decompressed output.
- LZ4Factory.nativeInstance().safeDecompressor() is not affected.
- LZ4Factory.nativeInstance().fastDecompressor() is affected because it actually uses safeInstance() since 1.8.1. In 1.8.0 and earlier versions, this implementation is instead vulnerable to the more severe CVE‐2025‐12183, so downgrading is not a solution.
- Both decompressors of LZ4Factory.safeInstance(), LZ4Factory.unsafeInstance() and LZ4Factory.fastestJavaInstance() are affected.
- LZ4Factory.fastestInstance() uses the nativeInstance or fastestJavaInstance depending on platform. LZ4Factory.fastestInstance().fastDecompressor() is always affected, while LZ4Factory.fastestInstance().safeDecompressor() is affected only when JNI cannot be used (e.g. on unsupported platforms).
Independent of this vulnerability, it is recommended that users migrate from fastDecompressor to safeDecompressor, as the latter is more performant (despite the name).
The impact of this vulnerability depends on how user code interacts with the decompression API. Users that allocate a new destination buffer each time, or use only zeroed buffers, are not impacted. When the buffer is reused, however, the confidentiality impact can be severe. This vulnerability is marked as VC:H out of caution.
Mitigation ---------- lz4-java 1.10.1 fixes this issue without requiring changes in user code.
If you cannot upgrade to 1.10.1, you can mitigate this vulnerability by zeroing the output buffer before passing it to the decompression function.
Relation to CVE‐2025‐12183 -------------------------- This CVE is a different attack than CVE‐2025‐12183, affecting different implementations with different impact. This new vulnerability was discovered by CodeIntelligence during research that followed up on CVE‐2025‐12183. Users are recommended to upgrade to 1.10.1 to fix both vulnerabilities.
Severity: High 8.2 / 10 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N CVE ID: CVE-2025-66566 Weaknesses: Weakness CWE-201 Credits: @simonresch (Reporter) -- -Alan Coopersmith- alan.coopersmith () oracle com Oracle Solaris Engineering - https://blogs.oracle.com/solaris