Repository navigation
Do not log the raw query text in the Arrow Flight and gRPC servers - #125716
alexey-milovidov merged 3 commits into
Conversation
The native protocol logs a query only in `executeQuery`, from `formatForLogging`, which hides secret arguments. The Arrow Flight server additionally logged the raw request before running it: `FlightDescriptor::ToString` (whose `cmd` is the SQL text or a Flight SQL protobuf carrying it), the ticket (the SQL text when it is not a generated `~TICKET-` id), and `FlightInfo`, `PollInfo` and the `CancelFlightInfo` request, which embed that descriptor. gRPC's `getQueryDescription` logged the first 64 characters of the query. So a password in `CREATE USER ... IDENTIFIED BY`, a storage key in `s3` or `disk` arguments, or an `encrypt` key was written to the server log and `system.text_log` in plain text, even for a query that was then rejected. These lines now print only identifiers generated by the server (a prefix and a UUID, checked by form), the compiled-in name of a known Flight SQL command (never the client's type URL), a table path, or the size of anything else. gRPC prints the query size. Found by the protocol randomization of the stress test in ClickHouse#125517, where the test-only masking rule `Detect passwords in tests` aborted the server on the `DoPut is called for descriptor` line while `05340_custom_disk_error_hides_secrets` ran over Arrow Flight: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125517&sha=c1a332dfdd920abb5ceb3e4919fd6afe6eba0b72&name_0=PR&name_1=Stress%20test%20%28arm_debug%29 ClickHouse#125517 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; 9 findings over 6 rounds) plus my own review. Bounce cap reached: published as is. The fix for row 9 was checked by my own review and a mutation run, not by another second-model round. Residual findings are listed below (only the nit in row 11).
Severity: ❌ blocker / |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261013-224600 |
|
Workflow [PR], commit [d56e423] Summary: ✅
AI ReviewSummaryThe PR prevents Arrow Flight and gRPC protocol logs from exposing SQL secrets by logging safe identifiers, known command names, and payload sizes. The earlier Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested. |
The field names of a query result are its projection names. The analyzer
hides secret arguments in them unless secrets display is enabled (server
setting `display_secrets_in_show_and_select`, query setting
`format_display_secrets_in_show_and_select` and the
`displaySecretsInShowAndSelect` privilege), in which case
`GetSchema returns schema` wrote, for example, the key of
`encrypt('aes-128-ecb', 'plaintext', '<key>')` to the server log. Showing
secrets in a result must not put them in the log, so this line now prints
only the number of fields.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
In the DBReplicated job the two extra servers get no gRPC port override, so all three listen on 9100 and the kernel spreads the connections between them. When the query runs on a replica, the main server's `text_log`, which the test reads, has no line for it, and the test fails with `0` instead of `1`. The server logs of the failing runs show the query on `clickhouse-server1` or `clickhouse-server2` every time: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125716&sha=eb582abf613dbb60daa95ab8d32ea7d168f9e482&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%201%2F2%29 Co-Authored-By: Claude Opus 5.5 <[email protected]>
7c7053a
Related: #125517
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed the Arrow Flight interface writing the text of each query, including secrets such as
IDENTIFIED BYpasswords and storage keys, to the server log andsystem.text_log. The gRPC interface did the same for the first 64 characters of each query. Now queries from these interfaces are logged only with their secrets hidden.Description
On 26.3.42.3 and 26.8.18.2, a query sent over Arrow Flight is logged at the
informationlevel with its secrets in plain text:DoPut is called for descriptor <FlightDescriptor cmd='CREATE USER ... IDENTIFIED BY '<password>''>. gRPC logs the first 64 characters of each query at thedebuglevel. Found by the protocol randomization in #125517:Stress test (arm_debug)aborted on the test ruleDetect passwords in testswhile05340_custom_disk_error_hides_secretsran over Arrow Flight (report).Root cause: the native protocol logs a query only in
executeQuery, fromformatForLogging, which hides secret arguments. The Arrow Flight server also logs the rawFlightDescriptor, ticket,FlightInfo,PollInfoandCancelFlightInforequest (nine lines), and gRPC'sgetQueryDescriptionlogs a raw query prefix. With secrets display on,GetSchemalogged secrets in field names.Change: these lines now print only identifiers in the form the server generates (
~TICKET-<uuid>,~POLL-<uuid>), the compiled-in name of a known Flight SQL command, a table path, or the size of anything else;GetSchemaprints the field count. gRPC prints the query size.Not changed: HTTP's
Request URItrace line masks query-string values by parameter name only, so a?query=value is still printed there.Validation: with the CI masking rule, the master binary aborts on both lines and the fixed one does not. An integration test in
test_arrowflight_interfacechecks each line's new form and that the secret is absent, also with secrets display on; the stateless05394_grpc_query_text_is_not_loggedchecks the gRPC line andsystem.text_log. Both fail on master and pass with the fix (10 repeats, 50 randomized runs).🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125716]
Version info
26.10.1.2452-master(included in26.10and later)