Repository navigation
Fix CREATE OR REPLACE bypassing the drop privilege of the replaced table via Replicated databases and ON CLUSTER - #122272
Conversation
…LACE leaves the initiator
|
Workflow [PR], commit [f6058a3] Summary: ✅
AI ReviewSummaryThis PR moves the replacement-time Findings
Tests
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit f6058a3.
Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code |
…style rule in test 05238
| String database_name = getContext()->resolveDatabase(create.getDatabase()); | ||
| if (auto database = DatabaseCatalog::instance().tryGetDatabase(database_name)) | ||
| if (auto table = database->tryGetTable(create.getTable(), getContext())) | ||
| required_access.emplace_back(getDropAccessType(*table), database_name, create.getTable()); |
There was a problem hiding this comment.
This still authorizes only against the initiator's local catalog. For ON CLUSTER, executeDDLQueryOnCluster later expands empty database names to each host's default DB, and createTable already documents that the target database may be absent on the initiator. In both cases this block can add no DROP_DICTIONARY/DROP_TABLE requirement even though a remote worker will still replay the replacement with full access, so the RBAC bypass remains for remote-only or default-db-mismatched targets.
Please derive the extra drop grant from the same per-host target set that distributed DDL uses, or re-check the concrete remote object kind under the original user on the worker before the swap.
There was a problem hiding this comment.
The initiator can only authorize against objects it can see, as with every ON CLUSTER check. It cannot learn the kind of a remote-only object. For that case, distributed_ddl_use_initial_user_and_roles already makes each worker run this check as the initiating user.
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, 22 s compile time in total, 7 of them have a recent master baseline. |
6caf070
Backport #122272 to 26.9: Fix `CREATE OR REPLACE` bypassing the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
Backport #122272 to 26.8: Fix `CREATE OR REPLACE` bypassing the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
… the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
… the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
Backport #122272 to 26.7: Fix `CREATE OR REPLACE` bypassing the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
Cherry pick #122272 to 26.3: Fix `CREATE OR REPLACE` bypassing the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
…privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
Backport #122272 to 26.3: Fix `CREATE OR REPLACE` bypassing the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
… the drop privilege of the replaced table via `Replicated` databases and `ON CLUSTER`
CREATE OR REPLACEsent to aReplicateddatabase or withON CLUSTERis replayed with full access, so the drop privilege for the kind of the replaced table was never checked and a user with onlyCREATE VIEWandDROP VIEWcould replace a dictionary with a view. The privilege is now required ingetRequiredAccess, which every path checks on the initiator as the real user.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
CREATE OR REPLACEin aReplicateddatabase or withON CLUSTERnow requires the drop privilege for the kind of the table it replaces, so a user withoutDROP DICTIONARYcan no longer replace a dictionary.Workflow [PR]
Sync PR [sync-upstream/pr/122272]
Version info
26.10.1.1221-master(included in26.10and later)26.9.9.13,26.8.16.19,26.7.20.12,26.3.40.16