Repository navigation
Conversation
`nats_url`, `rabbitmq_address` and `after_processing_move_connection_string` are masked by searching their String value for the credential, and so are `format_avro_schema_registry_url`, `url_base` and `s3_base` in `CoreSettings::renderSecretSettingValue`. Since ClickHouse#119028 a value of another type was taken to carry no secret, so a `Map` literal such as `SETTINGS nats_url = {'u':'nats://user:secret@host:4222'}` was formatted verbatim into `system.query_log`, `system.text_log` and the server log before the setting rejected it. Such a value is now hidden whole, as `DEFAULT_MASKING_RULE` and the engine-argument form of these settings already do. None of these settings accepts a non-String value, so only the text of statements that are rejected anyway changes; `nats_url = 4222` in 05153 is now `'[HIDDEN]'`. The rejection context added by ClickHouse#116882 ("while setting '<name>' to value <v>") rendered a composite value with `FieldVisitorToString` and masked only `scheme://user:password@`, so an Azure `AccountKey=` or a scheme-less NATS userinfo inside a `Map` still reached `query_log.exception`. It now names only the type of an Array, Tuple, Map, Object, AggregateFunctionState or CustomType value. 05153 gains a SET arm for each of the six settings that checks the server's own executeQuery log line, which carries both the query text and the exception, for the credential. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`formatValueForErrorMessage` names only the type of an Array, Tuple or Map value, but 05153 sent only a Map literal, so dropping the Array or the Tuple case kept it green. Neither literal parses in `SET`, while a typed query parameter reaches the setting as a real Array or Tuple value. Part 5 sends all three that way to `url_base` and checks the logged query text, the type-only error text and that the credential appears nowhere in the server's own log line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A `NumberLiteral` holds the unparsed text of a number literal, and the AST JSON dialect builds one from any `Number_<text>` dump. `formatValueForErrorMessage` rendered it with `FieldVisitorToString`, which returns that text as is, so "while setting 'url_base' to value ..." echoed a credential that the logged statement itself hides. It now names only the type, as for the other values that are not plain scalars. The SQL parser does not produce a `NumberLiteral`, so no SQL statement's error text changes. 05153 part 5 also sends a `disk(...)` value (a `CustomType`) in SQL and a number literal in the AST JSON dialect to `url_base`, and checks that each is hidden in the logged query, is named only by its type in the error, and leaves the credential nowhere in the server's own log line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`DiskConfigurationMasker` keeps the `type`, `disk` and `name` arguments of a `disk(...)` visible, and `CoreSettings::renderSecretSettingValue` returned that partial rendering before its branch that hides a value that is not a String whole, so `SET url_base = disk(type = '<credential>', ...)` was logged with the credential in it. `renderSecretChangeValue` also asked the Core renderer before the engine rules, so the same partial rendering answered for `nats_url`, `rabbitmq_address`, `after_processing_move_connection_string` and every other engine setting, whose rules all hide a value that is not a String whole. `renderSecretSettingValue` now hides a non-String value of `format_avro_schema_registry_url`, `url_base` and `s3_base` whole before it looks at a `disk(...)`, and `renderSecretChangeValue` asks the engine rules first. Engine setting names and the three Core names do not overlap, so the new order only changes a secret `disk(...)` value of an engine setting. A `disk(...)` value of any other setting, such as `SETTINGS disk = disk(...)`, is masked as before. 05153 part 5 now puts the canary in the `type` argument of the `disk(...)` arm, and sends the same value to `nats_url`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… rule as one early return `formatValueForErrorMessage` listed the `Field` types it names only by type in a switch whose `default:` echoed every other value, so a `Field` type added later would be echoed verbatim. That list is exactly the set `Field::isScalar` classifies as not a plain scalar, and `isScalar` has no default, so a new type must be classified there before it compiles. The echo now asks `isScalar`. `CoreSettings::renderSecretSettingValue` gets its one new rule (a value that is not a String, of `format_avro_schema_registry_url`, `url_base` or `s3_base`, is hidden whole) as an early return in front of the unchanged function instead of a restructured body. Both changes keep the behavior; 05153 and its reference are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The queue engines take each of their settings with the legacy `s3queue_` prefix as well (`adjustSettingName` strips it before the settings are applied), but the engine masking rules were looked up by the name as written. So a value of `s3queue_after_processing_move_connection_string` or `s3queue_after_processing_move_secret_access_key`, a String included, was logged in cleartext, and `SHOW CREATE TABLE` of a table created with that spelling printed it. `renderSecretChangeValue` now drops the prefix before the engine-rule lookup. The Core lookup keeps the written name: no Core setting starting with `s3queue_` is in an engine map. Part 4 of 05153 sends a Map to both legacy names. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ue_` prefix The queue engine settings include every format setting, and `adjustSettingName` strips the legacy `s3queue_` prefix from any of them. `format_avro_schema_registry_url` is one, and it is masked by the Core rule, but only the engine-rule lookup dropped the prefix. So a value of `s3queue_format_avro_schema_registry_url` matched no rule: it was logged in cleartext, and `SHOW CREATE TABLE` of a queue table created with that spelling printed it. `renderSecretChangeValue` now gives the unprefixed name to the Core lookup too. The Core settings that start with `s3queue_` strip to names that are in no masking map, so they stay unmasked. Part 4 of 05153 sends a Map to `s3queue_format_avro_schema_registry_url`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the two comments on the lookup order in renderSecretSettingValue and renderSecretChangeValue to one line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 6 rounds, 5 findings), plus my own cold review of the diff.
Severity: ❌ blocker / Bounce cap reached (5 + 1 fix rounds): published as is. The row 10 fix, made in the final round, was verified by my review of the final diff and by its test arm failing on the previous head, without a seventh gate run. Rows 5, 6 and 9 are noted, not blocking. Session id: cron:clickhouse-review-slot-8:20260930-013227 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260929-165500 |
|
Workflow [PR], commit [3dddb1a] Summary: ✅
AI ReviewSummaryThis PR closes the non- Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit 3dddb1a.
Changed lines: Changed C/C++ lines covered: 30/30 (100.00%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units16 translation units recompiled, 51 s compile time in total, 16 of them have a recent master baseline. |
|
This is not a bug that needs to be fixed |
|
Understood, I'll leave it closed. For context, @ evillique asked for this fix on the private report linked in the description. One part does affect a valid statement, though: CREATE TABLE q (a String) ENGINE = S3Queue('http://host/bucket/data/*', NOSIGN, 'CSV')
SETTINGS mode = 'unordered', s3queue_after_processing_move_secret_access_key = 'secret';Do you want only that as a small PR (strip the prefix before the lookup in |
|
@groeneai Yes, that's a different issue than an obscure "if you put a map value in a string setting". Please open a PR specific to that problem |
|
Acknowledged. I'll open a separate PR for only the legacy |
|
I opened #123060 for only the legacy |
`S3Queue` and `AzureQueue` accept every setting with the legacy `s3queue_` prefix: `ObjectStorageQueueSettings::loadFromQuery` renames the setting through `adjustSettingName`, which strips the prefix from any name, and `alter()` does the same. The masking of a `SETTINGS` clause looks the rule up by the name as written, and every rule is keyed on the canonical name, so a secret written as `s3queue_after_processing_move_secret_access_key`, `s3queue_after_processing_move_connection_string` or `s3queue_format_avro_schema_registry_url` matched no rule and was printed in cleartext by `SHOW CREATE TABLE`, `system.tables` and, through `hasSecretParts`, `system.query_log` and the server log. `renderSecretChangeValue` now drops the prefix once and gives the unprefixed name to both the query-level rules and the engine rules. No key of any masking map starts with `s3queue_`, and the four query-level settings that do (`s3queue_default_zookeeper_path`, `s3queue_migrate_old_metadata_to_buckets`, `s3queue_enable_logging_to_s3queue_log`, `s3queue_keeper_fault_injection_probability`) strip to names no map holds, so the only changes that render differently are the `s3queue_`-prefixed spellings of a masked name. Requested in ClickHouse#122997 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: https://github.com/ClickHouse/clickhouse-private/issues/74204
Related: #119028
Related: #116882
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a credential leak in
system.query_log,system.text_logand the server log: aMapor other non-Stringvalue ofnats_url,rabbitmq_address,after_processing_move_connection_string,format_avro_schema_registry_url,url_baseors3_basewas logged in cleartext before the statement was rejected. Such a value is now hidden whole, and the error rejecting aMap,ArrayorTuplevalue names only its type. A queue setting written with the legacys3queue_prefix is now masked as well.Description
On 26.8.10.6,
CREATE TABLE t (a String) ENGINE = NATS SETTINGS nats_url = {'u':'nats://user:secret@host:4222'}, ...is rejected, butsecretis written tosystem.query_logand the server log in cleartext. On master the same holds forSET url_base = {...},ALTER TABLE ... MODIFY SETTINGand the other settings above.The rules that mask inside the value took any non-
Stringvalue to mean "no secret", so the formatter printed the rawMap. The rejection message added by #116882 (master only) also echoed theMapwith onlyscheme://user:password@masked, so an AzureAccountKey=stayed visible inquery_log.exception.Now the three engine rules and
CoreSettings::renderSecretSettingValuehide such a value whole, as the whole-value rules already do, including adisk(...)value (its own masking keepstype, so the engine rules are now asked first). The rejection message names only the type of a value that is not a plain scalar. All six settings areStringorURI, so such a literal is always rejected; hencenats_url = 4222in05153is now logged as'[HIDDEN]'.The queue engines also accept each setting with the legacy
s3queue_prefix, which the lookup did not strip: on master an acceptedCREATE TABLE ... SETTINGS s3queue_after_processing_move_secret_access_key = '...'is logged and shown bySHOW CREATE TABLEin cleartext. The prefix is now dropped first.Validation:
05153_settings_masking_non_string_valuegains aSETarm per setting and legacy spelling, plusMap,ArrayandTuplequery-parameter,disk(...)and AST JSONNumberarms, each checking the server's log line for the query and the error. It fails on master with the exact inverse diff and passes with the fix (50/50 randomized); the other masking tests and parser unit tests pass.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/122997]