Skip to content

Fix privilege check bypass in text index transform expressions - #120080

Merged
Blargian merged 66 commits into
ClickHouse:masterfrom
Ergus:Fix_S_69071
Nov 9, 2026
Merged

Blargian merged 66 commits into
ClickHouse:masterfrom
Ergus:Fix_S_69071

Conversation

@Ergus

@Ergus Ergus commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

A text index preprocessor/postprocessor is user-supplied, but was only ever resolved under the
global full-access context, so the checkAccess a grant-checked function performs in its create
was skipped. A user could put demangle or addressToLine in a transform without the grant or
allow_introspection_functions and read the result back through the index.

checkIndexArgumentsAccess now resolves the functions those arguments name against the declaring
user, from the two places an index is declared: InterpreterCreateQuery and the ADD_INDEX branch
of AlterCommands. SQL UDFs are expanded first, since TreeRewriter inlines them before
resolution. Only names are resolved; type checking stays with the index validator.

As with DEFAULT and MATERIALIZED expressions, grants are checked when the index is defined, not
when it is used, so an existing index stays usable and an unrelated ALTER does not re-check them.

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fixed a privilege check bypass in text index preprocessor and postprocessor expressions. They were resolved under an internal full-access context, so functions requiring a grant, such as demangle and addressToLine, could be used without it. These expressions are now authorized against the user who declares the index. Creating or adding a text index with a preprocessor or postprocessor using ON CLUSTER now requires distributed_ddl_use_initial_user_and_roles = 1 on every host and distributed_ddl_entry_format_version >= 8; otherwise the query is rejected.


Workflow [PR]
Sync PR [sync-upstream/pr/120080]

Version info

  • Merged into: 26.11.1.1771-master (included in 26.11 and later)

@Ergus Ergus changed the title Fix s 69071 Fix privilege check bypass in text index transform expressions Sep 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b4b9f76]

Summary: ✅


AI Review

Summary

This PR authorizes text-index preprocessor and postprocessor expressions when declared, checks Replicated database submissions before dispatch, and requires worker execution as the initiating user for transforms in ON CLUSTER DDL. At b4b9f7675a5a, I found no new merge-blocking issue. The previously reported metadata-loading regression is fixed. All five focused transform tests pass in the current-head Fast test report.

PR Metadata

The Critical Bug Fix (crash, data loss, RBAC) category is appropriate, and the required entry describes the privilege fix specifically. It should also explain the new restriction on legitimate ON CLUSTER declarations. Append this sentence:

Creating or adding a text index with a preprocessor or postprocessor using ON CLUSTER now requires distributed_ddl_use_initial_user_and_roles = 1 on every host and distributed_ddl_entry_format_version >= 8; otherwise the query is rejected.

Findings

❌ Blockers

💡 Nits

  • [PR changelog entry] Include the ON CLUSTER migration sentence above so users with ordinary transforms such as lower can identify the required configuration change.
Final Verdict

Status: ✅ Approve for this PR's changes. The dismissed correctness issue is pre-existing and tracked separately. The changelog clarification is non-blocking. No new inline findings were posted.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... labels Sep 14, 2026
@rschu1ze rschu1ze self-assigned this Sep 28, 2026
Comment thread src/Storages/IndicesDescription.h Resolved
Comment thread src/Storages/IndicesDescription.h Resolved
Comment thread src/Storages/IndicesDescription.cpp Resolved
Comment thread src/Storages/IndicesDescription.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! and removed pr-bugfix Pull request with bugfix, not backported by default labels Sep 28, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 9, 2026
robot-ch-test-poll2 added a commit that referenced this pull request Nov 10, 2026
Cherry pick #120080 to 26.10: Fix privilege check bypass in text index transform expressions
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
robot-ch-test-poll added a commit that referenced this pull request Nov 10, 2026
Cherry pick #120080 to 26.9: Fix privilege check bypass in text index transform expressions
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
alexey-milovidov added a commit that referenced this pull request Nov 10, 2026
Resolve the conflicts by taking the 26.3 version of each file and re-applying
the change of #120080 on top,
adapted to the 26.3 code:

