Repository navigation
Fix privilege check bypass in text index transform expressions - #120080
Conversation
|
Workflow [PR], commit [b4b9f76] Summary: ✅
AI ReviewSummaryThis PR authorizes text-index PR MetadataThe
Findings❌ Blockers
💡 Nits
Final VerdictStatus: ✅ 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. |
Cherry pick #120080 to 26.10: Fix privilege check bypass in text index transform expressions
…ransform expressions
Cherry pick #120080 to 26.9: Fix privilege check bypass in text index transform expressions
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]>
Cherry pick #120080 to 26.3: Fix privilege check bypass in text index transform expressions
Cherry pick #120080 to 26.8: Fix privilege check bypass in text index transform expressions
…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]>
Backport #120080 to 26.8: Fix privilege check bypass in text index transform expressions
Backport #120080 to 26.10: Fix privilege check bypass in text index transform expressions
Backport #120080 to 26.9: Fix privilege check bypass in text index transform expressions
Backport #120080 to 26.3: Fix privilege check bypass in text index transform expressions
…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]>
A text index
preprocessor/postprocessoris user-supplied, but was only ever resolved under theglobal full-access context, so the
checkAccessa grant-checked function performs in itscreatewas skipped. A user could put
demangleoraddressToLinein a transform without the grant orallow_introspection_functionsand read the result back through the index.checkIndexArgumentsAccessnow resolves the functions those arguments name against the declaringuser, from the two places an index is declared:
InterpreterCreateQueryand theADD_INDEXbranchof
AlterCommands. SQL UDFs are expanded first, sinceTreeRewriterinlines them beforeresolution. Only names are resolved; type checking stays with the index validator.
As with
DEFAULTandMATERIALIZEDexpressions, grants are checked when the index is defined, notwhen it is used, so an existing index stays usable and an unrelated
ALTERdoes not re-check them.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a privilege check bypass in text index
preprocessorandpostprocessorexpressions. They were resolved under an internal full-access context, so functions requiring a grant, such asdemangleandaddressToLine, could be used without it. These expressions are now authorized against the user who declares the index. Creating or adding a text index with apreprocessororpostprocessorusingON CLUSTERnow requiresdistributed_ddl_use_initial_user_and_roles = 1on every host anddistributed_ddl_entry_format_version >= 8; otherwise the query is rejected.Workflow [PR]
Sync PR [sync-upstream/pr/120080]
Version info
26.11.1.1771-master(included in26.11and later)