Repository navigation
Cherry pick #118360 to 26.8: Require the local privilege for KILL and SYSTEM statements over ON CLUSTER - #122015
Conversation
…USTER Five statements required no privilege at all when spelled ON CLUSTER, while their local spellings refused the same user: KILL TRANSACTION KILL PART_MOVE_TO_SHARD SYSTEM STOP THREAD FUZZER SYSTEM START THREAD FUZZER SYSTEM RESET COVERAGE For an ON CLUSTER statement, getRequiredAccessForDDLOnCluster is the only authorization boundary: executeDDLQueryOnCluster runs context->checkAccess(access_to_check), which is a no-op on an empty list, and the worker that then runs the statement on each host re-executes with no user unless the server setting distributed_ddl_use_initial_user_and_roles is on, which defaults to false. So a holder of CLUSTER alone could roll back other users' transactions cluster-wide, cancel part moves between shards, and flip the thread fuzzer and the coverage counters on every node. Two chains left the list empty for a reachable statement. The KILL chain was an if/else if with no terminal else covering 2 of the 4 ASTKillQueryQuery::Type enumerators, while ParserKillQueryQuery parses the ON CLUSTER clause uniformly for all four. In InterpreterSystemQuery a grouped arm opted eight types into an empty break, and three of them are reachable because they have no explicit parser case and so fall into a default: arm that calls parseQueryWithOnCluster. The recurring cause is that the parser makes ON CLUSTER the default for a SYSTEM type with no explicit case while the authorization mapper's default is an empty list. Each statement now requires exactly what its own local path checks, in the order the local path checks it, so the message an ON CLUSTER refusal prints is the one the local spelling prints. The KILL chain became a switch with no default:, so a future enumerator is a compile error at the mapping site rather than a silent bypass. KILL PART_MOVE_TO_SHARD is the one place where the initiator cannot reproduce the local check exactly: the local path checks ALTER MOVE PARTITION and MOVE PARTITION BETWEEN SHARDS per matched row, and the WHERE clause is arbitrary, so the initiator cannot know the target tables and requires both flags globally instead. That is stronger in scope than the local check, never weaker, and it is the shape the neighbouring Type::Mutation arm has always used. The failpoint statements and SYSTEM SET COVERAGE TEST stay on the empty arm: their parser cases never read an ON CLUSTER clause, so those cluster spellings do not parse.
`KILL TRANSACTION ... WHERE tid = (1, 1, '000...')` only has to match no live transaction; comparing `tid` was an incidental way to spell that. The tuple has four elements in the ClickHouse Inc. build and three here, so the comparison fails type analysis there before the access check the test is about is even reached, and `CH Inc sync` reported: ``` Code: 43. DB::Exception: Illegal types of arguments (`Tuple(UInt64, UInt64, UUID, Int64)`, `Tuple(UInt8, UInt8, String)`) of function `equals` ``` Match on `tid_hash` instead, which is a `UInt64` in both and is never 0 for a live transaction, so every allowed arm stays the no-op it was. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…-system-required-access
…-system-required-access # Conflicts: # src/Interpreters/InterpreterSystemQuery.cpp
…equired-access Require the local privilege for KILL and SYSTEM statements over ON CLUSTER
Conflict resolved; the resolution is on my forkThe conflict is a missing prerequisite rather than a divergence. #118360 only moves What I checked before pushing:
I have |
…rypick/26.8/118360 # Conflicts: # src/Interpreters/InterpreterSystemQuery.cpp
Original pull-request #118360
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job