Throw IOException for invalid or unsupported frame descriptors - #133
Merged
Merged
Conversation
LZ4FrameInputStream.readHeader() passed the FLG and BD bytes to FLG.fromByte/BD.fromByte unguarded, so reserved bits, dependent blocks, dictionary IDs, bad versions and invalid block size indicators surfaced as RuntimeException/IllegalArgumentException from read(), skip() and the expected content size getters. Wrap them in an IOException instead. Fixes #102 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yawkat
enabled auto-merge (squash)
September 25, 2026 19:03
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #133 +/- ##
============================================
+ Coverage 79.76% 80.44% +0.68%
Complexity 562 562
============================================
Files 42 42
Lines 1838 1841 +3
Branches 247 247
============================================
+ Hits 1466 1481 +15
+ Misses 239 233 -6
+ Partials 133 127 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dongjoon-hyun
added a commit
to apache/spark
that referenced
this pull request
Sep 28, 2026
### What changes were proposed in this pull request? This PR aims to upgrade `at.yawk.lz4:lz4-java` to 1.12.0. ### Why are the changes needed? To bring the latest security fixes of `v1.11.4` and the stricter input validation of `v1.12.0`. The upstream recommends `1.12.0` over `1.11.4`. - https://github.com/yawkat/lz4-java/releases/tag/v1.12.0 (2026-09-25) - [Throw IOException for invalid or unsupported frame descriptors](yawkat/lz4-java#133) - [Reject short output in LZ4DecompressorWithLength safe paths](yawkat/lz4-java#126) - [Make stream failures sticky in LZ4FrameInputStream and LZ4BlockInputStream](yawkat/lz4-java#145) - https://github.com/yawkat/lz4-java/releases/tag/v1.11.4 (2026-09-25) - [LZ4FrameInputStream reallocates block buffers for every frame, allowing CPU and GC amplification from small inputs](GHSA-gm45-99xc-r7wv) - [LZ4BlockInputStream with stopOnEmptyBlock=false recurses once per empty block, causing StackOverflowError](GHSA-343h-94h5-c4wr) - [Native library extraction to a shared temporary directory is vulnerable to file replacement by another local user](GHSA-mcr4-qmvw-px4g) Note that Apache Spark's `LZ4CompressionCodec` reads streams via `LZ4BlockInputStream` with `withStopOnEmptyBlock(false)`, which is the code path fixed by `GHSA-343h-94h5-c4wr`. **Full Changelog**: yawkat/lz4-java@v1.11.3...v1.12.0 ### Does this PR introduce _any_ user-facing change? No. There is no behavior change for valid LZ4 streams. ### How was this patch tested? Pass the CIs. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 Closes #59093 from dongjoon-hyun/SPARK-59820. Authored-by: Dongjoon Hyun <dongjoon@apache.org> Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #102.
LZ4FrameInputStream.readHeader()calledFLG.fromByte/BD.fromByteunguarded. For reserved bits, dependent blocks, a dictionary ID, a bad version or block-size indicators 0-3, those calls throw a plainRuntimeException/IllegalArgumentException. That exception escaped fromread(),skip()and the content-size getters. Both calls are now wrapped, and failures are rethrown asIOException("Invalid or unsupported frame descriptor", cause). The publicFLG/BDAPI is unchanged.Note: descriptor validation still runs before the header checksum check. A bit flip in FLG or BD is therefore reported as invalid/unsupported rather than as a checksum mismatch; either way it is now an
IOException.Test:
testInvalidOrUnsupportedFrameDescriptorbuilds headers with valid checksums for FLG 0x40, 0x61, 0x62, 0x20 and BD 0x30, 0x41. For each it assertsIOExceptionwith that message fromread(),skip(),getExpectedContentSize()andisExpectedContentSizeDefined(). It fails without the fix.Note: this touches the same file as #125 and #131. Whichever is merged later may need a trivial rebase.
🤖 Generated with Claude Code