Skip to content

Fix RBAC bypass for DESCRIBE/CREATE TABLE AS via table functions - #99122

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
pufit:pufit/fix-describe-table-function-rbac-bypass
Mar 18, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
pufit:pufit/fix-describe-table-function-rbac-bypass

Conversation

@pufit

@pufit pufit commented Mar 9, 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 RBAC bypass that allowed users to obtain table structure via DESCRIBE TABLE or CREATE TABLE AS on table functions (mysql(), postgresql(), sqlite(), arrowFlight(), jdbc(), odbc(), etc.) without the required source access privileges. For functions that infer schema from remote servers, this also allowed triggering outbound connections (SSRF) without authorization.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

No documentation changes needed — this is a security fix that enforces existing access control semantics.


Summary

DESCRIBE TABLE table_function(...) and CREATE TABLE ... AS table_function(...) resolved table structure by calling getActualTableStructure() without any source access check. The access check (READ ON MYSQL, READ ON SQLITE, etc.) only existed in ITableFunction::execute(), which these code paths never called.

Affected table functions (SSRF + schema leak on DESCRIBE)

What changed

  • Added ITableFunction::getActualTableStructureWithAccess() — bundles checkSourceAccess() + getActualTableStructure() into a single call
  • Used it in InterpreterDescribeQuery, InterpreterCreateQuery, and getStructureOfRemoteTable (local shard path)
  • Removed partial per-function access checks from url(), s3()/azure()/hdfs(), and file() — they only guarded the structure == "auto" path and the s3/file versions were weaker (missing URI-level filtering via checkAccessWithFilter)

Test plan

  • New stateless test 04028_describe_table_function_rbac_bypass — verifies DESCRIBE and CREATE TABLE AS are denied without source grants, and succeed after granting

Note

High Risk
Touches RBAC enforcement paths for table functions and remote DESCRIBE, which is security-critical and may change behavior for existing users by rejecting previously-allowed queries without proper grants.

Overview
Closes an RBAC bypass where DESCRIBE TABLE table_function(...), CREATE TABLE ... AS table_function(...), and local-shard remote() structure resolution could fetch/infer table schemas (and potentially trigger outbound connections) without the required source privileges.

Introduces centralized access enforcement in ITableFunction via checkSourceAccess() and getActualTableStructureWithAccess(), updates interpreters and remote-structure helpers to use it, and removes ad-hoc per-table-function checks (e.g. url(), object storage, file()). Tests are updated/added to assert ACCESS_DENIED without READ ON <SOURCE> grants and to require READ ON REMOTE for remote-describe scenarios.

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

Version info

  • Merged into: 26.3.1.819 (included in 26.3 and later)
  • Backported to: 25.8.29.37

@clickhouse-gh

clickhouse-gh Bot commented Mar 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [0af5b33]

Summary: ✅

@pufit
pufit force-pushed the pufit/fix-describe-table-function-rbac-bypass branch from 8f64aa4 to 55a30da Compare March 9, 2026 23:08
pufit added 2 commits March 9, 2026 19:09
DESCRIBE TABLE and CREATE TABLE AS on table functions like mysql(),
postgresql(), sqlite(), etc. resolved structure without checking source
access, leaking schema info and triggering outbound connections (SSRF).

Add getActualTableStructureWithAccess() that bundles the source access
check with structure resolution. Use it in InterpreterDescribeQuery,
InterpreterCreateQuery, and getStructureOfRemoteTable.

Remove redundant per-function access checks from url(), s3()/azure(),
and file() that were partial (only guarded auto-detection path) and
inconsistent (s3/file missed URI-level filtering).
DESCRIBE remote() now requires source access via
getActualTableStructureWithAccess in addition to SHOW_COLUMNS.
@pufit
pufit force-pushed the pufit/fix-describe-table-function-rbac-bypass branch from 55a30da to b2e6cc6 Compare March 9, 2026 23:09
@pufit
pufit marked this pull request as ready for review March 10, 2026 04:31

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

DESCRIBE TABLE url() with explicit structure now requires READ ON URL.
Update test to expect ACCESS_DENIED instead of success.
@pufit
pufit force-pushed the pufit/fix-describe-table-function-rbac-bypass branch from 5b9da69 to 0af5b33 Compare March 10, 2026 04:37
@clickhouse-gh

clickhouse-gh Bot commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.80% 83.80% +0.00%
Functions 23.90% 23.90% +0.00%
Branches 76.30% 76.30% +0.00%

PR changed lines: PR changed-lines coverage: 98.00% (49/50)
Diff coverage report
Uncovered code

@serxa serxa self-assigned this Mar 10, 2026

@serxa serxa left a comment

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.

LGTM

@alexey-milovidov
alexey-milovidov merged commit f2358d5 into ClickHouse:master Mar 18, 2026
159 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 18, 2026
@clickhouse-gh clickhouse-gh Bot added the ready-for-backport PR is eligible for backporting (merged 7+ days ago, not reverted) label Mar 27, 2026
@maxknv maxknv removed the ready-for-backport PR is eligible for backporting (merged 7+ days ago, not reverted) label Mar 27, 2026
@clickhouse-gh clickhouse-gh Bot added the ready-for-backport PR is eligible for backporting (merged 7+ days ago, not reverted) label Mar 27, 2026
@pufit pufit added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jun 16, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jun 16, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jun 26, 2026
@robot-clickhouse robot-clickhouse removed the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 28, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Jul 28, 2026
Cherry pick #99122 to 25.8: Fix RBAC bypass for DESCRIBE/CREATE TABLE AS via table functions
robot-clickhouse added a commit that referenced this pull request Jul 28, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 28, 2026
alexey-milovidov added a commit that referenced this pull request Jul 29, 2026
Backport #99122 to 25.8: Fix RBAC bypass for DESCRIBE/CREATE TABLE AS via table functions
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 ready-for-backport PR is eligible for backporting (merged 7+ days ago, not reverted)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants