What changed, and why it matters
This patch changes how Monero's command-line wallet holds internal locks while exporting transaction history to a CSV file. Previously, the code briefly released a lock during the export process. The fix keeps the lock held continuously while sensitive wallet data is being written out. The change is defensive and prevents potential race conditions or use of partially-unlocked wallet state during an export that includes private keys.
Treat as a low-to-moderate hardening fix. Review whether any other export/report paths have similar inconsistent locking. No immediate emergency response is indicated, but the fix should be included in the next maintenance release.
Security signals we found
Lock lifetime change covering sensitive file write
Replacement of scoped unlock with explicit optional unlocker
Protection of export_keys code path that handles private key material
Defensive race-condition mitigation in wallet export feature
Evidence from the diff
In simple_wallet::export_transfers(), the original code acquired LOCK_IDLE_SCOPE() only on the non-export_keys branch, while the export_keys branch used SCOPED_WALLET_UNLOCK() and left idle lock management elsewhere. The patch moves LOCK_IDLE_SCOPE() to the top of the function so it covers the entire export, and replaces the scoped SCOPED_WALLET_UNLOCK() with an explicit std::optional
Changed components
src/simplewallet/simplewallet.cppsimple_wallet::export_transfers()CLI wallet export functionalityInspect captured patch +10 / −4
### src/simplewallet/simplewallet.cpp
@@ -42,6 +42,7 @@
#include <iostream>
#include <sstream>
#include <fstream>
+#include <optional>
#include <string_view>
#include <boost/lexical_cast.hpp>
#include <boost/program_options.hpp>
@@ -8832,6 +8833,8 @@ bool simple_wallet::export_transfers(const std::vector<std::string>& args_)
return true;
}
+ LOCK_IDLE_SCOPE();
+
std::vector<transfer_view> all_transfers;
// might consumes arguments in local_args
@@ -8859,12 +8862,15 @@ bool simple_wallet::export_transfers(const std::vector<std::string>& args_)
fail_msg_writer() << tr("command not supported by HW wallet");
return true;
}
- SCOPED_WALLET_UNLOCK();
- } else
- {
- LOCK_IDLE_SCOPE();
}
+ boost::optional<tools::password_container> pwd_container = boost::none;
+ if (export_keys && m_wallet->ask_password() && !(pwd_container = get_and_verify_password()))
+ return true;
+ std::optional<tools::wallet_keys_unlocker> unlocker;
+ if (export_keys)
+ unlocker.emplace(*m_wallet, pwd_container ? &pwd_container->password() : nullptr);
+
std::ofstream file(filename);
if(file.fail()) {
fail_msg_writer() << boost::format(tr("Failed to open %s for writing")) % filename;Why this scored 41/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.