Repository navigation
Conversation
Stress test (arm_asan_ubsan, s3) reported (STID 3543-4a91) a signed integer overflow at contrib/thrift/lib/cpp/src/thrift/protocol/TCompactProtocol.h:160:49 = trans_->checkReadBytesAvailable(map.size_ * elmSize) in checkReadBytesAvailable(TMap&). map.size_ (int32) times elmSize (int) is read from the compact-protocol wire (corrupt/fuzzed Parquet/ORC metadata) and overflows signed int. The same size times element-size idiom is present in the Set and List overloads and in TBinaryProtocol and TProtocol. This is vendored third-party Thrift arithmetic; the read it guards stays bounded and rechecked by the transport, so release builds are unaffected and only the UBSan sanitizer build aborts. Ignorelist the Thrift protocol sources for UBSan, consistent with the existing contrib/boost/boost/geometry and contrib/protobuf entries. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Internal second-model review (click to expand)Independent second-model (codex) review of this diff.
Re-run on the final diff: 0 findings. |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-author-slot-1:20260721-074100 |
|
cc @pamarcos - could you review this? It adds a UBSan ignorelist entry for the third-party Thrift protocol sources (contrib/thrift/lib/cpp/src/thrift/protocol/*), where checkReadBytesAvailable multiplies a wire-controlled map/list/set size by the element size and overflows signed int on corrupt/fuzzed Parquet metadata (STID 3543-4a91). Scoped like the existing boost/geometry entry. |
|
Workflow [PR], commit [0a0b2ef] Summary: ❌
|
|
Apache Thrift already fixed this exact defect, including regression tests, in 983c813c (apache/thrift@983c813). @oranjeai my suggestion is to sync v0.24.0 to our fork to include that commit. Then, cherry-pick the additions we had in v0.23.0 to the original version: ClickHouse/thrift@f95a731 and ClickHouse/thrift@248688d. Do that in a separate PR, I'm closing this one. |
|
Acknowledged. I'll sync ClickHouse/thrift to Apache Thrift v0.24.0 (which includes 983c813c), cherry-pick f95a731b and 248688d4 on top, then open a new PR bumping the contrib/thrift submodule and dropping the UBSan ignorelist entry. I'll post the new PR link here. |
|
Opened the sync as ClickHouse/thrift#10: base Apache Thrift
Verified inside ClickHouse: I don't have push access to ClickHouse/thrift, so #10 comes from a fork branch targeting |
|
Follow-up on the v0.24.0 sync: @thevar1able created the
|
Point contrib/thrift at the ClickHouse/thrift ClickHouse/v0.24.0 branch
(13d30d6a): Apache Thrift v0.24.0 with the ClickHouse patch f95a731b
("Don't use locale in to_string") cherry-picked.
v0.24.0 includes Apache commit 983c813c, which widens the compact-protocol
container-size prechecks to int64 (static_cast<int64_t>(size_) * elemSize),
fixing a signed-integer overflow on wire-controlled sizes. This is the
upstream fix for UBSan finding STID 3543-4a91, superseding the ubsan_ignorelist
approach from ClickHouse#111186 (closed) as suggested by @pamarcos.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Description
Ignorelist third-party Thrift for UBSan.
Stress test (arm_asan_ubsan, s3)reported (STID 3543-4a91):Line 160 is
trans_->checkReadBytesAvailable(map.size_ * elmSize)inTCompactProtocol::checkReadBytesAvailable(TMap&).map.size_(int32) andelmSizeare read from the compact-protocol wire (corrupt/fuzzed Parquet/ORC metadata), so a large declared map cardinality overflows signedint. This is vendored third-party Thrift arithmetic; the read it guards is still bounded and rechecked by the transport, so there is no unbounded read or allocation in a release build. Only the UBSan sanitizer build aborts on the overflow.The same
size * element-sizeidiom is present in theTSet/TListoverloads and inTBinaryProtocol/TProtocol. Addsrc:*/contrib/thrift/lib/cpp/src/thrift/protocol/*totests/ubsan_ignorelist.txt, scoped to the protocol sources (like the existingcontrib/boost/boost/geometrysubtree entry), consistent with the existing third-party UBSan entries.Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110171&sha=b3699207b14e085180bef427dac73696403b023c&name_0=PR&name_1=Stress%20test%20%28arm_asan_ubsan%2C%20s3%29