Repository navigation
Backport #110590 to 26.6: Validate the JSON/Object shared-data bucket count read from a stream - #117743
Merged
Conversation
Manual backport of the guard added in #110590 (commit `73641c7f1d1`). It cannot be cherry-picked, because that commit is an incremental rename of an earlier `throwIfTooManyBuckets` introduced by two predecessor commits which also change the path-count handling and `SerializationDynamic`, and neither of those is backported here. An `Object` V3 structure prefix carries the shared-data bucket count as a bare varint, and that count sizes the per-bucket reader state and `Columns` directly. A malformed `Native` block declaring `0` buckets therefore made `collectSharedDataFromBuckets` index an empty vector, and a count near `SIZE_MAX` escaped as a non-`DB::Exception` allocation failure. Reject anything outside `1 .. MAX_OBJECT_SHARED_DATA_BUCKETS` as `INCORRECT_DATA`, and point the writer-side setting caps at the same constant so the reader guard and the writer bound cannot drift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
|
Workflow [BackportPR], commit [0a70c98] Summary: ✅ |
The range check and the error message already say what the guard does, and the reason the range is `1 .. 256` is documented on `MAX_OBJECT_SHARED_DATA_BUCKETS` itself. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
bytehalo-infra
added a commit
to sentioxyz/ClickHouse
that referenced
this pull request
Sep 25, 2026
…26.3 backport ClickHouse#117748) PROTO: a Dynamic or JSON/Object structure read from a stream (Native input, the format() table function, a corrupted part) with a type or path count near SIZE_MAX -> an uncaught std::length_error instead of a DB::Exception; with a large but representable count, a multi-GB up-front reserve before any type or path is read (OOM/DoS). Also the `num_dynamic_types + 1` wrap-around for SIZE_MAX. Effect in the production build a394e92: the upstream tests 04307_dynamic_flattened_too_many_types and 04350_json_native_too_many_paths fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv). ClickHouse#110590 is an upstream port of Cloud-only tests that carries several fixes; its 26.3 (ClickHouse#117748) and 26.6 (ClickHouse#117743) backports take only the shared-data bucket guard. This commit adds its other guards unchanged: SerializationDynamic.cpp (flattened type count, V2 dynamic type count), SerializationObject.cpp (flattened and dynamic path counts; the helper joins the anonymous namespace that ClickHouse#117748 created; the fork keeps its own declarations there) and SerializationObjectSharedData.cpp (granule path and substream counts), with the upstream tests 04307 and 04350 and their four Native fixtures (blob ids equal to the upstream diff). The gtest and documentation changes of ClickHouse#110590 are not included. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Manual backport to
26.6of the shared-data bucket count validation added in #110590 (commit73641c7f1d1), plus a stateless test for it.Not a cherry-pick: that commit is an incremental rename of an earlier
throwIfTooManyBucketsintroduced by two predecessor commits which also change the path-count handling andSerializationDynamic, and neither of those is backported here.Related: #117739
Version info
26.6.5.32