Skip to content

Add missing SELECT grant check in mergeTreeProjection table function#95480

Merged
alexey-milovidov merged 1 commit intomasterfrom
fix-mergetree-projection-grants
Jan 29, 2026
Merged

Add missing SELECT grant check in mergeTreeProjection table function#95480
alexey-milovidov merged 1 commit intomasterfrom
fix-mergetree-projection-grants

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

The mergeTreeProjection table function was missing an access check, allowing users without SELECT permission on a table to read data from its projections. This fix adds the same access check that mergeTreeIndex and mergeTreeAnalyzeIndexes already have.

Also adds tests for grant checking on all MergeTree introspection functions: mergeTreeAnalyzeIndexes, mergeTreeAnalyzeIndexesUUID, mergeTreeIndex, and mergeTreeProjection.

Changelog category (leave one):

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

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

The mergeTreeProjection table function was missing an access check, allowing users without SELECT permission on a table (but with permissions for table functions) to read data from its projections. This fix adds the same access check that mergeTreeIndex and mergeTreeAnalyzeIndexes already have.

The `mergeTreeProjection` table function was missing an access check,
allowing users without SELECT permission on a table to read data from
its projections. This fix adds the same access check that
`mergeTreeIndex` and `mergeTreeAnalyzeIndexes` already have.

Also adds tests for grant checking on all MergeTree introspection
functions: `mergeTreeAnalyzeIndexes`, `mergeTreeAnalyzeIndexesUUID`,
`mergeTreeIndex`, and `mergeTreeProjection`.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@alexey-milovidov alexey-milovidov added the blocker This issue / pr blocks a new release label Jan 29, 2026
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Jan 29, 2026

Workflow [PR], commit [fa3cf80]

Summary:

job_name test_name status info comment
AST fuzzer (amd_ubsan) failure
Logical error: Block structure mismatch in A stream: different number of columns: (STID: 0993-38e6) FAIL cidb, issue

@clickhouse-gh clickhouse-gh bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! labels Jan 29, 2026
@pufit pufit self-assigned this Jan 29, 2026
@pufit
Copy link
Copy Markdown
Member

pufit commented Jan 29, 2026

Looks good. Clean one-liner fix following the same pattern as mergeTreeIndex and mergeTreeAnalyzeIndexes. Tests are thorough — appreciate the coverage for all introspection functions, not just the one being fixed.

The CI failure (AST fuzzer) appears to be the known issue #83614, unrelated to this change.


This review was drafted by an AI assistant (Claude) on behalf of @pufit.

Copy link
Copy Markdown
Member

@pufit pufit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead Internet Theory
Looks good to me, but I would remove some of the AI comments - they are good to get initial thoughts when you are reviewing AI suggestions, but afterwards they might become overwhelming for other contributors. Some obvious ones, like # Grant SELECT permission above grant queries, are unnecessary. But this is my opinion only.

@alexey-milovidov
Copy link
Copy Markdown
Member Author

These comments are in tests, I see it as okay.

@alexey-milovidov alexey-milovidov merged commit 153305b into master Jan 29, 2026
131 of 134 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-mergetree-projection-grants branch January 29, 2026 05:39
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jan 29, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jan 29, 2026
robot-clickhouse added a commit that referenced this pull request Jan 29, 2026
robot-clickhouse added a commit that referenced this pull request Jan 29, 2026
robot-clickhouse added a commit that referenced this pull request Jan 29, 2026
robot-clickhouse added a commit that referenced this pull request Jan 29, 2026
robot-clickhouse added a commit that referenced this pull request Jan 29, 2026
clickhouse-gh bot added a commit that referenced this pull request Jan 29, 2026
Backport #95480 to 26.1: Add missing SELECT grant check in `mergeTreeProjection` table function
@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 Feb 3, 2026
clickhouse-gh bot added a commit that referenced this pull request Feb 19, 2026
Backport #95480 to 25.11: Add missing SELECT grant check in `mergeTreeProjection` table function
pufit added a commit that referenced this pull request Feb 23, 2026
Backport #95480 to 25.12: Add missing SELECT grant check in `mergeTreeProjection` table function
pufit added a commit that referenced this pull request Feb 23, 2026
Backport #95480 to 25.8: Add missing SELECT grant check in `mergeTreeProjection` table function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release 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.

7 participants