Skip to content

Bump vendored expat from 2.8.2 to 2.9.0 - #124255

Merged
thevar1able merged 2 commits into
ClickHouse:masterfrom
actueleai:bump-expat-R_2_9_0
Oct 14, 2026
Merged

thevar1able merged 2 commits into
ClickHouse:masterfrom
actueleai:bump-expat-R_2_9_0

Conversation

@actueleai

@actueleai actueleai commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Bump the vendored expat in base/poco/XML from 2.8.2 to 2.9.0. The pin had also missed the 2.8.3–2.8.5 security releases.

CVEs

Attacker-controlled XML reaches expat only through backup manifests (.backup, read by RESTORE from user-chosen storage); every other input is operator-controlled configuration (server config, include_from/from_zk/from_env, UDF and dictionary files).

  • CVE-2026-66046 (HIGH, fixed in 2.8.4) — applies: a crafted multi-megabyte manifest spins a CPU during RESTORE (quadratic attribute handling).
  • CVE-2026-93990 (fixed in 2.8.5) — applies, low impact: lone UTF-16 surrogates silently alter characters; no memory corruption in this UTF-8 build.
  • Unrelated to ClickHouse's build or usage: CVE-2026-76641 (faulty intermediate fix never shipped in 2.8.2; needs external entity parsers, which Poco disables), CVE-2026-76957 (Poco's encoding callback never re-enters the parser), CVE-2026-76956 (entropy comes from Poco::RandomStream, expat's own path is not compiled), CVE-2026-72522 (needs XML_UNICODE), CVE-2026-77214 (Poco calls XML_Parse, never XML_ParseBuffer), CVE-2026-102633 (32-bit only, XML_GE=0).

ClickHouse-side changes

  • Re-vendored src/xmlparse.cpp, src/xmltok*.c, src/xmlrole.c, their headers and include/Poco/XML/expat*.h; new upstream src/xcs.h, src/hash_table.h, src/xmlxcs.c (upstream xcs.c, renamed to match the xml*.c glob); src/xcsinc.c removed upstream.
  • Local patches re-applied: EXPAT_POCO entropy override, C++ casts, extern "C" guards (upstream dropped them; xmlparse.cpp is C++ here).
  • CMakeLists.txt: -Wno-unreachable-code-return for _poco_xml.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Update the vendored expat to 2.9.0, fixing a denial of service through a crafted backup manifest during RESTORE (CVE-2026-66046) and the other 2.8.3–2.9.0 security fixes.


Workflow [PR]
Sync PR [sync-upstream/pr/124255]

Version info

  • Merged into: 26.10.1.2375-master (included in 26.10 and later)
  • Backported to: 26.9.19.13, 26.8.27.13, 26.7.31.8, 26.3.54.5

`expat` is not a submodule: Poco vendors it, so the sources are re-vendored by
hand. This brings `base/poco/XML` from upstream `R_2_8_2` to `R_2_9_0` (commit
a76b1174c1ea), which also folds in the intermediate releases 2.8.3, 2.8.4 and
2.8.5.

Security fixes that apply to code compiled here:

  - CVE-2026-77214 - `XML_ParseBuffer` did not validate `len` against the
    available buffer capacity (`xmlparse.cpp`)
  - CVE-2026-66046, CVE-2026-76641 - quadratic runtime from "attribute isCdata
    lookups", a denial of service (2.8.4)
  - CVE-2026-76957 - custom encoding callbacks could re-enter the parser (2.8.4)
  - CVE-2026-76956 - inverted `getentropy` return handling (2.8.4); not
    reachable here because `EXPAT_POCO` replaces expat's entropy gathering
  - CVE-2026-93990 - malformed UTF-16 smuggling (2.8.5); needs UTF-16 input,
    not reachable with the UTF-8 build used here
  - CVE-2026-72522 - out-of-bounds read in `*_toUtf16` (2.8.3); needs 16-bit
    character support, not enabled here

CVE-2026-102633 (integer overflow in `expat_realloc` on 32-bit platforms) does
not apply: `expat_realloc` is only compiled with `XML_GE == 1`, while this
build defines `XML_GE=0` and targets 64-bit platforms.

Other upstream changes that matter for the compiled code: the `XML_ATTR_INFO`
and `XML_MIN_SIZE` features are dropped; `XML_ParserReset` now handles OOM
while copying `encodingName`; the unknown encoding release callback runs before
parser teardown; new Properties API and 64-bit location API functions are
added; `xcs` is split out of `xmlparse.c` into `xcs.c`/`xcs.h`, and the hash
table moves into `hash_table.h`.

Local modifications re-applied on top of upstream 2.9.0:

  - the `EXPAT_POCO` blocks that replace expat entropy gathering with
    `Poco::RandomStream` (including reading into `unsigned long` for macOS)
    and the `XML_ResetHandlerCallDepth` helper
  - the `Poco/XML/expat.h` and `Poco/XML/expat_external.h` include paths
  - explicit casts on `malloc`/`realloc` results and on `void *data`, needed
    because `xmlparse.cpp` is compiled as C++
  - `extern "C"` guards in `internal.h`, `xmltok.h`, `xmlrole.h` and `xcs.h`,
    which upstream removed when it stopped mixing C and C++ translation units;
    here `xmlparse.cpp` is C++ while `xmltok.c`, `xmlrole.c` and `xmlxcs.c`
    are C

Files: `hash_table.h`, `xcs.h` and `xmlxcs.c` (upstream `xcs.c`, renamed so the
`src/xml*.c` glob compiles it, since it is now a standalone source) are added;
`xcsinc.c` is removed (upstream folded it into `xcs.c`); the rest of the
vendored expat sources and headers are updated.

`-Wno-unreachable-code-return` is added to the `_poco_xml` target: the new
`XML_GetPropertyFloat64` and `XML_GetPropertyUInt64` end with a `return` that is
unreachable because their `switch` handles every enum value.

Co-Authored-By: Claude Code <[email protected]>
@thevar1able thevar1able added the can be tested Allows running workflows for external contributors label Oct 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5edd4ed]

