Skip to content

Auto-port 4.1: Use safe decompressor in Lz4FrameDecoder - #17121

Merged
chrisvest merged 3 commits into
4.1from
auto-port-pr-17118-to-4.1
Jul 24, 2026
Merged

chrisvest merged 3 commits into
4.1from
auto-port-pr-17118-to-4.1

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #17118 to 4.1
Cherry-picked commit: e64a6b5


Motivation:

Lz4FrameDecoder currently uses LZ4FastDecompressor. Recent lz4-java security hardening has degraded the performance of this path, while the decoder already knows the exact compressed block length required by LZ4SafeDecompressor. The fast API also does not accept the compressed source length, allowing malformed blocks to consume trailing readable bytes.

Modification:

  • Use LZ4SafeDecompressor from the configured LZ4Factory.
  • Pass the exact declared compressed and decompressed lengths to the bounded decompression API.
  • Reject output whose actual decompressed length differs from the frame header.
  • Add regression coverage for reading beyond the declared compressed length and for decompressed-length mismatches.

Result:

Valid LZ4 frames continue to decode normally, while malformed blocks are constrained to their declared input and output bounds. The codec-compression test suite passes with 359 tests, and the focused Lz4FrameDecoderTest passes after allocating test inputs through the channel allocator.

Motivation:

`Lz4FrameDecoder` currently uses `LZ4FastDecompressor`. Recent lz4-java
security hardening has degraded the performance of this path, while the
decoder already knows the exact compressed block length required by
`LZ4SafeDecompressor`. The fast API also does not accept the compressed
source length, allowing malformed blocks to consume trailing readable
bytes.

Modification:

- Use `LZ4SafeDecompressor` from the configured `LZ4Factory`.
- Pass the exact declared compressed and decompressed lengths to the
bounded decompression API.
- Reject output whose actual decompressed length differs from the frame
header.
- Add regression coverage for reading beyond the declared compressed
length and for decompressed-length mismatches.

Result:

Valid LZ4 frames continue to decode normally, while malformed blocks are
constrained to their declared input and output bounds. The
`codec-compression` test suite passes with 359 tests, and the focused
`Lz4FrameDecoderTest` passes after allocating test inputs through the
channel allocator.

Co-authored-by: multicode <[email protected]>
(cherry picked from commit e64a6b5)
@chrisvest
chrisvest enabled auto-merge (squash) July 22, 2026 19:41
@chrisvest
chrisvest merged commit c69f043 into 4.1 Jul 24, 2026
18 checks passed
@chrisvest
chrisvest deleted the auto-port-pr-17118-to-4.1 branch July 24, 2026 19:55
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
Auto-port of netty#17118 to 4.1
Cherry-picked commit: e64a6b5

---
Motivation:

`Lz4FrameDecoder` currently uses `LZ4FastDecompressor`. Recent lz4-java
security hardening has degraded the performance of this path, while the
decoder already knows the exact compressed block length required by
`LZ4SafeDecompressor`. The fast API also does not accept the compressed
source length, allowing malformed blocks to consume trailing readable
bytes.

Modification:

- Use `LZ4SafeDecompressor` from the configured `LZ4Factory`.
- Pass the exact declared compressed and decompressed lengths to the
bounded decompression API.
- Reject output whose actual decompressed length differs from the frame
header.
- Add regression coverage for reading beyond the declared compressed
length and for decompressed-length mismatches.

Result:

Valid LZ4 frames continue to decode normally, while malformed blocks are
constrained to their declared input and output bounds. The
`codec-compression` test suite passes with 359 tests, and the focused
`Lz4FrameDecoderTest` passes after allocating test inputs through the
channel allocator.

---------

Co-authored-by: Jonas Konrad <[email protected]>
Co-authored-by: multicode <[email protected]>
Co-authored-by: Chris Vest <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants