Forbid creating directories in non-user directories#86844
Forbid creating directories in non-user directories#86844scanhex12 merged 21 commits intoClickHouse:masterfrom
Conversation
|
Test? |
Please set the proper category. This is a critical bugfix |
|
I am not against of merging this PR (at least it is mitigate crtical issue). But I am really worried that LocalObjectStorage interface allows us to do such actions. If so, the bug can be a great deal more dangerous |
divanik
left a comment
There was a problem hiding this comment.
Also address the tests and create the test which checks that security bug is not longer reproduced
| if (object_storage->getType() == ObjectStorageType::Local) | ||
| { | ||
| auto user_files_path = local_context->getUserFilesPath(); | ||
| if (!fileOrSymlinkPathStartsWith(configuration_ptr->getPathForRead().path, user_files_path)) | ||
| throw Exception(ErrorCodes::PATH_ACCESS_DENIED, "File path {} is not inside {}", configuration_ptr->getPathForRead().path, user_files_path); | ||
| } |
There was a problem hiding this comment.
Move the logic to
to also cover DeltaLake, referencing existing table (both by table engine and table function)There was a problem hiding this comment.
Any reasons why you think this is a bad suggestion?
|
From a security perspective, we cannot have a critical security check as an optional setting. That validation needs to be mandatory similarly as @Algunenano commented. I understand that there may be some extra effort needed to fix the failing tests but we need to have a proper and clean solution rather than a partial one. |
b64ecf6 to
7680331
Compare
| f"/iceberg_data/default/{TABLE_NAME}/", | ||
| f"/iceberg_data/default/{TABLE_NAME}/", |
There was a problem hiding this comment.
Is it true that default_upload_directory is always used with prefix "/var/lib/clickhouse/user_files/" now? Let's patch arguments in the function itself. This will dramatically change number of backported changes
| assert int(instance.query(f"SELECT count() FROM {TABLE_NAME}")) == 100 | ||
| snapshot1_timestamp = datetime.now(timezone.utc) | ||
| snapshot1_id = get_last_snapshot(f"/iceberg_data/default/{TABLE_NAME}/") | ||
| snapshot1_id = get_last_snapshot(f"/var/lib/clickhouse/user_files/iceberg_data/default/{TABLE_NAME}/") |
There was a problem hiding this comment.
This function is used 2 times with prefix /var/lib/clickhouse/user_files, so it's useless to move those changes in get_last_snapshot.
| if (object_storage->getType() == ObjectStorageType::Local) | ||
| { | ||
| auto user_files_path = local_context->getUserFilesPath(); | ||
| if (!fileOrSymlinkPathStartsWith(configuration_ptr->getPathForRead().path, user_files_path)) | ||
| throw Exception(ErrorCodes::PATH_ACCESS_DENIED, "File path {} is not inside {}", configuration_ptr->getPathForRead().path, user_files_path); | ||
| } |
There was a problem hiding this comment.
Any reasons why you think this is a bad suggestion?
ade470f to
7ae21a6
Compare
|
|
||
| auto log = getLogger("IcebergMetadata"); |
| ) | ||
|
|
||
| df = spark.read.format("iceberg").load(f"/iceberg_data/default/{TABLE_NAME}").collect() | ||
| df = spark.read.format("iceberg").load(f"/var/lib/clickhouse/user_files/iceberg_data/default/{TABLE_NAME}").collect() |
There was a problem hiding this comment.
Let's move this to a separate function (in backported code it also will be easy to replace such line with a function call)
| with open(f"/var/lib/clickhouse/user_files/iceberg_data/default/{TABLE_NAME}/metadata/version-hint.text", "wb") as f: | ||
| f.write(b"4") |
There was a problem hiding this comment.
Also this to a separate function which takes table name and int version
| @@ -28,12 +28,12 @@ def test_writes_create_partitioned_table(started_cluster_iceberg_with_spark, for | |||
| default_download_directory( | |||
There was a problem hiding this comment.
default_download_directory can be changed as a default_upload_directory
905b621 to
229471c
Compare
|
Please, change the changelog category to "Critical bug fix" |
5ec7d6d
+1, this seems relevant enough not only to be considered as a critical bug fix, but also IMHO a changelog entry is the bare minimum we should add as well |
|
@scanhex12 Will the work on backporting this pull request to the 25.8 version be continued? |
Changelog category (leave one):