Skip to content

Commit 9044908

Browse files
jonasschnelliluke-jr
authored andcommitted
Qt/RPCConsole: Don't store commands with potentially sensitive information in the history
Filters importprivkey, signrawtransaction, walletpassphrase, walletpassphrasechange, and encryptwallet
1 parent fc95daa commit 9044908

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/qt/rpcconsole.cpp

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ const struct {
6363
{NULL, NULL}
6464
};
6565

66+
// don't add private key handling cmd's to the history
67+
const QStringList RPCConsole::historyFilter = QStringList()
68+
<< "importprivkey"
69+
<< "signrawtransaction"
70+
<< "walletpassphrase"
71+
<< "walletpassphrasechange"
72+
<< "encryptwallet";
73+
6674
/* Object for executing console RPC commands in a separate thread.
6775
*/
6876
class RPCExecutor : public QObject
@@ -755,15 +763,26 @@ void RPCConsole::on_lineEdit_returnPressed()
755763

756764
message(CMD_REQUEST, cmd);
757765
Q_EMIT cmdRequest(cmd);
758-
// Remove command, if already in history
759-
history.removeOne(cmd);
760-
// Append command to history
761-
history.append(cmd);
762-
// Enforce maximum history size
763-
while(history.size() > CONSOLE_HISTORY)
764-
history.removeFirst();
765-
// Set pointer to end of history
766-
historyPtr = history.size();
766+
767+
bool storeHistory = true;
768+
Q_FOREACH(QString unallowedCmd, historyFilter)
769+
{
770+
if (cmd.trimmed().startsWith(unallowedCmd))
771+
storeHistory = false; break;
772+
}
773+
774+
if (storeHistory)
775+
{
776+
// Remove command, if already in history
777+
history.removeOne(cmd);
778+
// Append command to history
779+
history.append(cmd);
780+
// Enforce maximum history size
781+
while(history.size() > CONSOLE_HISTORY)
782+
history.removeFirst();
783+
// Set pointer to end of history
784+
historyPtr = history.size();
785+
}
767786
// Scroll console view to end
768787
scrollToEnd();
769788
}

src/qt/rpcconsole.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public Q_SLOTS:
140140
ClientModel *clientModel;
141141
QStringList history;
142142
int historyPtr;
143+
const static QStringList historyFilter;
143144
QString cmdBeforeBrowsing;
144145
QList<NodeId> cachedNodeids;
145146
const PlatformStyle *platformStyle;

0 commit comments

Comments
 (0)