- `IndicesDescription.cpp`: 26.3 has no `expandTextIndexTransformAliases`
  (transforms do not expand `ALIAS` columns there), so only the new
  authorization helpers are added.
- `executeDDLQueryOnCluster`: 26.3 has no `additional_access_check` hook, so a
  minimal one is added, taking only `throw_if_unresolved` (whether the workers
  run the query without the initiator's user), and called before enqueueing.
- `InterpreterAlterQuery.cpp`: 26.3 applies all metadata commands of a
  statement at once (no command segments), so the `Replicated`-database
  preflight validates, prepares and applies all of them on a metadata copy.
- `InterpreterCreateQuery.cpp`: the `StorageAlias` target-grant check is
  dropped (26.3 has no `isTargetTableGranted`); `getInMemoryMetadataPtr`
  takes no context.

Tests: removed `02346_text_index_add_share_nested_offsets_disabled` (no
`share_nested_offsets` setting in 26.3) and
`02346_text_index_transform_alter_segments` (no command segments in 26.3; the
transitive rename it uses is refused there). 26.3 has no `postprocessor`
argument and does not expand aliases in transforms, so those cases are removed
from `02346_text_index_transform_access` and
`02346_text_index_transform_access_replicated_database`, and
`02346_text_index_transform_data_access` uses `preprocessor` instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-ch-test-poll3 added a commit that referenced this pull request Nov 10, 2026
Cherry pick #120080 to 26.3: Fix privilege check bypass in text index transform expressions
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
robot-ch-test-poll3 added a commit that referenced this pull request Nov 10, 2026
Cherry pick #120080 to 26.8: Fix privilege check bypass in text index transform expressions
robot-clickhouse added a commit that referenced this pull request Nov 10, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 10, 2026
alexey-milovidov added a commit that referenced this pull request Nov 10, 2026
…ackport

The cherry-pick of #120080 to 26.9 calls `distributedDDLWorkersUseInitiatorUser`
in `InterpreterCreateQuery` and `InterpreterAlterQuery`, but the function does
not exist on 26.9 (master decides this via the `throw_if_unresolved` argument of
`additional_access_check`, which 26.9 lacks), so every build failed.

Define it next to `executeDDLQueryOnCluster`: the hosts run an `ON CLUSTER`
query as the initiating user only when the server setting
`distributed_ddl_use_initial_user_and_roles` is on and
`distributed_ddl_entry_format_version` is at least `INITIATOR_USER_VERSION`,
the same condition master uses.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130481&sha=b1b5d6ba25f997a4ac9f926d4a8f1c677255ca3a&name_0=BackportPR&name_1=Build%20%28amd_release%29
PR: #130481

Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #120080 to 26.8: Fix privilege check bypass in text index transform expressions
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #120080 to 26.10: Fix privilege check bypass in text index transform expressions
clickhouse-gh Bot added a commit that referenced this pull request Nov 10, 2026
Backport #120080 to 26.9: Fix privilege check bypass in text index transform expressions
alexey-milovidov added a commit that referenced this pull request Nov 10, 2026
Backport #120080 to 26.3: Fix privilege check bypass in text index transform expressions
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…ackport

The cherry-pick of #120080 to 26.9 calls `distributedDDLWorkersUseInitiatorUser`
in `InterpreterCreateQuery` and `InterpreterAlterQuery`, but the function does
not exist on 26.9 (master decides this via the `throw_if_unresolved` argument of
`additional_access_check`, which 26.9 lacks), so every build failed.

Define it next to `executeDDLQueryOnCluster`: the hosts run an `ON CLUSTER`
query as the initiating user only when the server setting
`distributed_ddl_use_initial_user_and_roles` is on and
`distributed_ddl_entry_format_version` is at least `INITIATOR_USER_VERSION`,
the same condition master uses.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130481&sha=b1b5d6ba25f997a4ac9f926d4a8f1c677255ca3a&name_0=BackportPR&name_1=Build%20%28amd_release%29
PR: #130481

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-text-index Full-text search: inverted/text index in MergeTree (tokenizers, posting lists, GIN-style index bu... pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants