Skip to content

Enforce remote_url_allow_hosts for ArrowFlight engine and table function - #108507

Merged
SmitaRKulkarni merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/arrowflight-remote-host-filter
Jul 20, 2026
Merged

SmitaRKulkarni merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/arrowflight-remote-host-filter

Conversation

@groeneai

@groeneai groeneai commented Jun 25, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

The ArrowFlight table engine and the arrowFlight table function now honor the <remote_url_allow_hosts> allow-list. Previously the connection host and port were not validated, so a query could reach hosts not present in the allow-list.

Description

ArrowFlightConnection::connect() opened a gRPC connection to the user-supplied host:port without consulting RemoteHostFilter, so <remote_url_allow_hosts> was never enforced for ArrowFlight. An authenticated user with the ARROW_FLIGHT source grant could reach arbitrary internal TCP/gRPC endpoints (SSRF, internal service access, port scanning).

The fix adds a single host-and-port check at StorageArrowFlight::getConfiguration(), the choke point both the storage factory (registerStorageArrowFlight) and the table function (TableFunctionArrowFlight::parseArguments) route through. host/port are populated there for both the positional ArrowFlight('host:port', ...) form and the named-collection form, so both argument styles are covered. This mirrors TableFunctionRemote, ClickHouseDictionarySource and StoragePostgreSQL.

Backward compatible: the check only enforces the existing setting; the default empty allow-list permits all hosts, so existing setups are unaffected.

Reproduction (with <remote_url_allow_hosts> configured to not include the target):

SELECT * FROM arrowFlight('169.254.169.254:80', 'meta');
CREATE TABLE t (x Int32) ENGINE = ArrowFlight('127.0.0.1:9000', 'dataset');
-- Both are now rejected with UNACCEPTABLE_URL before any connection is opened.

A new integration test (test_arrowflight_storage::test_remote_host_filter) asserts that a disallowed host is rejected with UNACCEPTABLE_URL for the table function, the storage engine, and the named-collection forms.

Version info

  • Merged into: 26.7.1.1222 (included in 26.7 and later)
  • Backported to: 26.6.5.19, 26.3.33.38

ArrowFlightConnection::connect() opened a gRPC connection to the
user-supplied host:port without consulting RemoteHostFilter, so the
<remote_url_allow_hosts> allow-list was not enforced. An authenticated
user with the ARROW_FLIGHT source grant could therefore reach arbitrary
internal TCP/gRPC endpoints (SSRF, internal service access, port
scanning).

Add the host-and-port check at the single choke point,
StorageArrowFlight::getConfiguration(), which both the storage factory
and the table function route through, with host/port populated for the
positional and the named-collection argument forms. This mirrors
TableFunctionRemote, ClickHouseDictionarySource and StoragePostgreSQL.

