Repository navigation
MySQL dictionary source: accept enable_local_infile only in the configuration file - #120972
Conversation
…guration file ClickHouse#112070 established that the source configuration of a dictionary created with a DDL query comes from the query itself, so it may not name files for the server to open: the server reads them with its own privileges. It implemented that as checkNoSSLPaths, keyed on the three ssl_ca / ssl_cert / ssl_key key names rather than on the invariant itself. enable_local_infile is in the same dictionary_allowed_keys and satisfies the same premise by a second, indirect route: it sets MYSQL_OPT_LOCAL_INFILE on the outgoing connection, which lets the MySQL endpoint the dictionary points at ask the client for the contents of a file of its choosing. The option is off by default for exactly this reason, and has been since 33205bb ("Disable LOAD DATA LOCAL INFILE because it is insecure", still visible at mysqlxx/Connection.h:16); 26a951e re-exposed it as an argument and bfc705c put it in the dictionary source's allowed keys, which is how a DDL query reaches it. It was never considered in ClickHouse#112070, so this completes that guard for the sibling key rather than duplicating it. The guard is applied at the two configuration prefixes the connection pool actually reads for a DDL-created dictionary: each <replica> prefix and the single-endpoint prefix, both inside the existing created_from_ddl block of the non-named-collection branch. It resolves the value in Pool::Pool's own lookup order, a replica value winning over the parent as its fallback (Pool.cpp:94-95), so what is rejected is the value the connection would really use. That matters in both directions: a <replica> inheriting a truthy parent is rejected, while a truthy parent whose every replica sets 0 is not, because PoolWithFailover builds only per-replica pools when replicas exist and so the parent alone decides nothing. An independent parent check would reject that safe configuration; open ClickHouse#109736 is a bug fix for the same class of mistake two lines away. The guard is deliberately not placed beside checkNoSSLPaths, which sits before the branch because for the SSL keys that breadth is necessary. It is not needed there for this key: the named-collection route reaches createMySQLPoolWithFailover, which passes the literal MYSQLXX_DEFAULT_ENABLE_LOCAL_INFILE (PoolWithFailover.cpp:164), and MySQLSettings carries no local_infile, so a collection-defined or NAME-overriding key is accepted and then never read. Guarding it there would break a configuration that cannot enable the option. That inertness is a precondition rather than a property, so it is stated in the PR body: adding such a setting, as ClickHouse#103229 did for enable_compression, would make that branch a live carrier. Resolution is by value rather than by presence, unlike checkNoSSLPaths: for a path key any value is dangerous, but enable_local_infile 0 is bit-for-bit the default and harmless, and this change is already backward incompatible without breaking configurations that never reach MYSQL_OPT_LOCAL_INFILE = 1. socket is the one other key in that list naming a path a DDL query can choose. It is deliberately not mirrored: it is a connect(2) to a path rather than a read of a file's contents, and pointing a dictionary at a local mysqld.sock is a legitimate, widely used configuration. Tests: a stateless test covering the four shapes that enable the option (source, an explicit <replica>, a <replica> that inherits it, a later <replica> when the first disables it) and the two that do not (0 at the source, 0 at every <replica> of a truthy source), which needs no MySQL server because the rejection precedes any connection, and an integration arm in test_dictionaries_mysql proving a configuration-file dictionary still loads and serves data with the option on while the same option from a DDL query against that endpoint is rejected. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Three rounds of pre-publication review before this PR was opened: an independent model
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20260919-042400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260919-033400 |
|
Workflow [PR], commit [32d8edc] Summary: ❌
AI ReviewSummaryThis PR closes the remaining DDL carrier for MySQL dictionary Final Verdict✅ Approve. LLVM Coverage ReportMeasured on commit 32d8edc.
Changed lines: Changed C/C++ lines covered: 33/33 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing commit See the job log for details. |
CI finish ledger - c1a3809Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20260919-093158 |
3fc318b
Backport #120972 to 26.9: MySQL dictionary source: accept `enable_local_infile` only in the configuration file
Backport #120972 to 26.8: MySQL dictionary source: accept `enable_local_infile` only in the configuration file
…enable_local_infile` only in the configuration file
…enable_local_infile` only in the configuration file
…guration file `enable_local_infile` sets `MYSQL_OPT_LOCAL_INFILE`, which lets the MySQL endpoint the dictionary points at ask the client for the contents of a file of its choosing, read with the server's own privileges. The source configuration of a dictionary created with a DDL query comes from the query itself, so it may not reach that option; it stays available to a dictionary defined in a server configuration file. (cherry picked from commit c1a3809) Adapted for 26.3. #112070 is not on this branch, so there is no `checkNoSSLPaths` for the guard to sit beside and no `BAD_ARGUMENTS` in the file's `ErrorCodes` block. `checkNoLocalInfile` is therefore added standalone, with that declaration, and hooked into the two `created_from_ddl` call sites this branch already has: the per-`<replica>` loop, which passes the parent prefix so an inherited value is resolved the way `Pool::Pool` resolves it, and the single-endpoint branch. The documentation hunk of the original is dropped, because the settings table it edits does not exist on this branch. Original pull-request: #120972 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…guration file `enable_local_infile` sets `MYSQL_OPT_LOCAL_INFILE`, which lets the MySQL endpoint the dictionary points at ask the client for the contents of a file of its choosing, read with the server's own privileges. The source configuration of a dictionary created with a DDL query comes from the query itself, so it may not reach that option; it stays available to a dictionary defined in a server configuration file. (cherry picked from commit c1a3809) Adapted for 26.7. #112070 is not on this branch, so there is no `checkNoSSLPaths` for the guard to sit beside and no `BAD_ARGUMENTS` in the file's `ErrorCodes` block. `checkNoLocalInfile` is therefore added standalone, with that declaration, and hooked into the two `created_from_ddl` call sites this branch already has: the per-`<replica>` loop, which passes the parent prefix so an inherited value is resolved the way `Pool::Pool` resolves it, and the single-endpoint branch. The documentation hunk of the original is dropped, because the settings table it edits does not exist on this branch. Original pull-request: #120972 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Cherry pick #120972 to 26.3: MySQL dictionary source: accept `enable_local_infile` only in the configuration file
Cherry pick #120972 to 26.7: MySQL dictionary source: accept `enable_local_infile` only in the configuration file
…al_infile` only in the configuration file
…al_infile` only in the configuration file
Backport #120972 to 26.3: MySQL dictionary source: accept `enable_local_infile` only in the configuration file
Backport #120972 to 26.7: MySQL dictionary source: accept `enable_local_infile` only in the configuration file
Related: #112070
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
A MySQL dictionary source created with a
CREATE DICTIONARYquery can no longer enableenable_local_infile, at the source or at one of itsREPLICAentries; loading such a dictionary fails withBAD_ARGUMENTS, which with the defaultdictionaries_lazy_loadis on first use rather than atCREATE. AREPLICAthat does not set the key inherits the source's value, as the connection pool does. To keep the option, define the dictionary in a server configuration file;enable_local_infile 0, and aSOURCE(MYSQL(NAME ...))reference to a named collection where the key was never read, are unaffected.Description
Completes #112070's guard for a sibling key in the same list.
#112070 established that a dictionary created with a DDL query may not name files for the server to open, since the server reads them with its own privileges, and implemented that as
checkNoSSLPathsoverssl_ca/ssl_cert/ssl_key.enable_local_infileis in the samedictionary_allowed_keysand meets that premise another way: it setsMYSQL_OPT_LOCAL_INFILE, letting the endpoint a dictionary points at ask the client for the contents of a file of its choosing. It is off by default for that reason (mysqlxx/Connection.h, since 33205bb), and was not considered there.Change. A new
checkNoLocalInfile, at the two prefixes the pool reads for a DDL-created dictionary: each<replica>and the single-endpoint one. It resolves the value inPool::Pool's order, a replica winning over the parent as its fallback, so what is rejected is the value the connection would use: a truthy parent whose every replica sets0stays accepted, since only per-replica pools exist when replicas do. Configuration-file dictionaries keep working, as in #112070.socket, the other key naming a path a query chooses, is deliberately not mirrored: aconnect(2), not a file read. The named-collection route needs none, though only as a precondition: it passes the literal default andMySQLSettingshas nolocal_infile, so the key is accepted and never read. Add such a setting, as #103229 did forenable_compression, and it needs the guard too. Happy to drop the option outright instead, if you prefer.Validation. New
05229_mysql_dictionary_enable_local_infilecovers the four shapes that enable the option and the two that do not, 50/50 green with randomized settings. A newtest_dictionaries_mysqlarm proves a configuration-file dictionary still loads and serves data with the option on. Every arm is pinned by a distinct mutation;test_storage_mysql'ssslarms stay green.Workflow [PR]
Sync PR [sync-upstream/pr/120972]
Version info
26.10.1.401-master(included in26.10and later)26.9.2.6,26.8.11.12,26.7.14.47,26.3.33.149