Skip to content

Safer hints for missing grants in exception messages - #91067

Merged
pufit merged 4 commits into
ClickHouse:masterfrom
filimonov:hide_details_from_access_denied_exception2
Mar 7, 2026
Merged

pufit merged 4 commits into
ClickHouse:masterfrom
filimonov:hide_details_from_access_denied_exception2

Conversation

@filimonov

@filimonov filimonov commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

ACCESS_DENIED hints no longer reveal column names unless the user can show all required columns; database/table names remain visible in the hint.

Documentation entry for user-facing changes

ACCESS_DENIED error hints no longer expose column names unless the user has SHOW_COLUMNS visibility for all required columns. Hints still include database/table names from the query. This reduces schema leakage while keeping grant guidance readable.

Example of the issue:

Code: 497. DB::Exception: foo: Not enough privileges. To execute this query, it's necessary to have the grant SELECT(cluster, shard_num, shard_name, shard_weight, internal_replication, replica_num, host_name, host_address, port, is_local, user, default_database, errors_count, slowdowns_count, estimated_recovery_time, database_shard_name, database_replica_name, is_active, unsynced_after_recovery, replication_lag, recovery_time) ON system.clusters. (ACCESS_DENIED)
  • Documentation is written (mandatory for new features)

Note

Medium Risk
Changes the formatting of ACCESS_DENIED hint text in a security-sensitive area (privilege visibility), which may affect clients/tests that rely on exact error messages.

Overview
Sanitizes ACCESS_DENIED hints so the “required grant” and “missing permissions” text no longer includes column names unless the user has SHOW_COLUMNS for all referenced columns; database/table names from the query remain visible.

Adds a new integration test suite (test_access_denied_hint_sanitized) and updates multiple existing integration tests to reflect the new hint behavior (often expecting SELECT ON db.table until SHOW COLUMNS is granted).

Written by Cursor Bugbot for commit f6a04c0. This will update automatically on new commits. Configure here.

Version info

  • Merged into: 26.3.1.501

@GrigoryPervakov GrigoryPervakov added the can be tested Allows running workflows for external contributors label Nov 28, 2025
@clickhouse-gh

clickhouse-gh Bot commented Nov 28, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f6a04c0]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Nov 28, 2025
@filimonov
filimonov force-pushed the hide_details_from_access_denied_exception2 branch from 4e1e2e0 to a329c29 Compare January 8, 2026 02:39
@filimonov

Copy link
Copy Markdown
Contributor Author

@vitlibar can you look?

@vitlibar vitlibar self-assigned this Jan 9, 2026
Comment thread src/Access/ContextAccess.cpp Resolved
@vitlibar

vitlibar commented Jan 9, 2026

Copy link
Copy Markdown
Member

@pufit What do you think?

@pufit

pufit commented Jan 12, 2026

Copy link
Copy Markdown
Member

I believe this is a good improvement. But first of all, before merging it, I want to merge my changes with optimizing the use of checkAccess, because right now some functions like isGranted do try checkAccess catch false, which is becoming extremely inefficient with our new error message formatting.

@filimonov

Copy link
Copy Markdown
Contributor Author

@pufit any updates?

which is becoming extremely inefficient with our new error message formatting.

I believe it's not a hot path in normal siturations. :)

@pufit

pufit commented Feb 9, 2026

Copy link
Copy Markdown
Member

Let's merge this PR first. #95874
I will try to fix the tests there today.

@pufit

pufit commented Feb 17, 2026

Copy link
Copy Markdown
Member

@filimonov, hi
I've merged #95874 so we can continue here. Can you resolve the conflicts?

Avoid exposing table structure to the users which does not have the permissions to access the table
@filimonov
filimonov force-pushed the hide_details_from_access_denied_exception2 branch from 2ff811f to 1d738f6 Compare March 6, 2026 01:23
@filimonov

Copy link
Copy Markdown
Contributor Author

@pufit done. And it's so green, that it's hard to believe :)

@pufit
pufit added this pull request to the merge queue Mar 7, 2026
Merged via the queue into ClickHouse:master with commit 7e8a088 Mar 7, 2026
146 checks passed
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 7, 2026
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 pr-improvement Pull request with some product improvements 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.

5 participants