Skip to content

S3 client check initial url in backup client - #123114

Merged
scanhex12 merged 3 commits into
masterfrom
s3-client-check-initial-url
Sep 30, 2026
Merged

scanhex12 merged 3 commits into
masterfrom
s3-client-check-initial-url

Conversation

@scanhex12

@scanhex12 scanhex12 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Critical Bug Fix (crash, data loss, RBAC)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

S3 client check initial url in backup client


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

Version info

  • Merged into: 26.10.1.1110-master (included in 26.10 and later)
  • Backported to: 26.9.8.4, 26.8.15.18, 26.7.19.5, 26.3.40.13

scanhex12 and others added 3 commits September 30, 2026 17:18
`PocoHTTPClient` for S3 only checks redirect targets against `RemoteHostFilter`,
and `BackupIO_S3` never validated the user-supplied endpoint, so
`BACKUP ... TO S3(url)` and `RESTORE ... FROM S3(url)` could reach hosts that
`s3` and `url` refuse with `UNACCEPTABLE_URL`.

Validate the backup URL in `makeS3Client`, the same way
`StorageS3Configuration::check` does for the `s3` table function.

The test is moved into `test_backup_restore_s3`.

ClickHouse/clickhouse-private#69102

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bfb0592]

Summary: ✅


AI Review

Summary

This PR closes a real gap: BACKUP ... TO S3(...) and RESTORE ... FROM S3(...) now validate the initial destination URL against remote_url_allow_hosts before any S3 request is built, and the new integration test covers both accepted and rejected endpoints. I did not find a remaining bypass in the current code: both backup and restore construct their S3 clients through makeS3Client, and the existing redirect-time checks remain in place.

PR Metadata
  • Changelog category: Critical Bug Fix is reasonable for a host-filter bypass.
  • Changelog entry: the current text is too implementation-centric and is not user-readable. Suggested replacement: Enforces \remote_url_allow_hosts` for `BACKUP` and `RESTORE` when using `S3(...)` destinations.`
Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit bfb0592.

Metric Baseline Current Δ
Lines 88.20% 88.20% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 79.70% 79.60% -0.10%

Changed lines: Changed C/C++ lines covered: 4/4 (100.00%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! comp-backup Backup/restore infrastructure and backup formats. labels Sep 30, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing bfb05923f with master 49950117d (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

7 translation units recompiled, 10 s compile time in total, 7 of them have a recent master baseline.

Job report

@jkartseva jkartseva left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@scanhex12
scanhex12 enabled auto-merge September 30, 2026 21:26
@scanhex12
scanhex12 added this pull request to the merge queue Sep 30, 2026
Merged via the queue into master with commit 4d8c596 Sep 30, 2026
150 checks passed
@scanhex12
scanhex12 deleted the s3-client-check-initial-url branch September 30, 2026 22:24
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 30, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 30, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 1, 2026
Backport #123114 to 26.8: S3 client check initial url in backup client
clickhouse-gh Bot added a commit that referenced this pull request Oct 1, 2026
Backport #123114 to 26.9: S3 client check initial url in backup client
clickhouse-gh Bot added a commit that referenced this pull request Oct 1, 2026
Backport #123114 to 26.7: S3 client check initial url in backup client
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Oct 2, 2026
PedroTadim added a commit that referenced this pull request Oct 2, 2026
Cherry pick #123114 to 26.3: S3 client check initial url in backup client
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 2, 2026
PedroTadim added a commit that referenced this pull request Oct 2, 2026
Backport #123114 to 26.3: S3 client check initial url in backup client
scanhex12 added a commit that referenced this pull request Oct 7, 2026
`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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-backup Backup/restore infrastructure and backup formats. pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-critical-bugfix pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR 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.

5 participants