Security fixes are released for the latest 5.x release. Older majors are not maintained.
| Version | Supported |
|---|---|
| 5.x | Yes |
| < 5.0 | No |
Please do not open a public issue for a security problem.
Report it through GitHub's private vulnerability reporting.
If that is not available to you, email the maintainers listed in build.gradle.kts.
Include, as far as you can:
- the affected version,
- an archive or test case that reproduces the problem,
- what an attacker gains.
We aim to acknowledge a report within 5 working days, and to ship a fix or a mitigation plan within 30 days of confirming it. You will be credited in the advisory unless you prefer otherwise.
Compress4J extracts what an archive tells it to. When the archive comes from an untrusted source:
- Path traversal is rejected: entry paths are resolved canonically against the output directory, so
../entries and writes through a symlink that points outside the output directory both fail withUnsafeEntryException. - Escaping symlinks are rejected by default with
UnsafeEntryException. SetescapingSymlinkPolicy(EscapingSymlinkPolicy.ALLOW)to extract them as-is, orRELATIVIZE_ABSOLUTEto rewrite absolute targets under the output directory and still reject targets that escape it. - Decompression bombs are bounded by default. Every reader (tar, zip, 7z, ar, cpio, arj, dump and
Decompressor) enforces an expansion ratio of 100, checked once it has produced 1 MiB, and extraction stops after 1,000,000 extracted entries (counted afterstripComponentsand the filter; unsupported and filtered-out entries are not counted). Entry and total sizes are not bounded by default. For untrusted input setmaxEntrySizeandmaxTotalSize, for examplelimits(ExtractionLimits.defaults().withMaxTotalSize(1024L * 1024 * 1024)). RaisemaxRatiofor legitimate highly compressible data, or uselimits(ExtractionLimits.noLimits())for trusted input only. Breaching a limit throwsLimitExceededException. - Corrupt input fails with
IOException, never a parserRuntimeException..xzand.lzmadecoders read with at most 256 MiB of memory unlessmemoryLimitKiBsays otherwise. Pack200 is never detected, and its decoding is not bounded by the limits; select it explicitly only for trusted input. - Security failures cannot be suppressed.
UnsafeEntryException(traversal, escaping symlinks) andLimitExceededExceptionboth extendUnsafeInputException, which no error handler can suppress.
try (var extractor = TarArchiveExtractor.builder(in)
.maxEntries(10_000)
.maxEntrySize(100L * 1024 * 1024)
.maxTotalSize(1024L * 1024 * 1024)
.build()) {
extractor.extract(outputDir);
}