Repository navigation
Clear --jwt and the other credential options from the command line of clickhouse-client and clickhouse-keeper-client - #131963
Conversation
`clearPasswordFromCommandLine` zeroed only `--password VALUE` and `--password=VALUE` in argv. The credential options added to clickhouse-client later (`--ssh-key-passphrase`, `--jwt`, `--one-time-password`, `--oauth-client-secret`) were never added to it, and clickhouse-keeper-client (`--password`, `--identity user:password`) never called it, so these values stayed readable by every local user in `ps` and `/proc/<pid>/cmdline` for the whole run (measured on 26.10.2.103 and 26.8.37.168 for `--jwt`). The function now zeroes the values of a fixed list of credential options, in the `--option value` and `--option=value` forms, exact names only. A shared list is safe because every caller rejects an unknown option during parsing, before the call. The scan goes from the last argument to the first without skipping: the client turns a `--password` followed by `-...` into ask-password, so in `--password --jwt TOKEN` the "value" of `--password` is `--jwt`, and the old forward scan zeroed it, skipped it and left TOKEN visible. Backwards, each argument is matched on its original text before the argument to its left can zero it. clickhouse-keeper-client calls the function after `init`, where Poco has already bound the option values into its configuration. All values are consumed from copies made during parsing, so only the `ps` view changes. Not covered, as for `--password` before: a password inside a connection string, abbreviated option names, and Poco's `--option:value` spelling. Closes: ClickHouse#131191 Co-Authored-By: Claude Opus 5.5 <[email protected]>
clickhouse-client fuses `--option = value` (three arguments) into `--option=value`, so `--jwt = TOKEN` and `--password = SECRET` are accepted, but only the lone `=` was zeroed and the value stayed visible in `ps`. When the argument after an exact credential option name is `=` and one more argument follows (the client's own fusion condition), that next argument is zeroed instead. Poco, used by clickhouse-keeper-client, also accepts `:` as the long-option delimiter, so `--password:SECRET` and `--identity:user:SECRET` are accepted; the value after `:` is now zeroed like the value after `=`. The boost-based programs reject that spelling before the call. Still not covered: a password inside a connection string, and abbreviated or differently-cased option names. 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; 2 rounds, 2 findings, 0 in the final round) plus my own review.
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-48:20261116-105001 |
|
cc @antonio2368, could you review this? It extends clearPasswordFromCommandLine from |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20261116-103800 |
|
Workflow [PR], commit [42c4337] Summary: ✅
AI ReviewSummaryExtends Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units8 translation units recompiled, 15 s compile time in total, 8 of them have a recent master baseline. |
eb82d56
Antalya 26.8 Backport of ClickHouse#131963 - Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
Antalya 25.8 Backport of ClickHouse#131963 - Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
Stable 26.3 Backport of ClickHouse#131963 - Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
Stable 26.8 Backport of ClickHouse#131963 - Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
Antalya 26.3 Backport of ClickHouse#131963 - Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
Stable 25.8 Backport of ClickHouse#131963 - Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
…ptions-from-command-line Clear `--jwt` and the other credential options from the command line of `clickhouse-client` and `clickhouse-keeper-client`
Closes: #131191
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
clickhouse-clientnow clears the values of--jwt,--ssh-key-passphrase,--one-time-passwordand--oauth-client-secretfrom its command line, as it already did for--password, so they are no longer visible inpsand/proc/<pid>/cmdline.clickhouse-keeper-clientnow does the same for--passwordand--identity. Closes #131191.Description
On 26.10.2.103 and 26.8.37.168,
clickhouse-client --jwt <token>keeps the bearer token readable by every local user inps//proc/<pid>/cmdlinefor the whole run, while--passwordis cleared. Thanks to the reporter of #131191 for the analysis.clearPasswordFromCommandLineonly knew--password; the credential options added later were never added to it, andclickhouse-keeper-clientnever called it. It now zeroes the values of a fixed list of credential options (--password,--jwt,--ssh-key-passphrase,--one-time-password,--oauth-client-secret,--identity), given as--option value,--option=valueor--option = value(clickhouse-keeper-clientalso--option:value), exact names only. It scans from the last argument, so the token is still cleared in--password --jwt <token>(--passwordwithout a value).clickhouse-keeper-clientcalls it after parsing its options. The values are consumed from copies made during parsing.clickhouse-benchmark(only--password) andclickhouse-local(no credential options) are unaffected.Not covered, as for
--passwordbefore: a password inside a connection string (clickhouse://user:password@host) and abbreviated or differently-cased option names the parsers also accept (such as--jw <token>, or--PASSWORDinclickhouse-keeper-client). ACLICKHOUSE_JWTenvironment variable, suggested in the issue, is a separate feature and is not added here (-C <file>withjwt: <token>already keeps the token off the command line); I can send it separately.Validation: the new test reads
/proc/<pid>/cmdlineofclickhouse-clientandclickhouse-keeper-clientconnected to a listener that never answers; it prints the secrets on master and passes with the fix (50 runs). Authentication with--password(also--password = <pw>),--ssh-key-passphraseand keeper--identity(also--identity:<user>:<pw>) still works.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131963]
Version info
26.11.1.2469-master(included in26.11and later)