The Apache Commons PMC has received the security report referenced
below. After analysis, we classified it as NOT A VULNERABILITY: the
behavior is that of the underlying xz-java library, and Commons
Compress already lets applications limit it. In the interest of
transparency and so that the community and other researchers can
benefit from the analysis, we are disclosing a summary of it.
Report reference (Apache Commons PMC / security archive):
https://lists.apache.org/thread/77fycm41x660d4ts38klmjtmldpr3lxt
Reporter: netwind
Disposition: NOT A VULNERABILITY -- no CVE; documentation to be
improved in COMPRESS-731
TLP:CLEAR (this message may be redistributed without restriction)
The reporter was informed of this classification and of our intent to
publish this summary.
== Summary of the report ==
A valid `.lzma` stream can declare a dictionary of up to 1.5 GiB and an
unknown uncompressed size. `LZMACompressorInputStream`, which is also
used by the auto-detecting `CompressorStreamFactory`, passes the stream
to xz-java's `LZMAInputStream`, which allocates the declared dictionary
when it is constructed, before decoding any data. Since neither
`new CompressorStreamFactory()` nor the default
`LZMACompressorInputStream` builder sets a memory limit, the reporter
showed that a 28-byte file, which decodes to five bytes, throws an
`OutOfMemoryError` on a 1 GiB heap with Commons Compress 1.28.0. The
reporter also argued that the memory limit is compared with the
declared need rather than with the free heap, and proposed a finite
default limit.
== PMC assessment ==
This is NOT a vulnerability. The allocation is performed by xz-java,
whose own `LZMAInputStream(InputStream)` constructor has no memory
limit either. Commons Compress exposes xz-java's limit through
`LZMACompressorInputStream.Builder.setMemoryLimitKiB()` and
`CompressorStreamFactory(boolean, int)`; with a limit set, the stream
is rejected with a `MemoryLimitException` before the dictionary is
allocated. The limit is the memory budget the application grants to
the stream: a limit larger than the available heap is a
misconfiguration.
Commons Compress does not currently claim to safely process arbitrary
malicious input:
https://commons.apache.org/threat-model-0.1.0.html
Applications that decompress untrusted LZMA or XZ data should set a
memory limit that fits their heap.
== Documentation ==
The documentation of `CompressorStreamFactory` and of the LZMA and XZ
streams will state that the defaults are unbounded, and the examples
page will be corrected: it still says that the LZMA format cannot be
auto-detected.
== References ==
Threat model:
https://commons.apache.org/threat-model-0.1.0.html
Security policy:
https://commons.apache.org/security.html
Commons Compress examples (memory limits):
https://commons.apache.org/proper/commons-compress/examples.html
Issue:
https://issues.apache.org/jira/browse/COMPRESS-731
Questions and follow-up are welcome on this list.
On behalf of the Apache Commons PMC,
Piotr P. Karwasz
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]