Repository navigation
Fix write out of bounds in quantileTiming deserialization - #104141
Merged
Merged
Conversation
The deserializer of the 'large' kind of `quantileTiming` aggregate function state read a `UInt16` index from the input and used it to index into a fixed-size `count_big` array without validating that the index is within bounds. A crafted aggregate state with an index in the range `(BIG_THRESHOLD, UInt16_max]` (i.e. between 30001 and 65535) caused a write past the end of `count_big`, corrupting adjacent memory of the aggregate state. Add a bounds check that rejects indices `>= BIG_SIZE` with an `INCORRECT_DATA` exception, in line with the other validations in this header. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Contributor
|
Workflow [PR], commit [b8cd311] Summary: ✅ AI ReviewSummaryThis PR fixes a real memory-safety issue in ClickHouse Rules
Final Verdict
|
Contributor
LLVM Coverage Report
Changed lines: 100.00% (7/7) · Uncovered code |
robot-ch-test-poll4
added a commit
that referenced
this pull request
May 6, 2026
Cherry pick #104141 to 25.8: Fix write out of bounds in quantileTiming deserialization
This was referenced May 6, 2026
robot-ch-test-poll4
added a commit
that referenced
this pull request
May 6, 2026
Cherry pick #104141 to 26.2: Fix write out of bounds in quantileTiming deserialization
This was referenced May 6, 2026
robot-ch-test-poll4
added a commit
that referenced
this pull request
May 6, 2026
Cherry pick #104141 to 26.3: Fix write out of bounds in quantileTiming deserialization
This was referenced May 6, 2026
robot-ch-test-poll4
added a commit
that referenced
this pull request
May 6, 2026
Cherry pick #104141 to 26.4: Fix write out of bounds in quantileTiming deserialization
alexey-milovidov
added a commit
that referenced
this pull request
May 6, 2026
Backport #104141 to 26.4: Fix write out of bounds in quantileTiming deserialization
alexey-milovidov
added a commit
that referenced
this pull request
May 6, 2026
Backport #104141 to 26.3: Fix write out of bounds in quantileTiming deserialization
alexey-milovidov
added a commit
that referenced
this pull request
May 6, 2026
Backport #104141 to 26.2: Fix write out of bounds in quantileTiming deserialization
alexey-milovidov
added a commit
that referenced
this pull request
May 7, 2026
Backport #104141 to 25.8: Fix write out of bounds in quantileTiming deserialization
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…leTiming deserialization
zeekay
pushed a commit
to hanzoai/datastore
that referenced
this pull request
Sep 11, 2026
…4141 Backport ClickHouse#104141 to 26.4: Fix write out of bounds in quantileTiming deserialization
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.
Fix an out-of-bounds write while deserializing the 'large' kind of
quantileTimingaggregate function state.The deserializer reads a
UInt16index from the input and uses it to index into a fixed-sizecount_bigarray. A crafted aggregate state with an index in the range(BIG_THRESHOLD, UInt16_max](between30001and65535) caused a write past the end ofcount_big, corrupting adjacent memory of the aggregate state. Untrusted input can reach this code path through*Merge/*Stateround-trips,arrayReduceoverAggregateFunctioncolumns, distributed query merging, and similar entry points.A bounds check is added that rejects out-of-range indices with
INCORRECT_DATA, in line with the other validations in this header.A regression test is added with a collection of crafted serialized states.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix write out of bounds while deserializing
quantileTimingstate.Documentation entry for user-facing changes
Version info
26.5.1.31826.4.2.5,26.3.10.55,26.2.18.8,25.8.24.7