Repository navigation
Backport #117798 to 26.3: Send the definer identity to remote shards from SQL SECURITY DEFINER views without an invoker - #128668
Merged
Merged
Conversation
…from SQL SECURITY DEFINER views without an invoker
Contributor
|
Workflow [BackportPR], commit [5eb07b5] Summary: ✅ |
On 26.3, with `table_engines_require_grant = false`, `TABLE ENGINE` on `Distributed`, `Kafka` and `RabbitMQ` is implicitly revoked unless the user also has `READ` and `WRITE` on the `REMOTE`, `KAFKA` and `RABBITMQ` sources. So `CREATE TABLE ... ENGINE = Distributed` failed with `ACCESS_DENIED` in the test setup. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128668&sha=latest&name_0=BackportPR PR: #128668 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The loop in `DistributedAsyncInsertBatch::recoverBatch` read the header of `files.back()` on each iteration, so only the last file was validated and the mixed-identity check added by #117798 compared the last file with itself and never fired. On master this was fixed by #105281, which was not backported to 26.3. Related: #105281 PR: #128668 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…flush context On 26.3 `async_insert` is enabled by default, and the flush context of `AsynchronousInsertQueue` is built from the global context with only `Context::setUser`, so its `ClientInfo` user names are empty. A direct `INSERT` into a `Distributed` table over a cluster with an interserver `<secret>` was therefore flushed to the shard with an empty `initial_user`, which the shard executes in interserver mode with full access. This is the same hole that #117798 closes for the definer of `SQL SECURITY DEFINER` views, and `test_streaming_engines_definer_interserver_secret::test_rabbitmq[tenant]` caught it in its control case: the tenant's direct insert was accepted on the shard. Bring the fix from #107541 (merged to master in edb9295): capture `current_user`, `initial_user` and `authenticated_user` in the async insert queue key at push time and restore them on the flush context. The only conflict is in `InsertQuery::toTupleCmp`, where 26.3 already uses `query_str_with_secrets` instead of `query_str`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128668&sha=0dc411340520ff9f52dfdb04638aa63196712372&name_0=BackportPR&name_1=Integration%20tests%20%28amd_tsan%2C%203%2F6%29 PR: #128668 Related: #107541 Co-Authored-By: Claude Opus 5.5 <[email protected]>
On 26.3, with `table_engines_require_grant = false`, `TABLE ENGINE ON Distributed` is implicitly revoked unless the user also has `READ` and `WRITE` on `REMOTE`, so `CREATE TABLE ... ENGINE = Distributed` by the tenant failed with `ACCESS_DENIED` in the test setup. Same as the fix for test_streaming_engines_definer_interserver_secret. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128668&sha=0dc411340520ff9f52dfdb04638aa63196712372&name_0=BackportPR&name_1=Integration%20tests%20%28amd_asan%2C%20db%20disk%2C%20old%20analyzer%2C%203%2F8%29 PR: #128668 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
|
🕵 Fixed the two integration test failures from the last run:
The affected files pass a syntax check against 26.3 headers. I couldn't run the tests locally because no 26.3 binary is available here, so the next CI run will be the real check. I also merged the latest A reviewer should confirm that bundling #107541 into this backport is acceptable. The alternative is a separate 26.3 backport of #107541, which this PR's tests would then depend on. |
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 2026
On 26.3, with `table_engines_require_grant = false`, `TABLE ENGINE` on `Distributed`, `Kafka` and `RabbitMQ` is implicitly revoked unless the user also has `READ` and `WRITE` on the `REMOTE`, `KAFKA` and `RABBITMQ` sources. So `CREATE TABLE ... ENGINE = Distributed` failed with `ACCESS_DENIED` in the test setup. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128668&sha=latest&name_0=BackportPR PR: #128668 Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 2026
The loop in `DistributedAsyncInsertBatch::recoverBatch` read the header of `files.back()` on each iteration, so only the last file was validated and the mixed-identity check added by #117798 compared the last file with itself and never fired. On master this was fixed by #105281, which was not backported to 26.3. Related: #105281 PR: #128668 Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 2026
…flush context On 26.3 `async_insert` is enabled by default, and the flush context of `AsynchronousInsertQueue` is built from the global context with only `Context::setUser`, so its `ClientInfo` user names are empty. A direct `INSERT` into a `Distributed` table over a cluster with an interserver `<secret>` was therefore flushed to the shard with an empty `initial_user`, which the shard executes in interserver mode with full access. This is the same hole that #117798 closes for the definer of `SQL SECURITY DEFINER` views, and `test_streaming_engines_definer_interserver_secret::test_rabbitmq[tenant]` caught it in its control case: the tenant's direct insert was accepted on the shard. Bring the fix from #107541 (merged to master in edb9295): capture `current_user`, `initial_user` and `authenticated_user` in the async insert queue key at push time and restore them on the flush context. The only conflict is in `InsertQuery::toTupleCmp`, where 26.3 already uses `query_str_with_secrets` instead of `query_str`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128668&sha=0dc411340520ff9f52dfdb04638aa63196712372&name_0=BackportPR&name_1=Integration%20tests%20%28amd_tsan%2C%203%2F6%29 PR: #128668 Related: #107541 Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus
pushed a commit
that referenced
this pull request
Nov 13, 2026
On 26.3, with `table_engines_require_grant = false`, `TABLE ENGINE ON Distributed` is implicitly revoked unless the user also has `READ` and `WRITE` on `REMOTE`, so `CREATE TABLE ... ENGINE = Distributed` by the tenant failed with `ACCESS_DENIED` in the test setup. Same as the fix for test_streaming_engines_definer_interserver_secret. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=128668&sha=0dc411340520ff9f52dfdb04638aa63196712372&name_0=BackportPR&name_1=Integration%20tests%20%28amd_asan%2C%20db%20disk%2C%20old%20analyzer%2C%203%2F8%29 PR: #128668 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Original pull-request #117798
Cherry-pick pull-request #128497
This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.
The PR source
The PR is created in the CI job