Skip to content

Revert "Require the FILE source grant for an EmbeddedRocksDB table with an explicit rocksdb_dir" - #117651

Merged
Algunenano merged 1 commit into
masterfrom
revert-117428-rocksdb-explicit-dir-file-grant
Sep 2, 2026
Merged

Algunenano merged 1 commit into
masterfrom
revert-117428-rocksdb-explicit-dir-file-grant

Conversation

@PedroTadim

@PedroTadim PedroTadim commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Reverts #117428


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

Version info

  • Merged into: 26.9.1.530 (included in 26.9 and later)

@PedroTadim
PedroTadim enabled auto-merge September 2, 2026 10:13
@clickhouse-gh

clickhouse-gh Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [aecef40]


AI Review

Summary

This PR reverts the recently added FILE-grant enforcement for EmbeddedRocksDB(..., rocksdb_dir, ...) and deletes the matching regression test. The revert is not safe: it reopens a privilege bypass that lets a user with CREATE TABLE plus TABLE ENGINE ON EmbeddedRocksDB reopen another RocksDB directory under user_files_path as their own table, bypassing the intended READ/WRITE ON FILE gate and any privilege on the original table.

Findings

❌ Blockers

  • [src/Storages/RocksDB/StorageEmbeddedRocksDB.cpp:856-867] Removing the deleted checkAccess(..., FILE) block reopens server-side file access through explicit rocksdb_dir. StorageEmbeddedRocksDB still resolves relative paths under user_files_path and opens the directory in initDB, so a user can create a read-only table over another table's RocksDB directory and read it through their own table; in writable mode they can also modify or wipe that directory with normal table operations. Suggested fix: keep the FILE grant check for fresh definitions and fix or replace the flaky test instead of reverting the permission enforcement.
Final Verdict

❌ Changes requested

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Sep 2, 2026
@Algunenano Algunenano self-assigned this Sep 2, 2026
@Algunenano
Algunenano added this pull request to the merge queue Sep 2, 2026
@PedroTadim

Copy link
Copy Markdown
Member Author

I think the issue is the test cannot run in parallel, but it didn't fail in the PR?

Comment on lines -856 to -866
/// An explicit `rocksdb_dir` opens a directory under `user_files_path` and needs the same `FILE` grant
/// as `file`; the argument-less form touches only the table's own data directory, and `clickhouse-local`
/// has no `user_files` fence to authorize. A replayed definition was authorized when it was introduced.
auto local_context = args.getLocalContext();
const bool from_existing_metadata = isLoadingFromExistingMetadata(args.mode) || args.query.attach_short_syntax;
if (!rocksdb_dir.empty() && !from_existing_metadata
&& local_context->getApplicationType() != Context::ApplicationType::LOCAL)
{
const AccessFlags required
= read_only ? AccessFlags(AccessType::READ) : (AccessType::READ | AccessType::WRITE);
local_context->checkAccess(required, toStringSource(AccessTypeObjects::Source::FILE));

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 check is the only thing that prevents EmbeddedRocksDB(..., rocksdb_dir, ...) from becoming an unguarded server-side file opener. The constructor still resolves a relative rocksdb_dir under user_files_path, and initDB still opens that directory immediately, so after this revert any user who can CREATE TABLE with EmbeddedRocksDB can point a new table at another RocksDB directory under user_files and read it through their own table. In writable mode they can also mutate it with INSERT/DELETE/TRUNCATE.

If 05054_embedded_rocksdb_explicit_dir_file_grant.sh is flaky, the fix needs to be in the test. Dropping the READ/WRITE ON FILE gate for fresh CREATE, full ATTACH, and RESTORE definitions reopens the privilege bypass that the deleted test was covering.

Merged via the queue into master with commit 552cef4 Sep 2, 2026
42 of 59 checks passed
@Algunenano
Algunenano deleted the revert-117428-rocksdb-explicit-dir-file-grant branch September 2, 2026 11:07
@zlareb1

zlareb1 commented Sep 2, 2026

Copy link
Copy Markdown
Member

The 05054_embedded_rocksdb_explicit_dir_file_grant failure was not parallelism — it was merge skew between #117428 and #117406, which landed ten minutes apart (08:47 and 08:57 UTC), so each PR's CI ran against a master lacking the other. That is why the test was green in #117428's own CI and started failing on master and on every unrelated PR only after both had merged.

The mechanism: the test's RESTORE arm has a restricted user run RESTORE TABLE ... FROM Disk('backups', ...) while holding only FILE grants. #117406 makes the Disk(...) backup location itself require READ ON DISK, and that check fires before the WRITE ON FILE check the arm asserts on. So the "denied" arm now dies with necessary to have the grant READ ON DISK instead of Missing permissions: WRITE ON FILE and prints NOT DENIED, and the "allowed" arm (after GRANT WRITE ON FILE) still lacks READ ON DISK and prints restore-FAILED. The failure is deterministic, which matches the rerun diagnosis on the CI side.

The enforcement reverted here was itself sound, and its PR description documents the bypass it closed (reopening another user's RocksDB directory under user_files_path without any FILE grant, including TRUNCATE doing fs::remove_all on it). A re-land only needs a one-line test fix: GRANT READ ON DISK TO ${USER} before the RESTORE arm (the arm only reads the backup location), keeping the rest of the test byte-identical.

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.

4 participants