Repository navigation
Cherry pick #99680 to 25.8: Fix heap-buffer-overflow in T64 and abort in Multiple decompression codecs - #110832
Merged
robot-clickhouse-ci-2 merged 12 commits intoJul 17, 2026
Merged
Conversation
`CompressionCodecT64::doDecompressData` had two heap-buffer-overflow vulnerabilities discovered via fuzzing: - `memcpy(dst, src, bytes_to_skip)` at the start had no check that `bytes_size >= bytes_to_skip`, allowing a read past the compressed source buffer - The header read (`memcpy(&min, src, sizeof(MinMaxType))`) had no check that `bytes_size >= header_size` (16 bytes), causing OOB reads on short inputs `CompressionCodecMultiple::doDecompressData` had two vulnerabilities: - No check that `compression_methods_size + 1 <= source_size` before constructing the `PODArray` from `&source[n+1]..&source[m]`; if `n >= m`, the reversed range caused the allocator to attempt a ~2^64-byte allocation, aborting the process - No check that `source_size >= COMPRESSED_BLOCK_HEADER_SIZE` (9 bytes) before calling `readDecompressedBlockSize`, which reads at `source[5..8]` Crash reproducer for T64 (9 bytes): `85 68 85 3b 8d 85 0a fd 81 2c` Crash reproducer for Multiple (9 bytes): `00 00 00 00 00 00 db 00 9a`
Add two `ASSERT_THROW` regression tests that reproduce the exact crash inputs found by fuzzing: - `T64Test::DecompressMalformedInput` — 2-byte payload `81 2c` with `decompressed_size = 26757` triggered a heap-buffer-overflow in `decompressData` because `bytes_to_skip > bytes_size` with no bounds check before the trailing-bytes `memcpy`. - `CompressionCodecMultipleTest::DecompressMalformedInput` — 1-byte payload `9a` claiming 154 codecs triggered a process abort in `doDecompressData` because `PODArray` was constructed from a reversed pointer range (`&source[155]..&source[1]`), causing a ~2^64-byte allocation attempt. Both inputs now throw `Exception` instead of crashing. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Resolve conflict in gtest_compressionCodec.cpp by keeping both the T64/Multiple malformed-input regression tests and the new ALP codec tests added on master. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… checks
Cover the two additional guards added in the fix commit:
- `T64Test::DecompressMalformedInputShortHeader` — payload present but
shorter than the 16-byte min/max header required by T64
(`bytes_size < header_size`, Bug 1b).
- `CompressionCodecMultipleTest::DecompressMalformedInputShortBlockHeader` —
compressed data after the methods list is shorter than
`COMPRESSED_BLOCK_HEADER_SIZE` (9), triggering the OOB read (Bug 1d).
Also rename existing tests to clarify which guard each covers, and fix
`CompressionCodecMultiple` construction to use the byte-code path instead of
`get("Multiple", {})` which throws `Codec Multiple cannot be specified directly`.
…cks' into fix/compression-codec-bounds-checks
Co-authored-by: Yakov Olkhovskiy <[email protected]>
Co-authored-by: Yakov Olkhovskiy <[email protected]>
…s-checks Fix heap-buffer-overflow in T64 and abort in Multiple decompression codecs
Resolve cherry-pick conflicts against the 25.8 base: - CompressionCodecMultiple.cpp: keep the two added bounds checks. - CompressionCodecT64.cpp: keep the 25.8 version unchanged. 25.8 has no unaligned trailing-byte memcpy path and already rejects a compressed size smaller than the min/max header, so neither T64 overflow is reachable here. - gtest_compressionCodec.cpp: add the four regression tests on top of the 25.8 test file; the two T64 cases assert 25.8 rejects short input at its existing header-size guard.
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.
Original pull-request #99680
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job