Backward compatible: the check only enforces the existing setting, and
the default empty allow-list permits all hosts, so existing setups are
unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. With <remote_url_allow_hosts> restricted to one host, SELECT * FROM arrowFlight('127.0.0.1:5005','ABC') returns Code 491 UNACCEPTABLE_URL every time with the fix; without it, the server attempts the gRPC connection (Connection refused → ARROWFLIGHT_FETCH_SCHEMA_ERROR).
b Root cause explained? ArrowFlightConnection::connect() opens a gRPC connection to the user-supplied host:port with no RemoteHostFilter check, so <remote_url_allow_hosts> is never consulted → an ARROW_FLIGHT-granted user can SSRF to arbitrary internal endpoints.
c Fix matches root cause? Yes. Adds the missing getRemoteHostFilter().checkHostAndPort(host, port) at StorageArrowFlight::getConfiguration() — the validation that was absent — before any connection is created.
d Test intent preserved / new tests added? New test_arrowflight_storage::test_remote_host_filter asserts a disallowed host is rejected with UNACCEPTABLE_URL via the table function, the storage engine, and a named collection. No existing test weakened (all existing tests use the allow-listed arrowflight1).
e Both directions demonstrated? Yes. Built two Build-ID-verified binaries: baseline (1c194f3…) reaches the connection layer for a disallowed host; fixed (a366096…) rejects it with UNACCEPTABLE_URL, while an allow-listed host passes the filter (fails later only at DNS resolution).
f Fix is general across code paths? Yes. Both construction sites — registerStorageArrowFlight and TableFunctionArrowFlight::parseArguments — route through getConfiguration(), so one check covers both. ArrowFlightConnection::cloneWithHostAndPort() has no callers, so connect() is the only live vector.
g Fix generalizes across inputs? Yes. getConfiguration() populates host/port for both the positional ArrowFlight('host:port', …) form and the named-collection (host/hostname + port) form; the single check covers both. Verified with IP and hostname inputs.
h Backward compatible? Yes. Only enforces the existing <remote_url_allow_hosts> setting; the default empty allow-list permits all hosts (RemoteHostFilter returns true when uninitialized), so existing setups see no behavior change. No setting default or on-disk/wire format changed.
i Invariants and contracts preserved? Yes. checkHostAndPort is a read-only validation that throws UNACCEPTABLE_URL before any mutation or connection; it is placed after both argument branches have populated configuration.host/port, so the Configuration contract is unchanged on all paths.

Session id: cron:clickhouse-worker-slot-6:20260625-151100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar @yakov-olkhovskiy — could you review this? ArrowFlightConnection::connect() opened a gRPC connection to the user-supplied host:port without checking RemoteHostFilter, so <remote_url_allow_hosts> was not enforced (SSRF for ARROW_FLIGHT-granted users). The fix adds one checkHostAndPort at StorageArrowFlight::getConfiguration(), the choke point both the storage engine and the table function route through.

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ce62b5f]

Summary: ❌

