Skip to content

[Qt][RPC] Hide passphrases in debug console history #8746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,16 @@ void RPCConsole::on_lineEdit_returnPressed()

if(!cmd.isEmpty())
{
message(CMD_REQUEST, cmd);
Q_EMIT cmdRequest(cmd);
// Remove passphrases from history
QStringList cmdList = cmd.split(' ');
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, splitting on ' ' is not enough here. Arguments can contain spaces if they're surrounded with ' or ". E.g. walletpassphrase "my voice is my password verify me"

Copy link
Member Author

Choose a reason for hiding this comment

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

That doesn't matter since only the command (first in the list) and the timeout (last in the list) are actually needed. Anything else in between doesn't matter.

Copy link
Member

Choose a reason for hiding this comment

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

Sure. What I'm afraid of is that in the future someone is bound to add a command for which this is not true. The handling per command is a bit brittle.

So I'd prefer these commands to not be added to history in the first place.

if(cmdList.first() == "walletpassphrase")
cmd = cmdList.first() + " **PASSPHRASE** " + cmdList.back();
else if(cmdList.first() == "walletpassphrasechange")
cmd = cmdList.first() + " **OLDPASSPHRASE** **NEWPASSPHRASE**";
else if(cmdList.first() == "encryptwallet")
cmd = cmdList.first() + " **PASSPHRASE**";
message(CMD_REQUEST, cmd);
// Remove command, if already in history
history.removeOne(cmd);
// Append command to history
Expand Down