Repository navigation
26.8: Keep external roles when copying a Context - #121643
Merged
Merged
Conversation
Since #110867 a remote node of a secret interserver query enables the initiator's current roles only as external roles and clears the user's default roles. The `ContextData` copy constructor did not copy `external_roles`, so any copied context that recalculated access (for example, a view with an access-related setting in its `SETTINGS` clause) lost all roles and a user whose grants come from roles got `ACCESS_DENIED` on the remote node. This is the relevant part of #110144 (master): copy `external_roles` and make `setExternalRolesWithLock` replace the list instead of appending, so that `setUser` on a copied context (e.g. `EXECUTE AS`) does not inherit the pushed roles.
Contributor
|
Workflow [BackportPR], commit [b4bef00] Summary: ❌
|
abraithwaite
added a commit
to abraithwaite/ClickHouse
that referenced
this pull request
Oct 5, 2026
…es to remote read nodes Backport of ClickHouse#110867 (Propagate current roles to remote read nodes) and the follow-up regression fix ClickHouse#121643 (Keep external roles when copying a Context) to the 26.3 LTS branch. When a query sets its active roles via SET ROLE / role=, those roles were not propagated to remote nodes on parallel-replica and Distributed reads over an interserver-secret cluster. Row policies on remote nodes fell back to the user's default roles instead of the active roles. This patch: 1. Adds a new ClientInfo wire field (current_roles) at protocol version 54485, carrying the initiator's active role names to remote nodes. 2. Includes current_roles in the interserver auth hash so they cannot be tampered with in transit. 3. On the receiver (Session.cpp), resolves the forwarded role names to UUIDs, pushes them as external roles, and clears the user's default roles so row policies are evaluated consistently with the initiator. 4. Fixes the ContextData copy constructor to copy external_roles (the regression from ClickHouse#121643 that caused ACCESS_DENIED on remote nodes when a copied context recalculated access). 5. Changes setExternalRolesWithLock to replace instead of append, so that setUser on a copied context does not inherit stale pushed roles. Changelog category: Bug Fix (user-visible misbehavior in an official stable release) Changelog entry: Propagate a query's active roles (SET ROLE / role=) to remote nodes on parallel-replica and Distributed reads over a cluster secured with an interserver secret; previously the remote nodes fell back to the user's default roles, evaluating row policies inconsistently with the initiator.
abraithwaite
added a commit
to abraithwaite/ClickHouse
that referenced
this pull request
Oct 5, 2026
…es to remote read nodes Backport of the fix from ClickHouse#110867 and the follow-up regression fix from ClickHouse#121643 to the 26.3 LTS branch. When a query sets its active roles via SET ROLE / role=, those roles were not propagated to remote nodes on parallel-replica and Distributed reads over an interserver-secret cluster. Row policies on remote nodes fell back to the user's default roles instead of the active roles. This backport takes a simpler approach than the master PR: instead of adding a new ClientInfo wire field and protocol version (which would collide with master's version numbering and break mixed-version clusters), it reuses the existing external_roles transport mechanism: 1. Sender (RemoteQueryExecutor): when SET ROLE is active, sends the current (active) role names instead of all granted roles via the existing external_roles parameter. 2. Receiver (Session): when external_roles are received over an interserver connection, clears the user's default current_roles so that only the pushed external_roles are active. This ensures row policies are evaluated consistently with the initiator. 3. Context copy constructor: copies external_roles (the regression from PR ClickHouse#121643 that caused ACCESS_DENIED on remote nodes when a copied context recalculated access). 4. setExternalRolesWithLock: replaces instead of appending, so that setUser on a copied context does not inherit stale pushed roles. No protocol version change. No ClientInfo wire format change. No auth hash change. Rolling-upgrade safe: an old receiver without the 'clear defaults' logic will add the roles on top of defaults (same as the pre-fix behavior, not a regression). Changelog category: Bug Fix (user-visible misbehavior in an official stable release) Changelog entry: Propagate a query's active roles (SET ROLE / role=) to remote nodes on parallel-replica and Distributed reads over a cluster secured with an interserver secret; previously the remote nodes fell back to the user's default roles, evaluating row policies inconsistently with the initiator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of the relevant part of #110144 to 26.8.
Since #110867 (in 26.7 and 26.8), a remote node of a secret interserver query (Distributed, parallel replicas) enables the initiator's current roles only as external roles and clears the user's default roles. The
ContextDatacopy constructor did not copyexternal_roles, so any copied context on the remote node that recalculates access (a change ofreadonly,allow_ddlorallow_introspection_functions, for example a view with such a setting in itsSETTINGSclause) loses all roles. A user whose grants come from roles then getsACCESS_DENIEDon the remote node. This is what Cloud parallel-replicas queries (TPC-H benchmark) are hitting on 26.8.The change:
external_rolesin theContextDatacopy constructor (as on master after Support per-authentication-method GRANTS clause in CREATE USER and ALTER USER #110144);setExternalRolesWithLockreplace the list instead of appending, so thatsetUseron a copied context (e.g.EXECUTE AS) does not inherit the pushed roles.Reproduced on
26.8.1.2745: the new test fails withACCESS_DENIEDon the view queries without the fix.Related: #110867
Related: #110144
Related: https://github.com/ClickHouse/support-escalation/issues/8194
Related: https://github.com/ClickHouse/data-plane-application/issues/40347
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
ACCESS_DENIEDon remote nodes of Distributed and parallel-replicas queries over an interserver-secret cluster for users whose grants come from roles, when the remote node recalculates access rights in a copied query context (for example, when reading a view withSETTINGS). The regression appeared in 26.7.Version info
26.8.11.19