Repository navigation
Do not expose uninitialized memory in query results - #115704
Conversation
|
Workflow [PR], commit [7803723] Summary: ✅
AI ReviewSummaryThis PR closes two real uninitialized-memory disclosure paths: binary string literals now build the result from the number of bytes actually decoded, and LZ4 decompression now fails instead of reporting success when the compressed body is empty but the caller expects output. The current branch also adds focused stateless coverage for both regressions, so the fixes and evidence match the stated contract. Final Verdict
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/6 (83.33%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Compile time of recompiled translation units8 translation units recompiled, 10 s compile time in total, 8 of them have a recent master baseline. |
…emory-in-results # Conflicts: # src/Functions/formatRow.cpp
The compressed block declares a compressed size equal to the size of the
header and a non-zero uncompressed size, so `LZ4::decompress` has nothing
to read from. Before the fix it reported success without writing anything,
and the destination buffer, which is used as the text of the query in this
test, was handed out with whatever it contained. The response to the
request then quoted the leaked bytes back to the client, for example:
Code: 62. DB::Exception: Syntax error: failed at position 1 (DB): DB::HTTPHandler:.
The checksum of the block is not verified thanks to
`http_native_compression_disable_checksumming_on_decompress`, which makes
it possible to craft such a block from a test.
Co-Authored-By: Claude Fable 5 <[email protected]>
Backport #115704 to 26.6: Do not expose uninitialized memory in query results
Backport #115704 to 26.7: Do not expose uninitialized memory in query results
Cherry pick #115704 to 25.8: Do not expose uninitialized memory in query results
Backport #115704 to 25.8: Do not expose uninitialized memory in query results
Backport #115704 to 26.5: Do not expose uninitialized memory in query results
Backport #115704 to 26.3: Do not expose uninitialized memory in query results
…y in query results
…y in query results
…y in query results
OTHER: binary literal whose length is not a multiple of 8; empty LZ4 block -> wrong (uninitialized memory). Effect in the production build a394e92: wrong/failing (the upstream test fails on it and passes on official 26.8.8.8; evidence/fix_ci_20260925/upstream_repro/residual/115704.PROD263.txt). Upstream patch unchanged, with its test(s): 05024_binary_string_literal_uninitialized_byte, 05028_lz4_empty_compressed_body. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two places where uninitialized or stale memory could end up in the result of a query:
b'...') is allocated for the worst case,ceil(bits / 8)bytes, but when the number of bits is not a multiple of eight fewer bytes are written, and the
result was built from the size of the buffer rather than from the number of bytes written. So
SELECT hex(b'000000001')returned01followed by a byte of uninitialized memory.LZ4::decompressreturned success without writing anything when the compressed block was emptywhile the caller expected a non-empty result, and the caller then handed out whatever was in the
destination buffer.
A third one,
formatRowNoNewlinestepping the position of a shared buffer back into the previousrow, was in this pull request initially; it was fixed separately in
#115669, which is already in
master, so this branchnow carries the version from
master.Related: #115669
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Do not return uninitialized memory in the result of a binary string literal whose length is not a multiple of eight, and from the LZ4 decompressor when a compressed block has no body.
Workflow [PR]
Sync PR [sync-upstream/pr/115704]
Version info
26.8.1.1909(included in26.8and later)26.7.6.8,26.6.4.13,26.5.8.24,26.3.23.6,25.8.33.5