Skip to content

Backport #110590 to 26.3: Validate the JSON/Object shared-data bucket count read from a stream - #117748

Merged
Avogar merged 1 commit into
26.3from
backport/26.3/110590
Sep 3, 2026
Merged

Avogar merged 1 commit into
26.3from
backport/26.3/110590

Conversation

@Avogar

@Avogar Avogar commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Manual backport to 26.3 of the shared-data bucket count validation added in #110590 (commit 73641c7f1d1), plus a stateless test for it.

Not a cherry-pick: 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.

Related: #117739
Related: #117743

Version info

  • Merged into: 26.3.30.7

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]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [5646e49]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_asan, distributed plan, parallel, 1/2) failure
04238_alter_rename_column_merge_race FAIL cidb

@Avogar
Avogar merged commit f9c5ae1 into 26.3 Sep 3, 2026
32 of 35 checks passed
@Avogar
Avogar deleted the backport/26.3/110590 branch September 3, 2026 16:09
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
PROTO: a V3 JSON/Object structure prefix read from a stream (Native input, the format() table function, a corrupted
part) with a shared-data bucket count outside 1..256 -> the count sizes the per-bucket reader state unchecked.
Effect in the production build a394e92: the backport's test 05059_json_native_invalid_shared_data_buckets kills
the server (SIGABRT in collectSharedDataFromBuckets for a bucket count of 0, from one SELECT over format('Native',
...)) and passes on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/corrected3/).
The 26.3 backport takes only this guard from ClickHouse#110590 (a port of Cloud-only tests with several fixes); the other count
guards of ClickHouse#110590 are backported separately. Its upstream test 03057_private_attach_disk_web reads a public S3 web
disk and is no evidence either way.
Upstream patch unchanged, with its test: 05059_json_native_invalid_shared_data_buckets.

Co-Authored-By: Claude Opus 5.5 <[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]>
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.

1 participant