Summary: ❌

job_name test_name status info comment
Finish Workflow FAIL
python3 ./ci/jobs/scripts/workflow_hooks/new_tests_check.py FAIL

AI Review

Summary

This PR revendors expat in base/poco/XML from 2.8.2 to 2.9.0 and re-applies the local Poco/ClickHouse integration patches. The import itself looks consistent and the Praktika matrix is green apart from new_tests_check.py, but I still see review blockers around a stale CVE-applicability note in the PR body and the lack of focused regression evidence for the RESTORE-reachable streaming-parser path this PR claims to harden.

Findings

💡 Nits

  • [base/poco/XML/src/XMLStreamParser.cpp:675] The PR body still says CVE-2026-77214 does not apply because Poco "never calls XML_ParseBuffer", but the streaming parser still feeds expat through XML_GetBuffer + XML_ParseBuffer here. Please update the security-applicability section to mark that CVE as applicable, or at least drop that rationale.
Tests
  • ⚠️ The PR is labeled Bug Fix and claims to harden attacker-controlled backup-manifest parsing during RESTORE, but it still ships without a focused regression or other explicit evidence for that XMLStreamParser / XML_GetBuffer / XML_ParseBuffer path. The only failing CI job on 2026-10-07 is new_tests_check.py in the Finish Workflow report for the same reason. A minimal ClickHouse-level test, or an explicit note that upstream expat regression coverage is the intended exception, would close this gap.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Update the PR body so the CVE-2026-77214 applicability note matches the current Poco call path.
    • Add focused regression evidence for the RESTORE / streaming-parser fix path, or document why local coverage is impractical and the upstream expat coverage is sufficient here.

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Oct 6, 2026
return XML_STATUS_ERROR;
}

// Detect and avoid integer overflow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The security applicability note in the PR body is stale here: it says CVE-2026-77214 does not apply because Poco never calls XML_ParseBuffer, but base/poco/XML/src/XMLStreamParser.cpp:675 still drives expat through XML_GetBuffer + XML_ParseBuffer. Please update the description to treat that CVE as applicable, or at least drop the “never calls XML_ParseBuffer” rationale.

@clickhouse-gh clickhouse-gh Bot added the comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. label Oct 6, 2026
@clickhouse-gh

clickhouse-gh Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 5edd4ed18 with master 6be68fd92 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

7 object files changed (+4.16 KiB total), 1 added.

Object file Master PR Δ

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

156 translation units recompiled, 523 s compile time in total, 154 of them have a recent master baseline.

Job report

The old glibc in the ppc64le sysroot defines `strncmp` as a recursive
macro in `bits/string2.h`, and `xmlxcs.c` from expat 2.9.0 calls
`strncmp` directly, which fails the build under `-Weverything -Werror`.
The other poco targets already suppress this warning.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default and removed pr-critical-bugfix labels Oct 7, 2026
@thevar1able
thevar1able added this pull request to the merge queue Oct 14, 2026
@thevar1able thevar1able self-assigned this Oct 14, 2026
Merged via the queue into ClickHouse:master with commit 0a46f51 Oct 14, 2026
297 of 301 checks passed
@thevar1able
thevar1able deleted the bump-expat-R_2_9_0 branch October 14, 2026 13:28
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 14, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR labels Oct 14, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 14, 2026
Backport #124255 to 26.9: Bump vendored `expat` from 2.8.2 to 2.9.0
clickhouse-gh Bot added a commit that referenced this pull request Oct 14, 2026
Backport #124255 to 26.8: Bump vendored `expat` from 2.8.2 to 2.9.0
clickhouse-gh Bot added a commit that referenced this pull request Oct 14, 2026
Backport #124255 to 26.7: Bump vendored `expat` from 2.8.2 to 2.9.0
strtgbb pushed a commit to Altinity/ClickHouse that referenced this pull request Oct 15, 2026
thevar1able added a commit that referenced this pull request Oct 16, 2026
Backport #124255 to 26.3: Bump vendored `expat` from 2.8.2 to 2.9.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants