Skip to content

Cherry pick #120080 to 26.3: Fix privilege check bypass in text index transform expressions - #130392

Merged
robot-ch-test-poll3 merged 68 commits into
backport/26.3/120080from
cherrypick/26.3/120080
Nov 10, 2026
Merged

robot-ch-test-poll3 merged 68 commits into
backport/26.3/120080from
cherrypick/26.3/120080

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #120080

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

alexey-milovidov and others added 19 commits November 5, 2026 02:35
`countmin` sketches need the `datasketches` library, which the Fast test
build lacks, so the test failed there with `Unknown statistic type 'CountMinSketch'`.
`minmax` is always available and exercises the same implicit-statistics path.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120080&sha=882c0069c412492821ef30f9d69cff26d4ccc683&name_0=PR&name_1=Fast%20test
#120080

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since the hosts of an `ON CLUSTER` query do not run it as the initiating user
unless `distributed_ddl_use_initial_user_and_roles` is enabled, a text index
transform is now refused with `INCORRECT_QUERY` before the per-function
privilege check. Update the expectations in
`02346_text_index_transform_access_replicated_database` accordingly, and drop the
missing-table case, whose check was removed together with the binding.

Cases 3 and 4 of `02346_text_index_transform_alter_segments` tested how an
`ON CLUSTER` transform is bound for the hosts, which is no longer reachable;
the refusal is covered by `02346_text_index_transform_on_cluster`. The test no
longer uses ZooKeeper, so its tags are removed.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120080&sha=dfd5282fd456ecfbd0a600e8160317804ee28074&name_0=PR&name_1=Fast%20test
PR: #120080

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eclared

The check refusing subqueries, table references, table/set `IN` operands and
non-deterministic functions in a text index `preprocessor` / `postprocessor`
ran inside `buildActionsDAGFromAST`, i.e. on every construction of the index:
on server start, on `ATTACH` of stored metadata, and on the revalidation of
existing indices during unrelated `ALTER`s. Metadata written by older releases
with such transforms would then fail to load.

Move it into `checkTextIndexPreAndPostProcessorPermissions`, which runs only
where a user declares an index (`CREATE`, full-definition `ATTACH`, `AS src`,
and indices added by `ALTER ... ADD INDEX`), alongside the function permission
checks it complements.

Address review: #120080 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fix privilege check bypass in text index transform expressions
@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-critical-bugfix labels Nov 9, 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
robot-ch-test-poll3 merged commit a0cba0a into backport/26.3/120080 Nov 10, 2026
2 checks passed
@robot-ch-test-poll3
robot-ch-test-poll3 deleted the cherrypick/26.3/120080 branch November 10, 2026 11:47
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-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants