Repository navigation
Reject path traversal in file names from part checksums - #120356
Conversation
File names read from `checksums.txt` were stored without validation and later used verbatim to build paths inside the part directory, both in `MergeTreeDataPartChecksum::checkSize` and when the part directory is cleared on removal. A forged `checksums.txt` could therefore reference files outside the part directory. Validate names in `MergeTreeDataPartChecksums::readV2` and `readV3` (`readV4` delegates to `readV3`): reject empty names, absolute names and names containing `.` or `..` path components with `UNEXPECTED_FILE_IN_DATA_PART`. Related: ClickHouse/clickhouse-private#72532 Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Workflow [PR], commit [7615af5] Summary: ❌
AI ReviewSummaryThis PR closes the original path-traversal bug by validating file names while parsing MergeTree part Findings
Final Verdict
LLVM Coverage ReportMeasured on commit 7615af5.
Changed lines: Changed C/C++ lines covered: 13/24 (54.17%) · Uncovered code |
Build profile diff (arm_release)Comparing commit See the job log for details. |
`readStringBinary` accepts embedded NUL bytes and `std::filesystem::path` keeps them inside a single component, so a name like `"..\0/x"` passed the `..` component check. On local disks the joined path is then handed to C APIs which truncate at the first NUL, so it acted as `..` and escaped the part directory. Reject names containing `\0` before splitting them into components. Addresses: #120356 (comment) Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
It's important bugfix, can be merged red. |
Backport #120356 to 26.8: Reject path traversal in file names from part checksums
Backport #120356 to 26.9: Reject path traversal in file names from part checksums
Backport #120356 to 26.6: Reject path traversal in file names from part checksums
Backport #120356 to 26.3: Reject path traversal in file names from part checksums
…es from part checksums
…es from part checksums
Backport #120356 to 26.7: Reject path traversal in file names from part checksums
…es from part checksums
File names read from
checksums.txtwere stored without validation and later used verbatim to build paths inside the part directory, both inMergeTreeDataPartChecksum::checkSizeand when the part directory is cleared on removal. A forgedchecksums.txtcould therefore reference files outside the part directory.Validate names in
MergeTreeDataPartChecksums::readV2andreadV3(readV4delegates toreadV3): reject empty names, absolute names and names containing.or..path components withUNEXPECTED_FILE_IN_DATA_PART.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Now ClickHouse reject relative paths in
checksums.txt.Workflow [PR]
Sync PR [sync-upstream/pr/120356]
Version info
26.10.1.19(included in26.10and later)26.9.1.1597,26.8.7.12,26.6.9.13,26.3.33.102