Fix permission issues in BACKUP/RESTORE operations#94617
Fix permission issues in BACKUP/RESTORE operations#94617pamarcos merged 9 commits intoClickHouse:masterfrom
Conversation
1. Forbid RESTORE in readonly mode - RESTORE modifies data, so it should be blocked when `readonly` setting is enabled 2. Forbid `internal` setting for initial queries - this setting is only meant for ON CLUSTER secondary queries, not user-specified 3. Check BACKUP permissions before opening backup destination - prevents establishing S3/remote connections before access is verified
|
Workflow [PR], commit [4737b78] Summary: ❌
|
There was a problem hiding this comment.
Pull request overview
This PR addresses three critical security vulnerabilities in BACKUP/RESTORE operations by implementing proper permission checks and access controls before potentially expensive operations occur.
Changes:
- Added validation to prevent user-specified
internalsetting for BACKUP/RESTORE queries (only allowed for ON CLUSTER secondary queries) - Added check to forbid RESTORE operations when
readonlysetting is enabled - Moved BACKUP permission verification before opening backup destination connections (e.g., S3)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Backups/BackupsWorker.cpp | Implements security checks: validates internal setting for both BACKUP and RESTORE, blocks RESTORE in readonly mode, and verifies BACKUP permissions before opening connections |
| tests/queries/0_stateless/03799_backup_restore_security.sh | Adds test cases covering readonly RESTORE blocking, internal setting validation, and permission check ordering |
| tests/queries/0_stateless/03799_backup_restore_security.reference | Expected output for the security test |
The previous check `if (readonly)` blocked RESTORE for both readonly=1 and readonly=2. However, readonly=2 is automatically set by the HTTP interface for non-POST requests to protect against accidental writes. This was causing legitimate RESTORE operations via HTTP sessions to fail. Now we only block readonly=1 (strict read-only mode explicitly set by the user) while allowing readonly=2 which is used by the HTTP interface for its automatic protection mechanism.
jkartseva
left a comment
There was a problem hiding this comment.
The change LGTM, but the test requires a fix.
@jkartseva what's wrong with the test? The only thing that failed was the Bugfix validation but I think it's a limitation of our CI that the job it's flagged as a failure even though the test works in the new version while it does not in the prior version. Or maybe there's something I'm missing, but I think it's a false negative. |
jkartseva
left a comment
There was a problem hiding this comment.
The CI was failing because of invalid access key – sorry, I did not save the link to the logs.
LGTM.
cd03cf4
Cherry pick #94617 to 25.11: Fix permission issues in BACKUP/RESTORE operations
Cherry pick #94617 to 25.12: Fix permission issues in BACKUP/RESTORE operations
Cherry pick #94617 to 25.10: Fix permission issues in BACKUP/RESTORE operations
Cherry pick #94617 to 25.8: Fix permission issues in BACKUP/RESTORE operations
Backport #94617 to 25.11: Fix permission issues in BACKUP/RESTORE operations
Backport #94617 to 25.12: Fix permission issues in BACKUP/RESTORE operations
Cherry pick #94617 to 25.3: Fix permission issues in BACKUP/RESTORE operations
Backport #94617 to 25.8: Fix permission issues in BACKUP/RESTORE operations
Backport #94617 to 25.10: Fix permission issues in BACKUP/RESTORE operations
Backport #94617 to 25.3: Fix permission issues in BACKUP/RESTORE operations
Fix permission issues in BACKUP/RESTORE operations
readonlysetting is enabledinternalsetting for initial queries - this setting is only meant for ON CLUSTER secondary queries, not user-specifiedCloses https://github.com/ClickHouse/clickhouse-private/issues/45780
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix permission issues in BACKUP/RESTORE operations
Documentation entry for user-facing changes