Skip to content

Revert "Fix table engine grants" - #100684

Merged
nikitamikhaylov merged 1 commit into
masterfrom
revert-98984-pufit/fix-table-engine-grants
Mar 25, 2026
Merged

nikitamikhaylov merged 1 commit into
masterfrom
revert-98984-pufit/fix-table-engine-grants

Conversation

@nikitamikhaylov

@nikitamikhaylov nikitamikhaylov commented Mar 25, 2026 •

Copy link
Copy Markdown
Member

Reverts #98984

Version info

  • Merged into: 26.4.1.258

@clickhouse-gh

clickhouse-gh Bot commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2d84453]

Summary: ✅


AI Review

Summary

This PR reverts the earlier TABLE ENGINE/SOURCE grant synchronization fix. I found a blocker: source-engine synchronization is now driven by a hard-coded engine list, which is already incomplete (e.g. YTsaurus, ArrowFlight). This can both deny valid grants and accidentally keep implicit TABLE ENGINE permissions. I requested changes.

PR Metadata

⚠️ Changelog category / Changelog entry from .github/PULL_REQUEST_TEMPLATE.md are missing in the PR body (Reverts ClickHouse/ClickHouse#98984 only), so metadata quality cannot be validated.

Exact replacement text:

  • Changelog category: CI Fix or Improvement (if this is an emergency revert to restore CI/stability), otherwise choose the category matching intended user impact.
  • Changelog entry: Reverted changes from #98984 that synchronized SOURCE grants with TABLE ENGINE grants, because they introduced RBAC regressions. Restores previous grant behavior.
Findings
❌ Blockers
  • [src/Access/ContextAccess.cpp:42] Source-engine mapping is now a manual list and omits existing source engines (YTsaurus, ArrowFlight). This breaks parity with registered storages and causes RBAC inconsistencies.
    Suggested fix: derive source engines from StorageFactory registrations (creator.features.source_access_type) instead of maintaining a static vector.

  • [src/Access/ContextAccess.cpp:298] In table_engines_require_grant = 0 mode, revocation also depends on that same incomplete list. Engines not present in the list silently retain implicit TABLE ENGINE permissions.
    Suggested fix: perform revoke/sync against all registered source engines from StorageFactory, not a hard-coded subset.

💡 Nits
  • PR metadata does not follow .github/PULL_REQUEST_TEMPLATE.md (missing changelog fields).
Tests

⚠️ Coverage for source/table-engine bridge behavior was reduced by removing targeted integration tests (test_source_grant_bridges_to_table_engine, test_source_revocation_blocks_table_engine, test_grant_table_engine_option). Please keep equivalent regression coverage if this revert is temporary.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ⚠️ Multiple targeted RBAC integration tests were removed.
Experimental gate ➖
No magic constants ✅
Backward compatibility ⚠️ RBAC behavior now depends on an incomplete static engine list.
SettingsChangesHistory.cpp ➖
PR metadata quality ⚠️ Missing required changelog template fields.
Safe rollout ⚠️ Static list can drift from registered engines in future rollouts.
Compilation time ✅
Performance & Safety
  • The main risk is safety/correctness in access control: incomplete source coverage can grant or deny TABLE ENGINE permissions unexpectedly.
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    1. Replace static source-engine list logic with StorageFactory-derived source-engine mapping.
    2. Ensure both grant-sync and revoke paths use the same dynamic source-engine source.
    3. Restore/replace removed RBAC regression coverage for source↔table-engine synchronization.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 25, 2026

namespace
{
const std::vector<String> source_table_engines = {

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 hard-coded source_table_engines list is now missing source engines like YTsaurus and ArrowFlight, while those engines still register source_access_type in StorageFactory.

That creates RBAC drift in both modes:

  • when table_engines_require_grant = 1, GRANT READ, WRITE ON <source> no longer bridges to GRANT TABLE ENGINE ON <engine> for omitted engines;
  • when table_engines_require_grant = 0, omitted engines keep implicit TABLE ENGINE access because they are never revoked in the loop below.

Please derive source engines from StorageFactory (as in the reverted logic) instead of maintaining a manual list.

{
/// Add TABLE_ENGINE on * and then remove TABLE_ENGINE on particular engines.
res.grant(AccessType::TABLE_ENGINE);
for (const auto & table_engine : source_table_engines)

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.

Related to the manual list below: this path now relies on source_table_engines for revocation, so any future source engine not added to that list silently keeps implicit TABLE ENGINE permissions when table_engines_require_grant = 0.

That is a security-sensitive default-permission bug. Please avoid list-based revocation here and keep this synchronized with registered source engines.

@clickhouse-gh

clickhouse-gh Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.10% +0.00%
Functions 24.40% 24.30% -0.10%
Branches 76.60% 76.70% +0.10%

PR changed lines: PR changed-lines coverage: 100.00% (80/80, 1 noise lines excluded)
Diff coverage report
Uncovered code

@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Mar 25, 2026
Merged via the queue into master with commit a6fc92d Mar 25, 2026
149 checks passed
@nikitamikhaylov
nikitamikhaylov deleted the revert-98984-pufit/fix-table-engine-grants branch March 25, 2026 15:01
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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.

2 participants