Skip to content

Bump vendored expat from 2.9.0 to 2.10.0 - #130311

Merged
thevar1able merged 2 commits into
ClickHouse:masterfrom
actueleai:bump-expat-R_2_10_0
Nov 10, 2026
Merged

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

Conversation

@actueleai

@actueleai actueleai commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Bumps the expat sources vendored under base/poco/XML from 2.9.0 to 2.10.0, picking up four security fixes in xmlparse.cpp, which parses every XML config and XMLStream payload.

CVEs

ClickHouse-side changes

  • base/poco/XML/src, base/poco/XML/include/Poco/XML: upstream 2.10.0 re-vendored; the EXPAT_POCO entropy, debug-removal and extern "C" patches and XML_ResetHandlerCallDepth are re-applied. New upstream header entities.h.
  • base/poco/XML/CMakeLists.txt: -Wno-declaration-after-statement for the new upstream xcsnstr.

Behaviour changes

  • Entity-amplification accounting now also charges indirect bytes, so documents with deeply nested entity expansions that parsed before may be rejected.

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

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

Update vendored expat from 2.9.0 to 2.10.0 to fix a crash, denial-of-service issues and an integer overflow in XML parsing.


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

Version info

  • Merged into: 26.11.1.1827-master (included in 26.11 and later)

`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_9_0` (commit a76b1174c1ea)
to `R_2_10_0` (commit a70841d9ffa6).

Security fixes that apply to code compiled here:

  - CVE-2026-113351 - denial of service via `XML_ParserReset` (`xmlparse.cpp`)
  - CVE-2026-115506 - billion laughs attacks are now detected quicker and for
    more of their variations: `accountingCurrentAmplificationTolerated` takes
    the not-yet-charged indirect bytes, and entity expanded sizes are resolved
    by an explicit-stack analysis in `resolveEntityClosureExpandedSize`
  - CVE-2026-117610 - segfault on initial non-final empty subparser parse calls
  - CVE-2026-118370 - signed integer overflow of `attIndex` and `nPrefixes` in
    `storeAtts`

CVE-2026-124317 is not mentioned in the upstream `Changes` for 2.10.0 (it is
not listed among the releases up to `R_2_10_0`) and is not fixed here.

Other upstream changes that matter for the compiled code: `XML_Parse` handles
`XML_CONTEXT_BYTES == 0` correctly, `m_parsingStatus.finalBuffer` is
initialized in `parserInit`, `isCalledFromInsideHandler` is checked first in
`XML_Parse`, a missing character-handler reset check and a missing
`m_startDoctypeDeclHandler` NULL check are added, `ENTITY.textLen` and
`ENTITY.processed` become `size_t`, and integer truncation in
`XmlGetAttributes`/`getAtts` is fixed. `parserInit` gained an `isReset`
parameter so that `XML_ParserReset` no longer clobbers the amplification
properties, and the allocator tracks `bytesAllocatedWhenLastReset` so one
document cannot skew the memory accounting of the next.

Local modifications re-applied on top of upstream 2.10.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
  - the removal of the `EXPAT_*_DEBUG` tracing (`getDebugLevel`,
    `unsignedCharToPrintable`, the accounting/entity/allocation report
    helpers, and the `debugLevel` and `peakBytesAllocated` fields), which
    upstream restructured in this release; the report call sites added by
    2.10.0 in `resolveEntityClosureExpandedSize` are dropped as well

Files: `entities.h` is a new upstream header included by `xmlparse.cpp` (with
the `Poco/XML/expat_external.h` include path applied). `xcs.h` gains the new
`xcsnstr` declaration; `xmlxcs.c` (upstream `xcs.c`) gains its definition.

`-Wno-declaration-after-statement` is added to the `_poco_xml_expat` target:
the new `xcsnstr` in `xmlxcs.c` declares a variable after a statement, which
`-Weverything` rejects even under `-std=gnu11`.

Co-Authored-By: Claude Code <[email protected]>
@thevar1able thevar1able added can be tested Allows running workflows for external contributors ci-skip-new-tests-check Ignore a check for new tests in bugfix PRs labels Nov 9, 2026
@thevar1able thevar1able self-assigned this Nov 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3887c9e]

Summary: ✅


AI Review

Summary

Updates Poco's vendored expat from 2.9.0 to 2.10.0, importing upstream security and parser fixes while retaining Poco's C++ adaptations. Reviewed head 3887c9e0f35231191e3f9464f6f59aa6c9f576d4. No blockers or major code findings. Five focused ASan/UBSan harness cases passed, covering initialization/reset, empty subparser input, attribute resizing/defaults, UTF-16 callback reset, and C++ exception cleanup.

Missing context / blind spots
  • ⚠️ Local execution covered the standalone parser with XML_GE=0 and explicit hash salts; it did not exercise the full ClickHouse/Poco integration, entropy provider, or other architectures. Normal build and integration CI supplies that coverage.
Findings

💡 Nits

  • PR description, “Behaviour changes” (build configuration): The claimed new rejection of deeply nested entity expansions does not apply to ClickHouse. The new accounting is guarded by XML_GE == 1, while this build still defines XML_GE=0. Replace that bullet with: “Entity expansion remains disabled in ClickHouse (XML_GE=0), so the upstream amplification-accounting changes do not alter accepted documents in this build.”
Final Verdict

Status: ✅ Approve. The description correction is non-blocking; no new inline review threads are warranted.

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. labels Nov 9, 2026
The style check's whitespace_check rejects ",  "; the other vendored expat
headers already carry the collapsed form.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3887c9e0f with master 4ce893869 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 5c1a21488; 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.

Compile time of recompiled translation units

12 translation units recompiled, 6 s compile time in total, 11 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +0.3 s (+6%) in total before that adjustment.

Job report

@thevar1able
thevar1able added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ClickHouse:master with commit f236eb4 Nov 10, 2026
187 checks passed
@thevar1able
thevar1able deleted the bump-expat-R_2_10_0 branch November 10, 2026 08:43
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 10, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 10, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #130311 to 26.9: Bump vendored `expat` from 2.9.0 to 2.10.0
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #130311 to 26.10: Bump vendored `expat` from 2.9.0 to 2.10.0
robot-ch-test-poll added a commit that referenced this pull request Nov 11, 2026
Cherry pick #130311 to 26.3: Bump vendored `expat` from 2.9.0 to 2.10.0
robot-ch-test-poll added a commit that referenced this pull request Nov 11, 2026
Cherry pick #130311 to 26.8: Bump vendored `expat` from 2.9.0 to 2.10.0
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 11, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 11, 2026
Backport #130311 to 26.8: Bump vendored `expat` from 2.9.0 to 2.10.0
thevar1able added a commit that referenced this pull request Nov 11, 2026
Backport #130311 to 26.3: Bump vendored `expat` from 2.9.0 to 2.10.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 ci-skip-new-tests-check Ignore a check for new tests in bugfix PRs 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-critical-bugfix 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.

5 participants