Skip to content

Fix system.dictionaries returning 0 rows with partial SHOW DICTIONARIES revoke - #106105

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-system-dictionaries-partial-revoke
May 29, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-system-dictionaries-partial-revoke

Conversation

@Avogar

@Avogar Avogar commented May 29, 2026 •

Copy link
Copy Markdown
Member

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):

Fix system.dictionaries returning 0 rows with partial SHOW DICTIONARIES revoke.

Version info

  • Merged into: 26.6.1.243
  • Backported to: 26.5.2.20, 26.4.4.25, 26.3.13.21, 25.8.25.18

…ARIES` revoke

`StorageSystemDictionaries::fillData` used `isGranted(SHOW_DICTIONARIES)`
without database/table arguments as an all-or-nothing gate: if the user
didn't have the privilege on every database and table, it returned empty
results immediately. Any partial revoke (e.g. on `system.billing` in
ClickHouse Cloud) caused the global check to fail, hiding all
dictionaries.

All other system tables (`StorageSystemTables`, `StorageSystemReplicas`,
etc.) use the global check as an optimization flag to skip per-entry
checks, not as an early return. Fix `StorageSystemDictionaries` and
`StorageSystemCompletions` to match this pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 29, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [4bc8f42]

Summary: ✅


AI Review

Summary

This PR fixes system.dictionaries and the dictionary branch of system.completions so a partial SHOW DICTIONARIES revoke no longer makes the global grant check suppress all dictionary rows. The current code preserves per-dictionary filtering when the global check is not sufficient, and the added stateless test covers both affected system tables.

Final Verdict

Status: ✅ Approve

@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 May 29, 2026
@@ -312,8 +312,7 @@ void fillDataWithPolicies(MutableColumns & res_columns, const ContextPtr & conte
void fillDataWithDictionaries(MutableColumns & res_columns, const ContextPtr & context)
{
const auto & access = context->getAccess();
if (!access->isGranted(AccessType::SHOW_DICTIONARIES))
return;
const bool need_to_check_access_for_dictionaries = !access->isGranted(AccessType::SHOW_DICTIONARIES);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this condition good enough. I mean, is access is not Granted checking a second condition may open potential breaches.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

access->isGranted(AccessType::SHOW_DICTIONARIES) will return false if there is a revoke on SHOW_DICTIONARIES on any of the database/table/dictionary. So we won't see all other dictionaries that we have access to. Instead, in this case we should check access to each dictionary independently in a loop. If access->isGranted(AccessType::SHOW_DICTIONARIES) returns true, it means we have access to all dictionaries.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was new to me too, apparently we handle this differently for AccessType::SHOW_TABLES. Here's an example: https://github.com/ClickHouse/ClickHouse/blob/master/src/Storages/System/StorageSystemTables.cpp#L518

Avogar and others added 2 commits May 29, 2026 13:09
@clickhouse-gh

clickhouse-gh Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.40% +0.00%
Functions 91.40% 91.40% +0.00%
Branches 76.90% 77.00% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 18/20 (90.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@alexey-milovidov
alexey-milovidov merged commit f9beb0c into master May 29, 2026
325 of 328 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-system-dictionaries-partial-revoke branch May 29, 2026 19:34
robot-ch-test-poll4 added a commit that referenced this pull request May 29, 2026
Cherry pick #106105 to 26.3: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
robot-clickhouse added a commit that referenced this pull request May 29, 2026
…with partial `SHOW DICTIONARIES` revoke
robot-ch-test-poll4 added a commit that referenced this pull request May 29, 2026
Cherry pick #106105 to 26.4: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
robot-clickhouse added a commit that referenced this pull request May 29, 2026
…with partial `SHOW DICTIONARIES` revoke
robot-ch-test-poll4 added a commit that referenced this pull request May 29, 2026
Cherry pick #106105 to 26.5: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
robot-clickhouse added a commit that referenced this pull request May 29, 2026
…with partial `SHOW DICTIONARIES` revoke
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 29, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label May 29, 2026
alexey-milovidov added a commit that referenced this pull request May 31, 2026
Backport #106105 to 26.5: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
alexey-milovidov added a commit that referenced this pull request May 31, 2026
Backport #106105 to 26.3: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
grantholly-clickhouse added a commit that referenced this pull request Jun 1, 2026
Backport #106105 to 26.4: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
@clickgapai

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

TL;DR

Fix system.dictionaries returning 0 rows with partial SHOW DICTIONARIES revoke

Reproduction

clickhouse-client -mn -q "CREATE DICTIONARY d (id UInt64, value String) PRIMARY KEY id SOURCE(CLICKHOUSE(TABLE 'numbers' DB 'system')) LIFETIME(MIN 0 MAX 300) LAYOUT(FLAT()); CREATE ROLE r; GRANT SHOW DICTIONARIES, SELECT ON *.* TO r; REVOKE SHOW DICTIONARIES, SELECT ON system.non_existing_table FROM r; CREATE USER u IDENTIFIED WITH no_password; GRANT r TO u;"; clickhouse-client --user u -q "SELECT name FROM system.dictionaries WHERE name='d'"  -- 0 rows on buggy build (partial SHOW DICTIONARIES revoke hides ALL dicts), 1 row when fixed

Bisect

  • Bisect skipped — bug predates available CI binaries. Maintainer-side bisect needed.

Affects

  • ✓ Fix is on master — this PR's change fixes the bug on master. Branches below still have the bug and need the backport.
  • Reproduces on: 26.5, 26.4, 26.3, 25.8
  • Does NOT reproduce on: master
  • Backport needed: 26.5, 26.4, 26.3, 25.8

Suggested next step

Manual triage of the Storages path is needed. The reproducer above should be a fast first check.

Component: Storages
Severity: P2

cc fix PR author: @Avogar
cc fix PR reviewer: @Ergus


ClickGap · Finding: phase_d_pr106105

robot-ch-test-poll2 added a commit that referenced this pull request Jun 4, 2026
Cherry pick #106105 to 25.8: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
robot-clickhouse added a commit that referenced this pull request Jun 4, 2026
…with partial `SHOW DICTIONARIES` revoke
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 4, 2026
@samay-sharma samay-sharma removed the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 5, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 5, 2026
Avogar added a commit that referenced this pull request Jun 9, 2026
Backport #106105 to 25.8: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ng 0 rows with partial `SHOW DICTIONARIES` revoke
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…6105

Backport ClickHouse#106105 to 26.4: Fix `system.dictionaries` returning 0 rows with partial `SHOW DICTIONARIES` revoke
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
OTHER: partial SHOW DICTIONARIES revoke -> wrong (0 rows).
Effect in the production build a394e92: its upstream test(s) 04268_system_dictionaries_partial_revoke fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv).
Upstream patch unchanged, with its test(s): 04268_system_dictionaries_partial_revoke.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 v25.12-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants