fix(console): redact secret-bearing commands from the console echo and history (W7-1)
The RPC console echoed and stored typed commands verbatim, so `walletpassphrase <secret>`, `z_importkey <key>`, `encryptwallet <pass>` etc. left the secret in the visible log AND the 100-entry recall history (copyable). Adds a pure, unit-testable RedactConsoleCommand()/ConsoleCommandCarriesSecret() (allowlist of 13 secret-bearing first-tokens) in console_tab_helpers; submitConsoleCommand() now echoes and stores `> walletpassphrase ****` while still executing the real command unredacted. Bare secret commands and non-secret commands pass through unchanged. Output-secret commands (dumpprivkey / z_exportkey / z_exportmnemonic) — whose secret is in the RESULT — are a separate redaction concern, tracked as a follow-up. First fix in the wallet-hardening P0-A cluster (see docs/wallet-hardening.md). New testConsoleSecretRedaction (11 assertions); ctest 1/1. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1416,8 +1416,11 @@ bool ConsoleTab::submitConsoleCommand(ConsoleCommandExecutor& exec, const std::s
|
||||
{
|
||||
if (cmd.empty()) return false;
|
||||
|
||||
addLine("> " + cmd, ConsoleChannel::Command);
|
||||
AppendConsoleHistory(command_history_, cmd, 100);
|
||||
// Redact secret-bearing commands (walletpassphrase, z_importkey, …) before they reach the visible
|
||||
// log and the recall history. The real `cmd` below is still executed unredacted.
|
||||
const std::string display = RedactConsoleCommand(cmd);
|
||||
addLine("> " + display, ConsoleChannel::Command);
|
||||
AppendConsoleHistory(command_history_, display, 100);
|
||||
history_index_ = -1;
|
||||
|
||||
// First token, lowercased, for built-in interception.
|
||||
|
||||
Reference in New Issue
Block a user