What changed, and why it matters
This update changes the Monero wallet so that two especially sensitive pieces of information—multisig setup data and transaction secret keys—are still shown to the user on screen but are no longer written to the wallet's log files. Before, the same on-screen message routine also saved those messages to disk, which could leave private key material in persistent logs. The patch adds an 'unlogged' message writer and uses it for these two cases, plus adds a test to confirm the behavior.
Users and operators running `monero-wallet-cli` should upgrade to a version containing this commit and review existing log files for accidental retention of multisig info or tx keys, rotating or purging those logs if necessary. Developers should adopt `unlogged_success_msg_writer` for any future sensitive console output.
Security signals we found
Sensitive cryptographic material (multisig key-exchange data, transaction secret keys) removed from persistent log output
New 'unlogged' message writer primitive added to control log exposure
Unit test added to enforce the unlogged behavior
Pull request title explicitly frames change as keeping secrets out of logs
Evidence from the diff
The patch introduces a log_to_file flag in scoped_message_writer and a new helper tools::unlogged_success_msg_writer(). In simplewallet.cpp, prepare_multisig_main and get_tx_key now route their sensitive output through the unlogged writer, preventing MCLOG_FILE from recording the multisig first key-exchange message and the transaction secret key(s) to the msgwriter log file. A unit test verifies that ordinary messages still reach the log while unlogged messages do not.
Changed components
src/common/scoped_message_writer.hsrc/simplewallet/simplewallet.cpptests/unit_tests/logging.cpptests/unit_tests/CMakeLists.txtInspect captured patch +36 / −3
### src/common/scoped_message_writer.h
@@ -53,17 +53,20 @@ class scoped_message_writer
epee::console_colors m_color;
bool m_bright;
el::Level m_log_level;
+ bool m_log_to_file;
public:
scoped_message_writer(
epee::console_colors color = epee::console_color_default
, bool bright = false
, std::string&& prefix = std::string()
, el::Level log_level = el::Level::Info
+ , bool log_to_file = true
)
: m_flush(true)
, m_color(color)
, m_bright(bright)
, m_log_level(log_level)
+ , m_log_to_file(log_to_file)
{
m_oss << prefix;
}
@@ -74,6 +77,7 @@ class scoped_message_writer
, m_oss(rhs.m_oss.str(), std::ios_base::out | std::ios_base::ate)
, m_color(std::move(rhs.m_color))
, m_log_level(std::move(rhs.m_log_level))
+ , m_log_to_file(rhs.m_log_to_file)
{
rhs.m_flush = false;
}
@@ -96,7 +100,8 @@ class scoped_message_writer
m_flush = false;
std::string message = m_oss.str();
- MCLOG_FILE(m_log_level, "msgwriter", message);
+ if (m_log_to_file)
+ MCLOG_FILE(m_log_level, "msgwriter", message);
try { el::base::sanitize(message); }
catch (const std::exception&) { message = "<Invalid UTF-8 in message>"; }
@@ -121,6 +126,11 @@ inline scoped_message_writer success_msg_writer(bool color = true)
return scoped_message_writer(color ? epee::console_color_green : epee::console_color_default, false, std::string(), el::Level::Info);
}
+inline scoped_message_writer unlogged_success_msg_writer(bool color = true)
+{
+ return scoped_message_writer(color ? epee::console_color_green : epee::console_color_default, false, std::string(), el::Level::Info, false);
+}
+
inline scoped_message_writer msg_writer(epee::console_colors color = epee::console_color_default)
{
return scoped_message_writer(color, false, std::string(), el::Level::Info);
### src/simplewallet/simplewallet.cpp
@@ -1230,7 +1230,7 @@ bool simple_wallet::prepare_multisig_main(const std::vector<std::string> &args,
SCOPED_WALLET_UNLOCK_ON_BAD_PASSWORD(return false;);
std::string multisig_info = m_wallet->get_multisig_first_kex_msg();
- success_msg_writer() << multisig_info;
+ tools::unlogged_success_msg_writer(false) << multisig_info;
success_msg_writer() << tr("Send this multisig info to all other participants, then use make_multisig <threshold> <info1> [<info2>...] with others' multisig info");
success_msg_writer() << tr("This includes the PRIVATE view key, so needs to be disclosed only to that multisig wallet's participants ");
@@ -8104,7 +8104,7 @@ bool simple_wallet::get_tx_key(const std::vector<std::string> &args_)
if (found_tx_key)
{
std::string stream = get_tx_key_stream(tx_key, additional_tx_keys);
- success_msg_writer() << tr("Tx key: ") << stream;
+ tools::unlogged_success_msg_writer(false) << tr("Tx key: ") << stream;
return true;
}
else
### tests/unit_tests/CMakeLists.txt
@@ -140,6 +140,9 @@ target_link_libraries(unit_tests
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES}
PkgConfig::libzmq)
+if (EPEE_READLINE)
+ target_link_libraries(unit_tests PRIVATE epee_readline)
+endif()
set_property(TARGET unit_tests
PROPERTY
FOLDER "tests")
### tests/unit_tests/logging.cpp
@@ -36,6 +36,7 @@
#include "gtest/gtest.h"
#include "file_io_utils.h"
#include "misc_log_ex.h"
+#include "common/scoped_message_writer.h"
static std::string log_filename;
@@ -124,6 +125,25 @@ TEST(logging, default)
cleanup();
}
+TEST(logging, unlogged_message_writer)
+{
+ init();
+ mlog_set_categories("msgwriter:INFO");
+
+ testing::internal::CaptureStdout();
+ tools::success_msg_writer(false) << "ordinary message marker";
+ tools::unlogged_success_msg_writer(false) << "unlogged message marker";
+ const std::string output = testing::internal::GetCapturedStdout();
+
+ std::string str;
+ ASSERT_TRUE(load_log_to_string(log_filename, str));
+ EXPECT_NE(std::string::npos, output.find("ordinary message marker"));
+ EXPECT_NE(std::string::npos, output.find("unlogged message marker"));
+ EXPECT_NE(std::string::npos, str.find("ordinary message marker"));
+ EXPECT_EQ(std::string::npos, str.find("unlogged message marker"));
+ cleanup();
+}
+
TEST(logging, all)
{
init();Why this scored 60/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.