Repository navigation
Fix custom disks to follow host allowlist when reused - #129061
Conversation
|
Workflow [PR], commit [c815f03] Summary: ✅
AI ReviewSummaryThe PR enforces Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units391 translation units recompiled, 3677 s compile time in total, 391 of them have a recent master baseline. |
A user short `ATTACH TABLE` or `ATTACH DATABASE` reads its stored definition with `attach = false`, so the reuse check added for fresh definitions also rejected `DETACH` + `ATTACH` of an existing table or database on an HDFS disk after `remote_url_allow_hosts` was tightened. The S3 counterpart keeps that working (`test_custom_s3_disk_remote_url_allow_hosts`). Pass whether the definition is stored down to `DiskFromAST::createCustomDisk` and skip the reuse check for it; the first build of such a disk is still enforced by the factory. Related: #129061 Co-Authored-By: Claude Opus 5.5 <[email protected]>
48ca874 to
e8a1979
Compare
The reuse check expanded the endpoint from the definition again, but the
disk name is a hash of the definition before macro expansion, while the
reused `HDFSObjectStorage` keeps the URL it was built with. After a macro
such as `{hdfs_host}` changed to an allowed host, an identical definition
passed the check and kept writing to the forbidden one. Check the URL held
by the disk instead.
Related: #129061 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reuse check was gated on the root `type` or `object_storage_type` of the definition, so a disk with `type = 'object_storage'` whose HDFS backend comes from `locations` (for example through `include`) was reused without a check. Check the HDFS endpoints of all object storages the disk holds; wrappers that name another disk are left to their own check. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wrapper such as `encrypted` or `cache` takes the disk it names directly from the disks map, so `disk(type = 'encrypted', disk = 'old_hdfs', ...)` built a new disk over an HDFS endpoint that `remote_url_allow_hosts` no longer allows: neither the HDFS factory check nor the reuse check ran, and `cache` even starts the wrapped disk. Check the endpoints of the named custom disk and the custom disks it wraps before the wrapper is built, under `storage_policies_mutex`, and again when the wrapper itself is reused. Disks from the server config are exempt. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A user short `ATTACH TABLE` or `ATTACH DATABASE` reads its stored definition with `attach = false`, so the reuse check added for fresh definitions also rejected `DETACH` + `ATTACH` of an existing table or database on an HDFS disk after `remote_url_allow_hosts` was tightened. The S3 counterpart keeps that working (`test_custom_s3_disk_remote_url_allow_hosts`). Pass whether the definition is stored down to `DiskFromAST::createCustomDisk` and skip the reuse check for it; the first build of such a disk is still enforced by the factory. Related: #129061 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reuse check expanded the endpoint from the definition again, but the
disk name is a hash of the definition before macro expansion, while the
reused `HDFSObjectStorage` keeps the URL it was built with. After a macro
such as `{hdfs_host}` changed to an allowed host, an identical definition
passed the check and kept writing to the forbidden one. Check the URL held
by the disk instead.
Related: #129061 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reuse check was gated on the root `type` or `object_storage_type` of the definition, so a disk with `type = 'object_storage'` whose HDFS backend comes from `locations` (for example through `include`) was reused without a check. Check the HDFS endpoints of all object storages the disk holds; wrappers that name another disk are left to their own check. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wrapper such as `encrypted` or `cache` takes the disk it names directly from the disks map, so `disk(type = 'encrypted', disk = 'old_hdfs', ...)` built a new disk over an HDFS endpoint that `remote_url_allow_hosts` no longer allows: neither the HDFS factory check nor the reuse check ran, and `cache` even starts the wrapped disk. Check the endpoints of the named custom disk and the custom disks it wraps before the wrapper is built, under `storage_policies_mutex`, and again when the wrapper itself is reused. Disks from the server config are exempt. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
e8a1979 to
a9b9c51
Compare
A user short `ATTACH TABLE` or `ATTACH DATABASE` reads its stored definition with `attach = false`, so the reuse check added for fresh definitions also rejected `DETACH` + `ATTACH` of an existing table or database on an HDFS disk after `remote_url_allow_hosts` was tightened. The S3 counterpart keeps that working (`test_custom_s3_disk_remote_url_allow_hosts`). Pass whether the definition is stored down to `DiskFromAST::createCustomDisk` and skip the reuse check for it; the first build of such a disk is still enforced by the factory. Related: #129061 Co-Authored-By: Claude Opus 5.5 <[email protected]>
a9b9c51 to
5fea75c
Compare
The reuse check expanded the endpoint from the definition again, but the
disk name is a hash of the definition before macro expansion, while the
reused `HDFSObjectStorage` keeps the URL it was built with. After a macro
such as `{hdfs_host}` changed to an allowed host, an identical definition
passed the check and kept writing to the forbidden one. Check the URL held
by the disk instead.
Related: #129061 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reuse check was gated on the root `type` or `object_storage_type` of the definition, so a disk with `type = 'object_storage'` whose HDFS backend comes from `locations` (for example through `include`) was reused without a check. Check the HDFS endpoints of all object storages the disk holds; wrappers that name another disk are left to their own check. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wrapper such as `encrypted` or `cache` takes the disk it names directly from the disks map, so `disk(type = 'encrypted', disk = 'old_hdfs', ...)` built a new disk over an HDFS endpoint that `remote_url_allow_hosts` no longer allows: neither the HDFS factory check nor the reuse check ran, and `cache` even starts the wrapped disk. Check the endpoints of the named custom disk and the custom disks it wraps before the wrapper is built, under `storage_policies_mutex`, and again when the wrapper itself is reused. Disks from the server config are exempt. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`Context::getStoragePolicyFromDisk` registers the policy `__<disk>` for a custom disk, so a fresh `CREATE TABLE ... SETTINGS storage_policy = '__<disk>'` reached that disk without `ensureDiskIsNotCustom` or the `remote_url_allow_hosts` check. A fresh definition now rejects a policy that contains a custom disk; stored metadata is still loaded as before. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A user short `ATTACH TABLE` or `ATTACH DATABASE` reads its stored definition with `attach = false`, so the reuse check added for fresh definitions also rejected `DETACH` + `ATTACH` of an existing table or database on an HDFS disk after `remote_url_allow_hosts` was tightened. The S3 counterpart keeps that working (`test_custom_s3_disk_remote_url_allow_hosts`). Pass whether the definition is stored down to `DiskFromAST::createCustomDisk` and skip the reuse check for it; the first build of such a disk is still enforced by the factory. Related: #129061 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reuse check expanded the endpoint from the definition again, but the
disk name is a hash of the definition before macro expansion, while the
reused `HDFSObjectStorage` keeps the URL it was built with. After a macro
such as `{hdfs_host}` changed to an allowed host, an identical definition
passed the check and kept writing to the forbidden one. Check the URL held
by the disk instead.
Related: #129061 (comment)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reuse check was gated on the root `type` or `object_storage_type` of the definition, so a disk with `type = 'object_storage'` whose HDFS backend comes from `locations` (for example through `include`) was reused without a check. Check the HDFS endpoints of all object storages the disk holds; wrappers that name another disk are left to their own check. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wrapper such as `encrypted` or `cache` takes the disk it names directly from the disks map, so `disk(type = 'encrypted', disk = 'old_hdfs', ...)` built a new disk over an HDFS endpoint that `remote_url_allow_hosts` no longer allows: neither the HDFS factory check nor the reuse check ran, and `cache` even starts the wrapped disk. Check the endpoints of the named custom disk and the custom disks it wraps before the wrapper is built, under `storage_policies_mutex`, and again when the wrapper itself is reused. Disks from the server config are exempt. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
5fea75c to
37180cb
Compare
- `IObjectStorage::checkRemoteHostFilter` replaces the switch over object storage types in `checkCustomDiskRemoteHosts`: S3, HDFS and Azure check the hosts they connect to, and `CachedObjectStorage` forwards to the storage it wraps. This removes the `dynamic_cast` that skipped the S3 check silently for any other implementation, the HDFS URL taken from `getDescription`, and the backend headers included in `DiskFromAST.cpp`. - `AzureObjectStorage::getURIsForRemoteHostFilter` is used both by `ObjectStorageFactory` and by the check of a reused disk, so the Azure hosts (the connection URL and the ADLS Gen2 endpoint, without the SAS token) are defined in one place. - The host check is a part of `DiskFromAST::ensureDiskIsAllowed` and `DiskFromAST::ensureStoragePolicyIsAllowed`, which were already called at the same places, instead of separate functions. - `getOrCreateCustomDisk` decides once whether hosts are checked. A new wrapper of a custom disk in a short `ATTACH` is now exempt too, like a reused disk. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-allowlist # Conflicts: # src/Databases/DatabaseMetadataDiskSettings.cpp # src/Databases/DatabaseMetadataDiskSettings.h
`allowed_disks_for_table_engines` allows a disk by name, and a custom disk with that name could be built before `remote_url_allow_hosts` was tightened. Data lake engines and table functions took such a disk in `DataLakeConfiguration::fromDisk` without a check, so a fresh `Iceberg`, `DeltaLake` or `Paimon` definition could reach a host that is no longer allowed. `DiskFromAST::ensureDiskIsAllowed` now runs there, like for the other engines that select a disk by name; a replayed definition is exempt. Related: #129061 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `deltaLake` table function is not built with MSan, because `delta-kernel-rs` is disabled there. The check is in `DataLakeConfiguration::fromDisk`, shared by all data lake engines and table functions, so the `Iceberg` engine and `icebergS3` cover it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
HDFS disks defined in a query (
disk(type = 'hdfs', ...)) now check their endpoint againstremote_url_allow_hosts, the same way S3 and Azure disks and theHDFStable engine do. S3 and Azure disks were already checked when they were built, but not when a later definition reused a disk already in the cache. Such a disk was checked against an olderremote_url_allow_hosts, or was loaded from metadata with only a warning, so an identical definition, a wrapper or its policy could still reach a host that is no longer allowed. Reused disks of all three types are now checked.The check covers every way a fresh table or database definition can reach such a disk:
HDFSObjectStorageconnects (new S3 and Azure disks were already checked inObjectStorageFactory);includemay resolve differently by now). Every location of the disk is checked, includingread_onlydisks and the disks underencryptedandcachewrappers;encryptedorcachewrapper that names an existing custom disk;__<disk>selected withstorage_policyinMergeTree(CREATE,ALTER) andDistributed;Log,TinyLog,StripeLog,SetandJoin;SETTINGS diskin data lake engines (Iceberg,DeltaLake,Paimon) and their table functions (icebergS3,deltaLake, ...); like for the other engines, a custom disk that uses the server's own credentials is refused there as well;CREATE DATABASE ... SETTINGS disk = disk(...)).The hosts that are checked match what the factory checks for each type: the endpoint for HDFS, the endpoint and bucket for S3 (so a
<s3_bucket>entry allows the disk, as it does for thes3table function), and the connection URL for Azure. For ADLS Gen2 (OneLake) the write endpoint is checked as well, and the query string is cut so that no SAS token appears in the error message. Disks from the server configuration are not checked, including when a customcacheorencrypteddisk wraps one of them.Disks loaded from existing metadata keep loading and only get a warning. A short
ATTACH TABLEorATTACH DATABASEuses its stored definition and is not checked either.Tests:
test_merge_tree_hdfs: new HDFS disks, reuse before and after a restart, wrappers,includeand macros, policies, the engines listed above, and the shortATTACHexemption;test_merge_tree_azure_blob_storage: a reused Azure disk loaded with a warning is rejected, and a shortATTACHstill works;test_backward_compatibility/test_custom_s3_disk_remote_url_allow_hosts: after the upgrade, a reused S3 table disk and a reused database metadata disk are rejected, and the table disk is accepted once a<s3_bucket>entry allows it.Related: #129044
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
HDFS disks created in a query now respect
remote_url_allow_hosts. HDFS, S3 and Azure disks created in a query are now also checked when a table or database reuses an existing disk, wraps it, or selects it throughstorage_policyor by name. Previously, an S3 or Azure disk that was already loaded could be reused after its host was removed from the list. A definition whose host is not allowed is rejected withUNACCEPTABLE_URL. Existing tables and databases on such disks still load, with a warning in the log and insystem.warnings.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129061]
Version info
26.11.1.2699-master(included in26.11and later)