Skip to content

Commit d4746d5

Browse files
author
Mark Friedenbach
committed
Add a SECURE style flag for ThreadSafeMessageBox, which indicates that the message contains sensitive information. This keeps the message from being output to the debug log by bitcoind. Fixes a possible security risk when starting bitcoind in server mode without the 'rpcpassword' option configured, resulting in the "suggested" password being output to the debug log.
1 parent e8f6d54 commit d4746d5

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/noui.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
static bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& caption, unsigned int style)
1616
{
17+
bool fSecure = style & CClientUIInterface::SECURE;
18+
style &= ~CClientUIInterface::SECURE;
19+
1720
std::string strCaption;
1821
// Check for usage of predefined caption
1922
switch (style) {
@@ -30,7 +33,8 @@ static bool noui_ThreadSafeMessageBox(const std::string& message, const std::str
3033
strCaption += caption; // Use supplied caption (can be empty)
3134
}
3235

33-
LogPrintf("%s: %s\n", strCaption, message);
36+
if (!fSecure)
37+
LogPrintf("%s: %s\n", strCaption, message);
3438
fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
3539
return false;
3640
}

src/qt/bitcoingui.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,9 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
992992
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
993993
{
994994
bool modal = (style & CClientUIInterface::MODAL);
995+
// The SECURE flag has no effect in the Qt GUI.
996+
// bool secure = (style & CClientUIInterface::SECURE);
997+
style &= ~CClientUIInterface::SECURE;
995998
bool ret = false;
996999
// In case of modal message, use blocking connection to wait for user to click a button
9971000
QMetaObject::invokeMethod(gui, "message",

src/rpcserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ void StartRPCThreads()
581581
strWhatAmI,
582582
GetConfigFile().string(),
583583
EncodeBase58(&rand_pwd[0],&rand_pwd[0]+32)),
584-
"", CClientUIInterface::MSG_ERROR);
584+
"", CClientUIInterface::MSG_ERROR | CClientUIInterface::SECURE);
585585
StartShutdown();
586586
return;
587587
}

src/ui_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class CClientUIInterface
6363
/** Force blocking, modal message box dialog (not just OS notification) */
6464
MODAL = 0x10000000U,
6565

66+
/** Do not print contents of message to debug log */
67+
SECURE = 0x40000000U,
68+
6669
/** Predefined combinations for certain default usage cases */
6770
MSG_INFORMATION = ICON_INFORMATION,
6871
MSG_WARNING = (ICON_WARNING | BTN_OK | MODAL),

0 commit comments

Comments
 (0)