Repository navigation
Add S3 bucket to remote_url_allow_hosts - #124453
Conversation
|
Workflow [PR], commit [4f09f03] Summary: ❌
AI ReviewSummaryThis PR adds bucket-scoped Findings
Final Verdict
LLVM Coverage ReportMeasured on commit 4f09f03.
Changed lines: Changed C/C++ lines covered: 123/123 (100.00%) · Uncovered code |
`RemoteHostFilter` only matches the host of a URL, so on a shared path-style endpoint such as `s3.us-west-2.amazonaws.com` it can either allow every bucket in the region or none. After #123114 made `BACKUP`/`RESTORE` to `S3` honor the filter, Cloud instances with `remote_url_allow_hosts` could no longer reach the platform backup bucket, and allowing the whole host would defeat the setting. Add an `s3_bucket` entry of the form `host/bucket` or `host:port/bucket`. S3 URLs are checked through `S3::URI::checkRemoteHostFilter`, which accepts the URL when the parsed endpoint host and bucket are listed, and otherwise falls back to the host check. The bucket comes from the parser, so the entry matches both path-style and virtual-hosted-style URLs. Used by the `s3` table functions and engines, the `S3` database engine, `BACKUP`/`RESTORE` to `S3` and the redirect check in `S3::Client`. Related: #123114 Related: ClickHouse/clickhouse-private#78644 Co-Authored-By: Claude Fable 5.1 <[email protected]>
`DatabaseS3::isTableExist` and `getTableImpl` go through `S3::URI::checkRemoteHostFilter` as well; check that a table in the allowed bucket is visible and readable while the same path in another bucket on the same endpoint is not. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
`RemoteHostFilter::setValuesFromConfig` cleared the allow lists and refilled them in place, so a malformed `<s3_bucket>` left only the entries preceding it while the filter stayed initialized. Parse into local containers and swap them in together with `is_initialized` only on success. Also document that `307 Temporary Redirect` locations are checked only against `<host>` and `<host_regexp>`, not `<s3_bucket>`. #124453 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
|
||
| std::lock_guard guard(hosts_mutex); | ||
| return s3_buckets.contains(endpoint_host + "/" + bucket) | ||
| || s3_buckets.contains(endpoint_host + ":" + toString(endpoint_port) + "/" + bucket); |
There was a problem hiding this comment.
The new host:port/bucket contract is broken for IPv6 endpoints. endpoint_host here is the bare host from the parsed URI, so for http://[2001:db8::1]:9001/root/... this lookup becomes 2001:db8::1:9001/root. But the only unambiguous config spelling is <s3_bucket>[2001:db8::1]:9001/root</s3_bucket>, which will never match.
Please canonicalize IPv6 hosts before building the key (or parse/store the config as structured host/port + bucket), and add a regression test for an explicit-port IPv6 endpoint.
Integration test `test_remote_host_filter_s3_bucket`: - a second node with `<s3_bucket>minio1/root</s3_bucket>` checks the entry form without a port, which is the form for a cloud endpoint on port 443 - the `base_backup` of an incremental backup goes through the same check - `SYSTEM RELOAD CONFIG` applies a new list without a restart, and a malformed entry placed first makes the reload fail and keeps the previous list - the positive cases of the custom disk test use `query`, because `query_and_get_error` raises when the query succeeds - a comment explains why the `S3` database test expects `UNKNOWN_TABLE` Unit tests: - `gtest_remote_host_filter`: entry format validation, port semantics of `isBucketAllowed`, absent section versus present but empty section - `gtest_s3_uri`: `checkRemoteHostFilter` for the path-style and the virtual-hosted form of one bucket, another bucket, another port, and the fallback to a `<host>` entry Docs and `config.xml`: a 301 redirect returned by S3 is checked against the bucket entries, a 307 redirect is checked by host only. Verified with the CI `build_amd_binary` of 7412e40: 10 of 12 tests pass; the two custom disk cases need the disk check that 45f7386 adds. Co-Authored-By: Claude Fable 5.1 <[email protected]>
`DiskFromAST::createCustomDisk` walked the disk AST with `InDepthNodeVisitor`, which appends `While processing <ast>` to any exception. The `disk` function is masked only as a setting value (`FieldFromASTImpl`), so the bare `ASTFunction` was printed with its credentials. Any failure while creating a custom disk, such as the new `UNACCEPTABLE_URL` check for S3 disks, put `secret_access_key` into the error and the server log, and the test masking rule turned that into an abort. Use a plain bottom-up traversal that does not decorate exceptions. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=124453&sha=7fb25dfd064ffe3ade1142182e171aba3f875e92&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20flaky%29 #124453 Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the master merge, a query-created Azure disk is checked against `remote_url_allow_hosts` through `run_remote_host_filter_check`, the flag S3 disks use since ClickHouse#124453, so the check also runs when the table is loaded from metadata. Before, it was keyed on `run_local_paths_check`, which is false on FORCE_ATTACH: after a restart, a table whose disk host had been removed from the allowlist loaded and wrote to that host. The checked URL now keeps only the scheme, host and port. The connection URL of a SAS connection string carries the token in its query, and ClickHouse#124453 removed the `While processing disk(...)` suffix that used to quote it anyway, so without this the error and the server log would be the only place still showing `sig=`. The message now matches the one the request-time check in `PocoAzureHTTPClient` uses. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@scanhex12 @alexbakharew @jkartseva — this PR looks backward incompatible but is categorized as Why: Suggested category: |
Cherry pick #124453 to 26.3: Add S3 bucket to `remote_url_allow_hosts`
Cherry pick #124453 to 26.7: Add S3 bucket to `remote_url_allow_hosts`
Cherry pick #124453 to 26.8: Add S3 bucket to `remote_url_allow_hosts`
Cherry pick #124453 to 26.9: Add S3 bucket to `remote_url_allow_hosts`
Backport #124453 to 26.9: Add S3 bucket to `remote_url_allow_hosts`
Backport #124453 to 26.8: Add S3 bucket to `remote_url_allow_hosts`
Backport #124453 to 26.7: Add S3 bucket to `remote_url_allow_hosts`
Backport #124453 to 26.3: Add S3 bucket to `remote_url_allow_hosts`
Adapted to this branch, which carries #124453 on the pre-#110665 factory API: the third `ObjectStorageFactory::create` parameter becomes `RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`, and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk` arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message and only gains the early returns. `DatabaseFactory::Arguments` has no `is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added. The backward-compatibility test starts from the pinned image `26.3.50.11` (built 2026-10-13, before #124453 reached this branch) instead of the floating `26.8` tag, which will soon include the check itself and would fail to create the disks. 26.3 keeps its non-static `registerS3ObjectStorage`, its single-line `storage_settings->loadFromQuery` call and has no `DistributedPlanExecutor.cpp`. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Adapted to this branch, which carries #124453 on the pre-#110665 factory API: the third `ObjectStorageFactory::create` parameter becomes `RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`, and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk` arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message and only gains the early returns. `DatabaseFactory::Arguments` has no `is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added. The backward-compatibility test starts from the pinned image `26.9.18.11` (built 2026-10-13, before #124453 reached this branch) instead of the floating `26.8` tag, which will soon include the check itself and would fail to create the disks. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Adapted to this branch, which carries #124453 on the pre-#110665 factory API: the third `ObjectStorageFactory::create` parameter becomes `RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`, and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk` arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message and only gains the early returns. `DatabaseFactory::Arguments` has no `is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added. The backward-compatibility test starts from the pinned image `26.8.26.12` (built 2026-10-13, before #124453 reached this branch) instead of the floating `26.8` tag, which will soon include the check itself and would fail to create the disks. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Bring the resolved cherry-pick onto the refreshed base (26.3 with #124453). No content change: the tree is the one already resolved. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Adapted to this branch, which carries #124453 on the pre-#110665 factory API: the third `ObjectStorageFactory::create` parameter becomes `RemoteHostFilterCheck remote_host_filter_check` next to `skip_access_check`, and `registerDiskObjectStorage` derives it from its `attach` and `custom_disk` arguments. `RemoteHostFilter::checkURL` keeps this branch's unmasked message and only gains the early returns. `DatabaseFactory::Arguments` has no `is_restore_from_backup` here, so only `isLoadingFromExistingMetadata` is added. The backward-compatibility test starts from the pinned image `26.7.29.12` (built 2026-10-13, before #124453 reached this branch) instead of the floating `26.8` tag, which will soon include the check itself and would fail to create the disks. Co-Authored-By: Claude Fable 5.1 <[email protected]>
….8.26.12 The test needs an old server that does not check SQL-defined disks against `remote_url_allow_hosts`, and took it from the moving tag `clickhouse/clickhouse-server:26.8`. Since `26.8.28.14` (2026-10-15) that tag contains the 26.8 backports of ClickHouse#124453 (ClickHouse#125789) and ClickHouse#124930 (ClickHouse#125821), so the old server rejects the test's first setup CREATE with `Code: 491 UNACCEPTABLE_URL` before any upgrade, and both tests fail on master. Pin both instances to `26.8.26.12`, which predates both backports. This makes the file byte-identical to the 26.8 branch copy, which already pins this tag. Co-Authored-By: Claude Opus 5.5 <[email protected]>
closes: https://github.com/ClickHouse/clickhouse-private/issues/78644
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add S3 bucket to
remote_url_allow_hostsWorkflow [PR]
Sync PR [sync-upstream/pr/124453]
Version info
26.10.1.1913-master(included in26.10and later)26.9.19.12,26.8.27.12,26.7.30.12,26.3.52.3