Skip to content

Cherry pick #118360 to 26.8: Require the local privilege for KILL and SYSTEM statements over ON CLUSTER - #122015

Merged
robot-ch-test-poll3 merged 6 commits into
backport/26.8/118360from
cherrypick/26.8/118360
Sep 24, 2026
Merged

robot-ch-test-poll3 merged 6 commits into
backport/26.8/118360from
cherrypick/26.8/118360

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 5 commits September 6, 2026 00:22
…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

# Conflicts:
#	src/Interpreters/InterpreterSystemQuery.cpp
…equired-access

Require the local privilege for KILL and SYSTEM statements over ON CLUSTER
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Conflict resolved; the resolution is on my fork

The conflict is a missing prerequisite rather than a divergence. ASTSystemQuery::Type::DISABLE_ALL_FAILPOINTS reached master in #118877 (pr-improvement, no backport label, no cherry-pick arms), so the context line this hunk anchors on does not exist on 26.8. It will not heal itself: ReleaseBranch._retry_cherrypick only force-pushes once the merge comes out clean, and that needs the prerequisite to land here, which is not going to happen.

#118360 only moves STOP_THREAD_FUZZER/START_THREAD_FUZZER and RESET_COVERAGE out of the no-required-access group in getRequiredAccessForDDLOnCluster; it adds and removes no case label. So the resolution leaves this branch's own label set untouched and only drops case Type::DISABLE_ALL_FAILPOINTS: (no such value on 26.8).

What I checked before pushing:

  • the 12 added lines are byte-identical to master's, and the single removed line is master's.
  • the switch stays exhaustive over this branch's Type (143 labels for 143 enum values), so -Wswitch is unaffected.
  • InterpreterKillQueryQuery.cpp and both test files merged with no conflict, and that hunk is byte-identical to master's.
  • ASTKillQueryQuery::Type and every AccessType the new code names already exist on 26.8, as do CLUSTER and the checkAccess(AccessType::CLUSTER) call site the fix depends on.
  • no conflict markers, and the result is a fast-forward of the current head.

I have triage and not push, so applying it needs one of you:

git fetch https://github.com/groeneai/ClickHouse resolve-26.8-cherrypick-118360
git push origin FETCH_HEAD:cherrypick/26.8/118360

…rypick/26.8/118360

# Conflicts:
#	src/Interpreters/InterpreterSystemQuery.cpp
@robot-ch-test-poll3
robot-ch-test-poll3 merged commit 9bc274d into backport/26.8/118360 Sep 24, 2026
1 check passed
@robot-ch-test-poll3
robot-ch-test-poll3 deleted the cherrypick/26.8/118360 branch September 24, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants