Skip to content

Commit

Permalink
Qt/RPCConsole: Don't store commands with potentially sensitive inform…
Browse files Browse the repository at this point in the history
…ation in the history

Filters importprivkey, signrawtransaction, walletpassphrase, walletpassphrasechange, and encryptwallet
  • Loading branch information
jonasschnelli authored and luke-jr committed Dec 29, 2016
1 parent fc95daa commit 9044908
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ const struct {
{NULL, NULL}
};

// don't add private key handling cmd's to the history
const QStringList RPCConsole::historyFilter = QStringList()
<< "importprivkey"
<< "signrawtransaction"
<< "walletpassphrase"
<< "walletpassphrasechange"
<< "encryptwallet";

/* Object for executing console RPC commands in a separate thread.
*/
class RPCExecutor : public QObject
Expand Down Expand Up @@ -755,15 +763,26 @@ void RPCConsole::on_lineEdit_returnPressed()

message(CMD_REQUEST, cmd);
Q_EMIT cmdRequest(cmd);
// Remove command, if already in history
history.removeOne(cmd);
// Append command to history
history.append(cmd);
// Enforce maximum history size
while(history.size() > CONSOLE_HISTORY)
history.removeFirst();
// Set pointer to end of history
historyPtr = history.size();

bool storeHistory = true;
Q_FOREACH(QString unallowedCmd, historyFilter)
{
if (cmd.trimmed().startsWith(unallowedCmd))
storeHistory = false; break;
}

if (storeHistory)
{
// Remove command, if already in history
history.removeOne(cmd);
// Append command to history
history.append(cmd);
// Enforce maximum history size
while(history.size() > CONSOLE_HISTORY)
history.removeFirst();
// Set pointer to end of history
historyPtr = history.size();
}
// Scroll console view to end
scrollToEnd();
}
Expand Down
1 change: 1 addition & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public Q_SLOTS:
ClientModel *clientModel;
QStringList history;
int historyPtr;
const static QStringList historyFilter;
QString cmdBeforeBrowsing;
QList<NodeId> cachedNodeids;
const PlatformStyle *platformStyle;
Expand Down

0 comments on commit 9044908

Please sign in to comment.