Repository navigation
Conversation
…r .. components checkPath joined a relative File() destination with the raw first backups.allowed_path entry, while ClickHouse#111394 started comparing it with the lexically normalized entries. When the first entry was not in normal form (`/w/./backups`, `/w/sub/../backups`, or a relative `../backups` resolved against the data path), lexically_proximate returned a path starting with `..` and every entry was rejected with BAD_ARGUMENTS. Absolute paths were not affected because they are normalized before the check. Normalize the joined path as well, so a relative destination resolves exactly like its absolute spelling: a `..` that comes back into an allowed entry is accepted, one that ends outside every entry is still rejected. Closes ClickHouse#125871 Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-local keeps a relative --path as given, so a relative backups.allowed_path entry resolved to a relative backup area (for example `--path ./data` with `../backups`, or `--path .` with `backups`). The directory fsync added by ClickHouse#111394 assumes an absolute area: for a relative one that does not exist yet, the boundary walk in the BackupWriterFile constructor climbs to the empty path, and BACKUP fails with `Cannot open directory for fsync` after writing the whole backup. 26.9 accepted these spellings. Make the data path absolute before checkPath joins it. fs::absolute is lexical, like the rest of checkPath, and is the identity for the server, whose path is already absolute. The test gets the relative --path arm. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… ancestor entry With overlapping backups.allowed_path entries where a later entry contains the first one, a relative destination such as `../../escape` was joined with the first entry without normalization, and the later entry then matched the joined path lexically (`backups/../../escape` does not start with `..`), so the backup was written outside every entry. The normalization of the joined path in checkPath closes this; add the overlapping-entry case to 05398 so that a revert of it fails the test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 3 rounds, 2 findings, the last round clean) plus my own review (3 findings).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261015-001800 |
|
cc @pamarcos @jkartseva, could you review this and add |
|
Workflow [PR], commit [e1d6e61] Summary: ✅
AI ReviewSummaryThe PR normalizes relative Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
d93763c
Closes: #125871
Related: #111394
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix the
backups.allowed_pathcheck for relativeFile()backup destinations: the destination is now normalized before the check, so a relative path whose..leaves every allowed entry is rejected even when one allowed entry contains another. Closes #125871.Description
On 26.9, a relative
File()destination whose..leaves the firstbackups.allowed_pathentry is accepted when a later entry contains the first one, and the backup is written outside every entry: the destination is joined with the first entry without normalization and the later entry then matches it lexically.On master, #111394 normalizes the entries but not the joined path, so
BACKUP ... TO File('b1')andRESTORE ... FROM File('b1')fail withBAD_ARGUMENTSwhen the first entry is not in lexical normal form (/w/./backups,/w/sub/../backups, or a relative../backups). With clickhouse-local and a relative--path, the area also stays relative, and when it does not exist yet the directory fsync added by #111394 fails withCannot open directory for fsync.The data path is made absolute and the joined path is normalized before the check. A relative path now resolves exactly like its absolute spelling: a
..that comes back into an allowed entry (File('../backups/b2')) is accepted, and a path that ends outside every entry is rejected. Like absolute paths and the entries, the joined path is normalized lexically, so a..that follows a symbolic link in an entry, or in the data path a relative entry is resolved against, no longer goes through the link as it did in 26.9. AbsoluteFile('/...')destinations andDisk()are not affected.The new test covers five cases (four spellings of the entry and
--path, and overlapping entries), the re-entry, and escapes that must be rejected. It fails on master and passes with the fix (50/50 randomized runs); the existing backup tests show no new failures.A backport to 26.9 or older also needs the entry normalization from #111394: with raw entries, a normalized path is rejected under an entry like
/w/./backups.Workflow [PR]
Sync PR [sync-upstream/pr/125911]
Version info
26.11.1.3-master(included in26.11and later)