Repository navigation
Reject MySQL hosts that the client library would reinterpret, and check remote_url_allow_hosts in the MySQL database engine - #129139
Conversation
|
Workflow [PR], commit [b886e19] Summary: ✅
AI ReviewSummaryReviewed head Missing context / blind spots
Final Verdict✅ Approve based on code review. Targeted CI results remain outstanding. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes9 object files changed (+23.26 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units13 translation units recompiled, 40 s compile time in total, 13 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.06 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
… reject NUL in filtered hosts
`mysql_real_connect` reads a host with `;` or `=` as a connection string (socket, plugin dir, TLS files), `://` as a plugin URL, `,` as a host list, and stops at NUL. Reject these in `mysqlxx::Pool` for all MySQL paths, drop `checkCanonicalHostAndPort`, and fix clang-tidy. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Otherwise the client library sends `localhost` to its default Unix socket and ignores the port checked by `remote_url_allow_hosts`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The client library replaces port 0 with its default port, so the connection would not go to the port checked by `remote_url_allow_hosts`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The client library uses `socket` only for `localhost`, so port 0 with another host still goes to the default TCP port. Document that hosts are reached over TCP and that `remote_url_allow_hosts` does not check dictionary sockets. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The client library ends the socket path at the first NUL, so a socket starting with one would be ignored and the connection would go over TCP to the default port. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
remote_url_allow_hosts in the MySQL database engineremote_url_allow_hosts in the MySQL database engine
Cherry pick #129139 to 26.3: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
…would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Cherry pick #129139 to 26.8: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
…would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Cherry pick #129139 to 26.9: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
…would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Cherry pick #129139 to 26.10: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
… would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Backport #129139 to 26.8: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Backport #129139 to 26.10: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Backport #129139 to 26.9: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
Backport #129139 to 26.3: Reject MySQL hosts that the client library would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
…ct-socket Resolves the conflict with ClickHouse#129139 in the embedded MySQL dictionary source docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse#129139 made every MySQL connection without an explicit `socket` use TCP, including `localhost`, and made every MySQL connection reject hosts that the client library reads as a connection string or a list of hosts. That covers the `force_tcp` flag and the dictionary-only host check of this PR, so both are removed and the mysqlxx and MySQLHelpers files are back to master. What remains is rejecting `socket` in a dictionary created with a DDL query, at the source and at each replica. 05229_mysql_dictionary_socket keeps the `socket` cases and one TCP control. The dictionary cases of 05493_mysql_host_connector_syntax set `SOCKET` in a DDL dictionary, so they now check port 0 without `socket`; a dictionary with `socket` and port 0 is only reachable from a server configuration file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…entries of configuration-file ones With `share_connection`, `PoolFactory::get` returns a cached pool keyed by `getPoolEntryName`, which joins the configuration fields without framing. The DDL checks (`socket`, `ssl_*` paths, `enable_local_infile`, the host filter) only see the keys of the `CREATE DICTIONARY` query, so a DDL source whose key matched a pool created from a configuration file got that pool, including its configured socket. On bbfc810 the `force_tcp` suffix kept the keys apart; it went away with ClickHouse#129139. `getPoolEntryName` now takes `created_from_ddl` and appends a marker for DDL-created sources, so their keys never equal a configuration-file key. The dictionary source passes it through `PoolFactory::get`. Covered by a new case in `gtest_pool_entry_name.cpp` (same configuration, different origin, different key). Also drop the `MySQL socket` alternative from the 05493 grep: the DDL dictionary cases there no longer set `SOCKET`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
…would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
…would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
… would reinterpret, and check `remote_url_allow_hosts` in the `MySQL` database engine
CREATE DATABASE ... ENGINE = MySQLdid not check hosts againstremote_url_allow_hosts, unlike themysqltable function, theMySQLtable engine and thePostgreSQLdatabase engine. Now it does, for both inline arguments and named collections, skipping the check only for the server's own metadata replay.The MySQL client library does not always connect to the host and port that were checked. It reads a host containing
;or=as a connection string (which can set a socket, a plugin directory or TLS files),://as a connection plugin URL, and,as a list of hosts. It also stops at a NUL, sendslocalhostto its default Unix socket and replaces port 0 with its default port. All MySQL connections now reject these hosts, port 0 without a used socket, and sockets containing NUL. Connections without an explicit socket always use TCP to the given port, includinglocalhost.Closes: https://github.com/ClickHouse/clickhouse-private/issues/74309
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The
MySQLdatabase engine now respectsremote_url_allow_hosts. MySQL hosts that the client library would read as a connection string, a plugin URL or a list of hosts are rejected, andlocalhostwithout an explicitsocketnow connects over TCP to the given port instead of the default Unix socket.Workflow [PR]
Sync PR [sync-upstream/pr/129139]
Version info
26.11.1.1523-master(included in26.11and later)