Skip to content

Core SQL test harness: do not write the password to the invocation log - #624

Merged
ccoltx merged 1 commit into
masterfrom
polyglot/core-sql-redact-password
Nov 19, 2026
Merged

ccoltx merged 1 commit into
masterfrom
polyglot/core-sql-redact-password

Conversation

@polyglotAI-bot

@polyglotAI-bot polyglotAI-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Description

The core SQL test harness (tests/clickhouse-test-runner/, merged in #621) appends a record of each invocation to the file of CLICKHOUSE_CLIENT_CLI_LOG. The first record is the command line, so the value of --password went into the file in clear. In CI the file is upstream-run.log, and the workflow uploads it as an artifact when a shard fails. GitHub masks secrets only in the console output, not in artifacts.

Nothing leaks today: the CI jobs connect as the passwordless default user of a local container. The leak starts on the first run against a server with a password. ClickHouse Product Security found this in the ODBC harness: ClickHouse/clickhouse-odbc#624 (comment). The C++ shim has the same problem.

The change is in the harness only. The library (clickhouse/) and the CI workflow do not change.

Changes

  • RedactPassword (args.cpp) returns the command line with each password value replaced by ***: --password X gives --password ***, --password=X gives --password=***. A last --password with no value stays as it is. It reads the options with the option table of ParseArgs, so it also finds the value after an option that takes --password as its own value: in -u --password --password X, -u takes the first --password, and X is the password. A setting (--max_threads) never takes an argument that starts with -, so its value needs no rule. Unlike ParseArgs, the function does not stop at --, so a password after -- is also hidden.
  • RunMain (shim.cpp) logs the result of RedactPassword in place of the raw arguments.
  • The other records (address, statements, error) have no password. The live test checks the full log.
  • README: the row of CLICKHOUSE_CLIENT_CLI_LOG says that the --password value is hidden.

Tests

  • RedactPassword.HidesThePasswordOnly (unit): --user u --password secret --password=secret2 --query 'SELECT 1' --password gives --user u --password *** --password=*** --query 'SELECT 1' --password. The command lines in which an option takes --password as its value (-u, --host), or a setting comes before --password (--max_threads, --max_threads -1), are checked against the password that ParseArgs reads. Contrast: the value of another option stays (-u --password x, --host --password=x).
  • Live.LogHidesPassword (live, shard 1 of CI): two runs, one with --password <value> and one with --password=<value>, against the server, with CLICKHOUSE_CLIENT_CLI_LOG set to a new temporary file. The log must not contain either value, and must contain --password *** and --password=***. The test checks only the log: the server 26.10 refuses a password for the passwordless default user (AUTHENTICATION_FAILED), so the error record (the server's error text) is also in the checked log. The test restores the earlier value of CLICKHOUSE_CLIENT_CLI_LOG. Without the fix, its four checks fail.
  • Local, with the server of the pinned version (26.10.4.207): 53/53 unit and live tests with Clang 18 and with GCC 13 (-Werror). clang-format --dry-run --Werror (18.1.8) is clean. The real program logs --host localhost -u --password --password *** -q SELECT 1 and --password=*** -q SELECT 1.

Reference: the same fix in the C# harness (InvocationLog.RedactPassword, ClickHouse/clickhouse-cs) and in the ODBC harness (ClickHouse/clickhouse-odbc#624, commit 036de6e).

🤖 Generated with Claude Code


Note

Low Risk
Test-harness logging change only; narrows secret exposure in CI artifacts without altering client connection behavior.

Overview
The SQL test shim (tests/clickhouse-test-runner) no longer writes cleartext --password values into CLICKHOUSE_CLIENT_CLI_LOG, which CI uploads as an artifact when shards fail.

A new RedactPassword helper mirrors the harness’s option parsing so both --password secret and --password=secret are logged as ***, including edge cases where another flag consumes --password as its value. RunMain now logs the redacted argv string instead of the raw command line, and the README documents the behavior.

Coverage adds a unit test for redaction rules and a live test that asserts the log file never contains the password strings.

Reviewed by Cursor Bugbot for commit 0143e68. Bugbot is set up for automated code reviews on this repo. Configure here.

The log of CLICKHOUSE_CLIENT_CLI_LOG had the command line with the value
of --password in clear. CI uploads this log (upstream-run.log) as an
artifact when a shard fails. The CI jobs use the passwordless default
user, but a run against a server with a password would write the
password to the artifact.

RedactPassword (args.cpp) gives the command line with each --password
value replaced by ***. It reads the options as ParseArgs does, so it
finds the value also after an option that takes --password as its own
value (-u --password --password X). The other records of the log
(address, statements, errors) have no password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@polyglotAI-bot
polyglotAI-bot requested review from a team and slabko as code owners November 19, 2026 14:37

@security-ai-gate-reviewer security-ai-gate-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved by the AI review gate on 0143e68. Details in the approver's comment on this pull request.

@security-ai-gate-reviewer

Copy link
Copy Markdown

AI review gate — auto-approved

0143e68fa7bd is approved by security-ai-gate-reviewer[bot], an automated identity, not a human. The approval stands on the required AI review: Cursor Bugbot concluded green on this commit and the AI review gate is SUCCESS (its own comment has the verdict), and the change touches no path that requires a human reviewer. It is bound to this commit: a new push dismisses it and the approver re-evaluates.

History (latest 5 heads, newest first)

  • 0143e68fa7bd approved — green: Cursor Bugbot

@ccoltx
ccoltx merged commit 1f77b54 into master Nov 19, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants