Skip to content

Fix potential out-of-bounds read in the ALP codec decompression - #103457

Merged
rienath merged 5 commits into
masterfrom
alp-bit-width-test
May 5, 2026
Merged

rienath merged 5 commits into
masterfrom
alp-bit-width-test

Conversation

@rienath

@rienath rienath commented Apr 23, 2026 •

Copy link
Copy Markdown
Member

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):

Fix potential out-of-bounds read in the ALP codec decompression path when processing malformed input with an invalid bit-width.

Version info

  • Merged into: 26.5.1.267
  • Backported to: 26.4.1.1137, 26.3.10.59

@clickhouse-gh

clickhouse-gh Bot commented Apr 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4b99e3c]

Summary: ✅


AI Review

Summary

This PR adds a defensive check for invalid ALP bit-width values before calculateBitpackedBytes and adds a regression test that reproduces malformed-input handling in decompression. I did not find new correctness, safety, or performance issues in the proposed change.

Missing context
  • ⚠️ No CI logs/results were available in the provided review context.
ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ✅
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@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 Apr 23, 2026

printf '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\234\032\0\0\0\0\040\0\0\001\010\0\004\0\0\0\0A\0\0\0\0\0\0\0\0' \
| ${CLICKHOUSE_CURL} "${CLICKHOUSE_URL}&decompress=1&http_native_compression_disable_checksumming_on_decompress=1" --data-binary @- \
| grep -c "Cannot decompress ALP-encoded data, invalid bit-width: 65, max allowed: 64"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's not grep the concrete error message and grep only the error code?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks, fixed. One reason to do this is to make sure test passes if we change error message. Are there any other ones that I am missing?

@Michicosun Michicosun self-assigned this Apr 26, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.00% -0.10%
Functions 91.10% 91.10% +0.00%
Branches 76.60% 76.60% +0.00%

Changed lines: 100.00% (8/8) · Uncovered code

Full report · Diff report

@rienath
rienath added this pull request to the merge queue May 5, 2026
Merged via the queue into master with commit d7cd1bc May 5, 2026
325 of 326 checks passed
@rienath
rienath deleted the alp-bit-width-test branch May 5, 2026 02:31
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 5, 2026
robot-ch-test-poll added a commit that referenced this pull request May 5, 2026
Cherry pick #103457 to 26.3: Fix potential out-of-bounds read in the `ALP` codec decompression
robot-clickhouse added a commit that referenced this pull request May 5, 2026
robot-ch-test-poll added a commit that referenced this pull request May 5, 2026
Cherry pick #103457 to 26.4: Fix potential out-of-bounds read in the `ALP` codec decompression
robot-clickhouse added a commit that referenced this pull request May 5, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label May 5, 2026
alexey-milovidov added a commit that referenced this pull request May 5, 2026
Backport #103457 to 26.4: Fix potential out-of-bounds read in the `ALP` codec decompression
alexey-milovidov added a commit that referenced this pull request May 6, 2026
Backport #103457 to 26.3: Fix potential out-of-bounds read in the `ALP` codec decompression
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label May 6, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…3457

Backport ClickHouse#103457 to 26.4: Fix potential out-of-bounds read in the `ALP` codec decompression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants