Skip to content

Check access rights before loading a dictionary or reading its definition - #122678

Merged
Manerone merged 29 commits into
ClickHouse:masterfrom
Manerone:dictionary-access-before-load
Nov 18, 2026
Merged

Manerone merged 29 commits into
ClickHouse:masterfrom
Manerone:dictionary-access-before-load

Conversation

@Manerone

@Manerone Manerone commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

The dictionary table function, the dictGet-family functions, naiveBayesClassifier* and Dictionary tables loaded the dictionary first and checked dictGet/SELECT access afterwards. A query without the required grants failed with ACCESS_DENIED, but the dictionary had already been loaded: its source was queried and its status in system.dictionaries changed from NOT_LOADED to LOADED. CREATE TABLE ... ENGINE = Dictionary(d) and, with the old analyzer, the injective dictGet optimization of GROUP BY (optimize_injective_functions_in_group_by) loaded the dictionary without any access check. In addition, inferring the result type of these functions read the dictionary definition before any check, so a user without dictGet could learn attribute names, types and the layout from the result type or from error messages.

This PR adds ExternalDictionariesLoader::resolveDictionary, which resolves a dictionary name once, without loading the dictionary. It returns the key the loader stores the dictionary under (the UUID for a dictionary in an Atomic database) and the dictionary ID, taken from the loaded dictionary if there is one, otherwise from the dictionary configuration, so the access key is the same as before. Access is checked on that ID, and the dictionary or its definition is then read by the same key, so a dictionary renamed in between cannot be read instead of the one that passed the check. For a dictionary that does not exist, it returns the ID the dictionary would have in the current database, so a user without access gets ACCESS_DENIED and cannot tell a missing dictionary from an existing DDL dictionary. An XML dictionary is checked as <no_database>.d, so the denial message for it still differs from the one for a missing name. The access check now runs before the dictionary is loaded or its definition is read:

  • dictionary table function, Dictionary tables (including joins against them) and CREATE TABLE ... ENGINE = Dictionary: dictGet or SELECT on the dictionary is required, the same rule as for reading a Dictionary table before (StorageDictionary::checkDictionaryAccess). For CREATE TABLE ... ENGINE = Dictionary, the check runs before the dictionary is loaded to validate the columns.
  • dictGet-family functions, dictGetKeys and naiveBayesClassifier*: dictGet is required, also for inferring the result type.
  • Old analyzer, injective dictGet in GROUP BY: the optimization is skipped when dictGet is not granted, and the query fails at the regular check during execution.

Behavior changes:

d is a dictionary and w is a table with ENGINE = Dictionary(d). "Access" means dictGet for the dictGet-family functions, dictGetKeys and naiveBayesClassifier*, and dictGet or SELECT on d for the dictionary table function and Dictionary tables.

User Query Before After
No access to d SELECT * FROM dictionary('d'), dictGet('d', ...), dictHas, naiveBayesClassifier('d', ...), reading or joining w, GROUP BY dictGet('d', ...) with enable_analyzer = 0 d was loaded, then ACCESS_DENIED ACCESS_DENIED, d is not loaded
No access to d DESCRIBE TABLE dictionary('d') d was loaded and its structure shown ACCESS_DENIED
No access to d CREATE TABLE ... ENGINE = Dictionary(d), CREATE VIEW ... AS SELECT ... JOIN w succeeded and loaded d ACCESS_DENIED
No access to d Queries and DDL that only need the result type: DESCRIBE/EXPLAIN of a query with dictGet('d', ...), queries where no rows reach dictGet, CREATE VIEW with dictGet('d', ...), a column with DEFAULT dictGet('d', ...) succeeded; errors showed attribute names, types or the layout of d ACCESS_DENIED
No access to d Any of the above when d does not exist Dictionary ... not found, which told a missing dictionary from an existing one ACCESS_DENIED, like for an existing DDL dictionary
Only SELECT on d Direct join against w with enable_analyzer = 0 d was loaded, then ACCESS_DENIED (required dictGet) works, like with the analyzer
Any CREATE TABLE ... ENGINE = Dictionary(d) with an unqualified name and a non-default current database Dictionary (d) not found d is resolved in the current database, like when the table is read

A table created AS a table function with an explicit column list, e.g. AS view(SELECT dictGet('d', ...)), creates its storage on first use with the global context, so the query of view is analyzed with full access. A follow-up PR handles that case.

Users with access see no difference. If a query or DDL now fails with ACCESS_DENIED for a dictionary, grant dictGet on it (or SELECT for the dictionary table function and Dictionary tables) to the user running it.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Check access rights before loading a dictionary or reading its definition in the dictionary table function, dictGet-family functions, naiveBayesClassifier, Dictionary tables and CREATE TABLE ... ENGINE = Dictionary. Queries without the required grants no longer trigger the dictionary load, and queries or DDL that reference a dictionary now require access to it even when they do not read it, e.g. DESCRIBE, CREATE VIEW or a DEFAULT dictGet(...) column.


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

Version info

  • Merged into: 26.11.1.2728-master (included in 26.11 and later)
  • Backported to: 26.10.8.7, 26.9.33.16, 26.8.42.17, 26.3.67.31

The `dictionary` table function, `dictGet`-family functions and
`naiveBayesClassifier` loaded the dictionary first and checked `dictGet`/`SELECT`
access afterwards, so a query without the required grants still triggered the
load. The injective `dictGet` optimization of `GROUP BY` in the old analyzer
loaded the dictionary without any check.

Add `ExternalDictionariesLoader::getDictionaryID`, which returns the dictionary ID
from the loaded dictionary or from its configuration without loading it, and use
it to check access before the load. The injective `GROUP BY` optimization is
skipped when `dictGet` is not granted; the query then fails at the regular check.
`DESCRIBE TABLE dictionary(...)` now also requires `dictGet` or `SELECT`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [09b6e5e]

Summary: ✅


AI Review

Summary

Reviewed PR #122678 at 09b6e5ea54a18f4317e256368c193b362567debd. The change checks dictionary access before loading or inspecting a definition, carries the resolved identity into the subsequent lookup, and covers joins and dictionary-engine DDL. No new inline findings. The previously reported concerns below remain in the current code; the author explicitly deferred them, so they are retained here without reopening their discussions.

Findings

❌ Blockers

  • src/Interpreters/InterpreterCreateQuery.cpp:4445, src/TableFunctions/TableFunctionView.cpp:63: Persisted view table functions still analyze dictionary expressions with full access. [dismissed by author -- https://github.com/Check access rights before loading a dictionary or reading its definition #122678#discussion_r4494581710] The view fix was reverted in 87f38153105. With table-creation/read grants but no access to private.d, a user can create w (value String) AS view(SELECT dictGet('private.d', 'value', toUInt64(1)) AS value). The first read resolves the proxy through the global context, reads the protected definition and can load the dictionary before the reader's eventual ACCESS_DENIED. This remains real because ITableFunction::execute captures the global context and TableFunctionView::executeImpl still analyzes the query with it. Fix the deferred context boundary, preserving the previous nullable-result conversion, or link the promised follow-up PR/issue.

  • src/Interpreters/InterpreterCreateQuery.cpp:4403: An unqualified dictionary can resolve to an unauthorized target on another cluster server. [dismissed by author -- https://github.com/Check access rights before loading a dictionary or reading its definition #122678#discussion_r4481374346] The preflight uses the initiator's server default database, but queues an unqualified Dictionary('d'). With server defaults public_db and private_db, a grant on public_db.d passes the preflight while a full-access worker can load private_db.d. AS dictionary('d') has the same dependency. This remains real because each worker copies its own context; the code does not require identical server defaults. Bind creation-time resolution across workers or authorize the worker's target as the submitting user; otherwise track this supported configuration explicitly. Evidence is a source trace, not a live two-server reproduction.

  • src/Interpreters/InterpreterCreateQuery.cpp:4175: Legacy distributed DDL can re-evaluate persisted dictionary references without the submitting user's permissions. [dismissed by author -- https://github.com/Check access rights before loading a dictionary or reading its definition #122678#discussion_r4584807700] With distributed_ddl_entry_format_version 1 or 2, a CREATE VIEW ... ON CLUSTER query containing dictGet(if(currentUser() = 'limited', 'app.allowed', 'private.d'), ...) can select private.d during worker analysis and load it without the user's grant. This remains real because the preflight checks engines, while legacy replay analyzes the stored query under the worker's identity. The author reproduced the source load for these formats; the concern does not apply to the normalized default-format example. Require replay authorization as the initiating user, reject the unsupported combination, or link a tracking issue for the legacy-format gap.

  • src/Interpreters/ExternalDictionariesLoader.cpp:257: Denied XML dictionary lookups still disclose existence. [dismissed by author -- https://github.com/Check access rights before loading a dictionary or reading its definition #122678#discussion_r4123261484] A missing unqualified d is checked as app.d, while an existing XML dictionary is checked as <no_database>.d. Denial messages disclose the different target; with only dictGet ON app.*, even the error codes differ. This remains real because returning ACCESS_DENIED does not conceal the authorization target. The description now acknowledges the limitation. Track a denial/namespace policy that avoids exposing unauthorized resolution.

⚠️ Majors

  • src/Interpreters/InterpreterCreateQuery.cpp:4445, src/TableFunctions/TableFunctionLoop.cpp:175: Nested persisted dictionary arguments can still resolve using the wrong user. [dismissed by author -- https://github.com/Check access rights before loading a dictionary or reading its definition #122678#discussion_r4565150784] With explicit columns, AS loop(dictionary(if(currentUser() = 'limited', 'app.allowed', 'private.d'))) evaluates the nested name during deferred global-context construction. It can consequently read the wrong dictionary or produce an unexpected ACCESS_DENIED. This remains real because only a top-level dictionary call is frozen in the user's context. The reader's dictionary check prevents an unauthorized load in the discussed loop case; address the incorrect resolution in the general persisted-table-function follow-up.
Missing context / blind spots
  • ⚠️ The current head's Praktika workflow was still running, with the release build and targeted stateless tests pending. No local build or test run was performed; completed head-specific results would close this validation gap.
Final Verdict

Status: ⚠️ Request changes. Link concrete tracking issues or follow-up PRs for the accepted deferrals above, especially the reverted view authorization fix. The current description promises a follow-up but does not link one. No additional inline discussion is needed for these already-dismissed findings.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 28, 2026
@Manerone Manerone added the can be tested Allows running workflows for external contributors label Sep 28, 2026

@diegomestre2 diegomestre2 left a comment

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.

LGTM. No remarks.

@clickhouse-gh clickhouse-gh Bot added the comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. label Sep 28, 2026
A user with `SELECT` on a `Dictionary` table but without `dictGet` or `SELECT`
on the underlying dictionary triggered the dictionary load before getting
`ACCESS_DENIED`. Check access on the dictionary ID obtained without loading.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Storages/StorageDictionary.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 09b6e5ea5 with master 4553bee2f (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

20 object files changed (-23.23 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Interpreters/JoinedTables.cpp.o 193.63 KiB 173.74 KiB -19.89 KiB (-10.27%)

711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

112 translation units recompiled, 1334 s compile time in total, 112 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +93.1 s (+7%) in total before that adjustment.

Job report

@diegomestre2

Copy link
Copy Markdown
Contributor

LGTM.

Manerone and others added 2 commits September 30, 2026 14:10
…nctions

`dictGet`-family functions and `dictGetKeys` read the dictionary structure, and
`naiveBayesClassifier*` read the layout, to infer the result type before any
access check. A user without the `dictGet` grant could learn attribute names,
types and the layout from the result type or the error messages. Check `dictGet`
access before reading the definition.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`CREATE TABLE ... ENGINE = Dictionary(d)` loaded the dictionary to validate the
columns, without checking access to the dictionary. Validate the columns against
the dictionary definition without loading it, and require `dictGet` or `SELECT`
on the dictionary, the same rule as for reading it. The rule is now in
`StorageDictionary::checkDictionaryAccess`, shared by `StorageDictionary::read`,
the `Dictionary` engine and the `dictionary` table function.

Test joins against a `Dictionary` table as a user without access to the
dictionary, too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Manerone Manerone changed the title Check access rights before loading a dictionary Check access rights before loading a dictionary or reading its definition Sep 30, 2026
Comment thread src/Storages/StorageDictionary.cpp Resolved
`CREATE VIEW ... AS SELECT ... JOIN` against a `Dictionary` table only analyzes
the query, so `StorageDictionary::read` is not called, but the direct join
planning of both analyzers still loaded the dictionary without checking access
to it. `StorageDictionary::getDictionary` now takes the query context and checks
access before loading; the unchecked overload is removed. Remove the unused
`trySetStorageInTableJoin`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Interpreters/JoinedTables.cpp Resolved
Manerone and others added 4 commits September 30, 2026 17:17
The direct join planning of the old analyzer loaded the dictionary a second time
through `FunctionDictHelper`, which requires `dictGet`, so a user with only
`SELECT` on the dictionary could not join against a `Dictionary` table, unlike
with the analyzer and when reading the table. Reuse the dictionary returned by
`StorageDictionary::getDictionary`, which accepts `dictGet` or `SELECT`.

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

At `CREATE` time the `Dictionary` engine resolved the dictionary name with the
global context, while reading the table resolves it with the query context, so
an unqualified name could point to different dictionaries, and `CREATE TABLE ...
ENGINE = Dictionary(d)` with a non-default current database failed with
`Dictionary not found`. Use the query context for the access check and the
validation of the columns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…fter the access check

The access check now runs before the dictionary is loaded, so loading it to
validate the columns is fine for a user who may read it. Keep the previous
behavior for such users, including failing early when the dictionary cannot be
loaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Dear @diegomestre2, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

Manerone and others added 3 commits November 4, 2026 09:30
`dictGet*`, `dictGetKeys`, `naiveBayesClassifier*`, the `dictionary` table function and `ENGINE = Dictionary` check access with the ID returned by `ExternalDictionariesLoader::getDictionaryID`, which threw `Dictionary ... not found` for a missing dictionary before the check ran. A user without access could therefore tell a missing dictionary from an existing one. For a missing dictionary, `getDictionaryID` now returns the ID the dictionary would have, so such a user gets `ACCESS_DENIED`, and a user with access still gets the not-found error from the lookup that follows.

ClickHouse#122678 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Nov 18, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 18, 2026
Manerone added a commit that referenced this pull request Nov 19, 2026
Resolve the conflicts of the cherry-pick of #122678 to 26.10.

The conflicts come from master-only changes next to the PR's hunks: the `modernize-use-nodiscard` sweep (disabled on 26.10), `getSignatureString` in the naive Bayes functions, and the `SubcolumnCodecs.h` include. They take the 26.10 side; the PR's own changes are kept, including the removal of `assertDictionaryStructureExists`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-ch-test-poll added a commit that referenced this pull request Nov 19, 2026
Cherry pick #122678 to 26.10: Check access rights before loading a dictionary or reading its definition
robot-clickhouse added a commit that referenced this pull request Nov 19, 2026
Manerone added a commit that referenced this pull request Nov 19, 2026
Resolve the conflicts of the cherry-pick of #122678 to 26.9.

- 26.9 has no `predictXGBoost`, so the changes to `FunctionPredictXGBoost.cpp` and the test `05620_dictionary_access_check_predict_xgboost` are dropped.
- 26.9 has neither `ExternalDictionariesLoader::ResolvedDictionaryName` nor `addDistributedPlanLocalObject`: the struct is added for `resolveDictionaryNameUnchecked`, which qualifies the name the same way as `resolveDictionaryNameFromDatabaseCatalog`, the 26.9 string resolvers stay as they are, and `resolveDictionary` records nothing.
- The analyzer is mandatory on 26.9, so the `enable_analyzer = 0` cases are removed from `05291_dictionary_access_check_before_load`.
- Other conflicts come from master-only changes (the `modernize-use-nodiscard` sweep, `getSignatureString` in the naive Bayes functions, the `SubcolumnCodecs.h` include) and take the 26.9 side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
robot-clickhouse-ci-2 added a commit that referenced this pull request Nov 19, 2026
Cherry pick #122678 to 26.9: Check access rights before loading a dictionary or reading its definition
robot-clickhouse added a commit that referenced this pull request Nov 19, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 19, 2026
Backport #122678 to 26.10: Check access rights before loading a dictionary or reading its definition
clickhouse-gh Bot added a commit that referenced this pull request Nov 19, 2026
Backport #122678 to 26.9: Check access rights before loading a dictionary or reading its definition
Manerone added a commit that referenced this pull request Nov 20, 2026
Resolve the conflicts of the cherry-pick of #122678 to 26.3.

- 26.3 has no `predictXGBoost`, so the changes to `FunctionPredictXGBoost.cpp` and the test `05620_dictionary_access_check_predict_xgboost` are dropped.
- `naiveBayesClassifier` on 26.3 reads its models from the server configuration, not from a dictionary, so `FunctionNaiveBayesClassifier.cpp` keeps the 26.3 version, the naive Bayes cases are removed from `05291`, `05292` and `05497`, and the PR's `getDictionaryLayoutType` additions are dropped (26.3 has no `getDictionaryLayoutType`).
- 26.3 has neither `ExternalDictionariesLoader::ResolvedDictionaryName` nor `addDistributedPlanLocalObject`, and resolves names only with the string form of `resolveDictionaryNameFromDatabaseCatalog`: the struct is added for `resolveDictionaryNameUnchecked`, which takes the key from that function and qualifies the name the same way, the check that skips databases without their own tables (`isExternal`) moves into that function, and `resolveDictionary` records nothing.
- `trySetStorageInTableJoin` is still used on 26.3 (`PlannerJoinTree.cpp`), so it is kept; it now takes the query context and gets the dictionary through the access-checked `StorageDictionary::getDictionary`.
- 26.3 has no `SYSTEM UNLOAD DICTIONARY`, so `05291` and `05498` reset the dictionary with `DETACH DICTIONARY` and `ATTACH DICTIONARY`, with `check_table_dependencies = 0` because the `Dictionary` tables depend on it and a `Replicated` database detaches permanently.
- Other conflicts come from master-only changes (the `modernize-use-nodiscard` sweep, include changes) and take the 26.3 side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Manerone added a commit that referenced this pull request Nov 20, 2026
Resolve the conflicts of the cherry-pick of #122678 to 26.8.

- 26.8 has no `predictXGBoost`, so the changes to `FunctionPredictXGBoost.cpp` and the test `05620_dictionary_access_check_predict_xgboost` are dropped.
- 26.8 has neither `ExternalDictionariesLoader::ResolvedDictionaryName` nor `addDistributedPlanLocalObject`, and resolves names only with the string form of `resolveDictionaryNameFromDatabaseCatalog`: the struct is added for `resolveDictionaryNameUnchecked`, which takes the key from that function and qualifies the name the same way, the check that skips databases without their own tables (`isExternal`) moves into that function, and `resolveDictionary` records nothing.
- Other conflicts come from master-only changes (the `modernize-use-nodiscard` sweep, `getSignatureString` in the naive Bayes functions, the `SubcolumnCodecs.h` include) and take the 26.8 side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Manerone added a commit that referenced this pull request Nov 20, 2026
Cherry pick #122678 to 26.8: Check access rights before loading a dictionary or reading its definition
Manerone added a commit that referenced this pull request Nov 20, 2026
Cherry pick #122678 to 26.3: Check access rights before loading a dictionary or reading its definition
robot-clickhouse added a commit that referenced this pull request Nov 20, 2026
robot-clickhouse added a commit that referenced this pull request Nov 20, 2026
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Nov 20, 2026
clickhouse-gh Bot added a commit that referenced this pull request Nov 20, 2026
Backport #122678 to 26.8: Check access rights before loading a dictionary or reading its definition
Manerone added a commit that referenced this pull request Nov 20, 2026
Backport #122678 to 26.3: Check access rights before loading a dictionary or reading its definition
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 24, 2026
Since ClickHouse#122678, analyzing `dictGet` checks the `dictGet` grant, and an ALTER
re-validates the default expressions of every column of the table as the
altering user. Once `c_dict ALIAS dictGet(d, 'v', id)` exists, every later
ALTER by a user without `dictGet ON d` therefore fails with ACCESS_DENIED,
whatever column it adds. Adding `c_dict` last keeps each arm about its own
expression.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
qiuyanjun888 pushed a commit to qiuyanjun888/ClickHouse that referenced this pull request Nov 24, 2026
`timeSeriesSamples`, `timeSeriesTags`, `timeSeriesTimeRanges` and
`timeSeriesMetricFamilies` (and the aliases `timeSeriesData`,
`timeSeriesMetrics`) look up the TimeSeries table and its target in
`parseArguments` and then return the target's columns, but nothing in the
class checks a privilege on the TimeSeries table. A user with only
`SHOW TABLES` on `db.ts` (or no grant on it at all) therefore got the
target's columns from `DESCRIBE TABLE timeSeriesSamples('db', 'ts')` and
`DESCRIBE (SELECT ...)`, and could `SELECT` from the target, also through a
`remote()` local shard or parallel replicas, while `DESCRIBE TABLE db.ts`
is denied.

Check `SHOW COLUMNS` on the resolved TimeSeries table id before the lookup,
the privilege `DESCRIBE TABLE db.ts` checks at the same point, through the
existing `ITableFunction::checkSourceTableAccess` helper. `parseArguments`
runs before every use of the function, so one check covers every spelling
and all four functions. A table-level `SELECT` or `INSERT` on the TimeSeries
table implies `SHOW COLUMNS`, so ordinary readers and writers are unaffected;
a missing table now gives `ACCESS_DENIED` to a user without the grant, as a
direct `DESCRIBE` does. The Prometheus `/api/v1/metadata` endpoint reads
through `timeSeriesMetricFamilies` as the request's user and inherits the
check.

`timeSeriesSelector`, `prometheusQuery` and `prometheusQueryRange` are not
changed: they are the PromQL engine's read path, can be persisted with
`CREATE TABLE ... AS`, and their access design is the owner's open work
(ClickHouse#120267).

Closes ClickHouse#133495 (the `dictionary(...)` half was fixed by ClickHouse#122678).

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

can be tested Allows running workflows for external contributors comp-rbac Authorization: roles, grants, quotas, row-level security, access checks. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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.

6 participants