Repository navigation
Conversation
Cover replacement without scoped `DROP`, partial revokes cancelling independent requirements, and missing `GRANT OPTION` when restoring grants. Use the existing backup integration fixture because access backups include every entity of the requested type, making shared stateless access state unsuitable for these checks.
Require the corresponding `DROP` privilege for `create_access='replace'`, matching `CREATE ... OR REPLACE` even when the target does not exist. Build grant requirements separately and combine independent requirements with `AccessRights::makeUnion` so partial revokes cannot remove permissions required by other entities or tables. Restoring a grant requires `GRANT OPTION` even when the backed-up entity lacks it.
|
Workflow [PR], commit [e74b53f] AI ReviewSummaryThe PR requires Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block. Apply the replacement privilege check to masking policies and prove it with the focused Cloud regression; obtain passing results for the added integration tests. |
| /// `CREATE MASKING POLICY` is a GLOBAL-scope privilege, so the element carries no database or | ||
| /// table argument even though the policy itself names a table. | ||
| res.emplace_back(AccessType::CREATE_MASKING_POLICY); | ||
| res.grant(AccessType::CREATE_MASKING_POLICY); |
There was a problem hiding this comment.
❌ Blocker: require DROP MASKING POLICY for replacement restores.
In CLICKHOUSE_CLOUD builds, RESTORE TABLE system.masking_policies ... SETTINGS create_access='replace' reaches this branch but still requires only CREATE MASKING POLICY. restoreAccessEntitiesFromBackup passes replace_if_exists=true to destination_access_storage.insert for every restored entity type, and AccessControl::RestoreAccessStorage::insertImpl adds no caller privilege check. A user who can create masking policies and read the backup can therefore overwrite an existing policy with a weaker backed-up definition without DROP MASKING POLICY, leaving the same authorization gap this PR closes for row policies.
Include AccessType::DROP_MASKING_POLICY when replace is true, and add a Cloud regression case proving replacement is denied without that grant and succeeds after it is granted.
Require the corresponding scoped `DROP` privilege for `create_access='replace'`, matching `CREATE ... OR REPLACE` even when the target does not exist. Include `DROP_MASKING_POLICY` for the existing `CLICKHOUSE_CLOUD` branch. Build grant requirements separately and combine independent requirements with `AccessRights::makeUnion` so partial revokes cannot remove permissions required by other entities or tables. Restoring a grant requires `GRANT OPTION` even when the backed-up entity lacks it. Related: ClickHouse#127128
Superseded by the complete fix, including the
CLICKHOUSE_CLOUDmasking-policy branch, in the pull request below.Related: #127136
RESTOREwithcreate_access='replace'could overwrite access entities while checking only theirCREATEprivileges. Require the corresponding scopedDROPprivilege, including when the target does not exist, matchingCREATE ... OR REPLACE.Combine independent restoration requirements with
AccessRights::makeUnionso partial revokes in backed-up grants cannot remove privileges required to restore other entities or tables. Restoring grants also requiresGRANT OPTION, even when the backed-up entity does not have it.Regression tests cover row-policy replacement, user/role partial revokes, grant-option checks, and table restoration. They reuse the existing backup integration fixture because access backups include every entity of a requested type and need an isolated access store.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix insufficient privilege checks when restoring access entities. Replacement with
create_access='replace'now requires the correspondingDROPprivilege, and partial revokes in a backup cannot reduce the privileges required for restoration.Workflow [PR]
Sync PR [sync-upstream/pr/127128]