job_name test_name status info comment
Stress test (amd_debug) FAIL
Logical error: Not-ready Set is passed as the second argument for function 'A (STID: 0250-41a5) FAIL cidb, issue ISSUE EXISTS
Stress test (amd_asan_ubsan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue ISSUE EXISTS
Stress test (arm_asan_ubsan, s3) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue ISSUE EXISTS
Stress test (arm_msan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue ISSUE EXISTS

AI Review

Summary

This PR enforces the existing remote_url_allow_hosts filter for ArrowFlight configuration before the lazy gRPC connection object is created, covering the table engine, table function, and named-collection argument paths. The added integration test exercises disallowed positional and named-collection inputs while the existing tests continue to cover the allow-listed host. I did not find any unresolved correctness, security, or compatibility issues in the current diff.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.40% 85.40% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.60% 77.60% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 4/4 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ce62b5f

CI fully finished on this head (Finish Workflow pass, Mergeable Check pass). Every red has an owner; none is caused by this PR's diff (it adds one RemoteHostFilter check in StorageArrowFlight::getConfiguration + a security test).

Note: "Bugfix validation (integration tests)" reports 8/9 sub-test FAILs but the JOB itself is pass - that check deliberately runs the PR's tests on the no-fix base; the PR's new security case test_remote_host_filter correctly passes, and the 8 pre-existing arrowflight sub-tests fail only because the no-fix base lacks the PR's test config. Not a real failure.

Check / test Reason Owner / fixing PR
Stress test (amd_asan_ubsan / arm_asan_ubsan, s3 / arm_msan) / Hung check failed, possible deadlock found deadlock (chronic trunk family, 447 distinct PRs / 330 master hits in 30d) #101680 / #105905 (ours, open)
Stress test (amd_debug) / Logical error: Not-ready Set is passed as the second argument for function 'in' (STID: 0250-41a5) chronic trunk LOGICAL_ERROR (14 master / 38 PRs in 30d; unrelated to RemoteHostFilter) #107924 (external, open) - non-destructive in-place set build; also a fix task is in pending (full effort, fixing-PR link to follow)
Report messages (18 warnings) informational warnings aggregator, non-blocking (Mergeable Check is green) N/A (informational)

Session id: cron:our-pr-ci-monitor:20260625-200000

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - ce62b5f (owner correction)

Correcting the Not-ready Set owner line: the owner is the external open fixing PR (no separate pending fix task is needed since a fixing PR exists).

Check / test Reason Owner / fixing PR
Stress test (amd_debug) / Not-ready Set is passed as the second argument for function 'in' (STID: 0250-41a5) chronic trunk LOGICAL_ERROR (14 master / 38 PRs in 30d; unrelated to RemoteHostFilter) #107924 (external, open) - "Fix Not-ready Set exception by making in-place set build non-destructive"

Session id: cron:our-pr-ci-monitor:20260625-200000

@SmitaRKulkarni SmitaRKulkarni self-assigned this Jul 20, 2026

@SmitaRKulkarni SmitaRKulkarni 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

@SmitaRKulkarni
SmitaRKulkarni added this pull request to the merge queue Jul 20, 2026
Merged via the queue into ClickHouse:master with commit 9f49403 Jul 20, 2026
164 of 169 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 20, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

TL;DR

Enforce remote_url_allow_hosts for ArrowFlight engine and table function

ClickGap verified: reproduced it with the script below on 26.6; tested 7 version(s) — 6 affected, 1 clean (see Affects); long-standing (not a recent regression); introducing PR not yet pinned.

Reproduction

Configure a server whose allow-list does NOT include the target host, e.g.:
  <remote_url_allow_hosts><host>allowed.example.com:443</host></remote_url_allow_hosts>
Then run (table function, engine, and named-collection forms all affected):
  SELECT * FROM arrowFlight('127.0.0.1:9', 'ds');
  CREATE TABLE t (x Int32) ENGINE = ArrowFlight('127.0.0.1:9', 'ds');
Observed pre-fix: the disallowed host is NOT rejected; ClickHouse opens the connection and fails with Code: 752 ARROWFLIGHT_FETCH_SCHEMA_ERROR ('Failed to connect ... Connection refused'). Fixed behavior: rejected with UNACCEPTABLE_URL (Code: 491) before any connection is opened.

Bisect

  • Reproduces on every release line tested down to v25.12.11.4 (the oldest with a downloadable binary for this repro). The introducing change predates v25.12.11.4, so it can't be pinned from release binaries — this is a long-standing issue, not a recent regression. A maintainer with full git history can git blame the relevant file/line to find the exact change.

Affects

  • ✓ Fix is on master — this PR's change fixes the bug on master. Branches below still have the bug and need the backport.
  • Reproduces on: 26.6, 26.5, 26.4, 26.3, 26.2, 26.1
  • Does NOT reproduce on: master
  • Backport needed: 26.6, 26.5, 26.4, 26.3, 26.2, 26.1

Suggested next step

The fix has landed on master; the affected release branches above still need the backport.

Component: comp-arrow-flight
Severity: P2

cc fix PR author: @groeneai
cc fix PR reviewer: @SmitaRKulkarni


ClickGap · Finding: phase_d_pr108507

Triage metadata

  • Primary component: comp-arrow-flight
  • Secondary components: comp-testing
  • Component owners (comp-arrow-flight): @yakov-olkhovskiy @vitlibar

@Algunenano Algunenano added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Sep 1, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 1, 2026
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 1, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Sep 1, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 1, 2026
Backport #108507 to 26.6: Enforce remote_url_allow_hosts for ArrowFlight engine and table function
PedroTadim added a commit that referenced this pull request Sep 10, 2026
Backport #108507 to 26.3: Enforce remote_url_allow_hosts for ArrowFlight engine and table function
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ht-remote-host-filter

Enforce remote_url_allow_hosts for ArrowFlight engine and table function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default 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.

7 participants