Skip to content

Fix crash when reading malformed ZSTD-compressed ORC files (25.8) - #116162

Merged
thevar1able merged 1 commit into
25.8from
backport/orc-zstd-error-check-25.8
Aug 26, 2026
Merged

thevar1able merged 1 commit into
25.8from
backport/orc-zstd-error-check-25.8

Conversation

@thevar1able

Copy link
Copy Markdown
Member

Backports the ORC-1966 fix to the vendored orc library: check the
return code of ZSTD_decompressDCtx / ZSTD_compressCCtx and raise an
exception instead of propagating the error code as a buffer length.

Reading a crafted ORC input with a corrupt ZSTD frame could otherwise
produce an out-of-bounds access when the bogus length reached footer
parsing or the string column reader. Newer releases already carry this
via the orc 2.3.1 bump; 25.8 did not, so this is a minimal targeted
backport of only the ZSTD error-handling change.

Changelog category (leave one):

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

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

Fix a possible crash when reading a malformed ZSTD-compressed ORC file.

Bump the vendored `orc` submodule to include the cherry-pick of
`ORC-1966` ("[C++] Fix ZSTD compress/decompress to propagate errors").

Without this check, `ZSTDDecompressionStream::decompress` returned the
raw `ZSTD_decompressDCtx` result. On a malformed ZSTD frame that call
returns an error code as a near-2^64 `size_t`, which `BlockDecompressionStream::NextDecompress`
stored as the decompressed length and passed downstream unchecked. This
produced two exploitable symptoms when reading a crafted ORC input:

- the corrupt length reached protobuf parsing of the file footer, causing
  an out-of-bounds `memcpy` and a server crash;
- the corrupt length reached the string blob reader feeding
  `readColumnWithStringData`, causing an out-of-bounds/uninitialized read
  copied into query results.

Both share this single root cause, so guarding the `ZSTD_isError` return
closes both. Newer releases (26.3+) already carry the fix via the
`orc` 2.3.1 bump; 25.8 did not receive that bump, so this is a minimal
targeted backport of only the ZSTD error-handling change.

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

clickhouse-gh Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [c7d4d8a]

@thevar1able
thevar1able requested a review from rschu1ze August 24, 2026 17:31
@rschu1ze rschu1ze self-assigned this Aug 24, 2026
@PedroTadim

This comment was marked as resolved.

@groeneai

This comment was marked as resolved.

@PedroTadim

This comment was marked as resolved.

@thevar1able
thevar1able merged commit 9ddaf42 into 25.8 Aug 26, 2026
33 checks passed
@thevar1able
thevar1able deleted the backport/orc-zstd-error-check-25.8 branch August 26, 2026 15:01
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.

4 participants