What changed, and why it matters
This Monero wallet command-line patch adds or moves idle locks around several account, address, and output commands. The goal appears to be preventing the wallet's background refresh thread from running at the same time as these commands, which could otherwise read or modify wallet state while it is being updated. The commit message frames it as serialization with refresh, not as a security fix. There is no direct evidence in the diff of an exploitable vulnerability, crash, or incorrect balance/address result, but missing or misplaced locks are a classic source of race-condition bugs.
Treat as a hardening/reliability fix rather than a confirmed vulnerability. Review whether other simplewallet commands that read or mutate subaddress accounts, labels, tags, or transfer lists also need `LOCK_IDLE_SCOPE()`. Add regression tests or a code comment explaining the locking invariant. If a concrete race-induced bug was observed, file and reference a bug report.
Security signals we found
Addition/movement of idle-scope locking around wallet state mutations and reads
Replacement of a potentially re-locking balance call with an unlocked variant inside a held lock
Serialization of CLI commands with the background refresh thread
Evidence from the diff
The change wraps wallet2 calls in LOCK_IDLE_SCOPE() (which pauses the background refresh thread) in simple_wallet::unspent_outputs, account subcommands (add/switch/label/tag/tag_description), and print_address. It also replaces show_balance() with show_balance_unlocked() inside a locked scope. The pattern suggests the author noticed that these commands could interleave with the idle refresh loop, potentially causing data races or inconsistent reads. The patch is small and partial: it does not document a specific bug, add tests, or explain why these particular commands were chosen.
Changed components
src/simplewallet/simplewallet.cppsimple_wallet::unspent_outputssimple_wallet::accountsimple_wallet::print_addresswallet2 background refresh synchronizationInspect captured patch +12 / −4
### src/simplewallet/simplewallet.cpp
@@ -9049,7 +9049,10 @@ bool simple_wallet::unspent_outputs(const std::vector<std::string> &args_)
}
}
tools::wallet2::transfer_container transfers;
- m_wallet->get_transfers(transfers);
+ {
+ LOCK_IDLE_SCOPE();
+ m_wallet->get_transfers(transfers);
+ }
std::map<uint64_t, tools::wallet2::transfer_container> amount_to_tds;
uint64_t min_height = std::numeric_limits<uint64_t>::max();
uint64_t max_height = 0;
@@ -9379,10 +9382,10 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
std::string label = boost::join(local_args, " ");
if (label.empty())
label = tr("(Untitled account)");
+ LOCK_IDLE_SCOPE();
m_wallet->add_subaddress_account(label);
m_current_subaddress_account = m_wallet->get_num_subaddress_accounts() - 1;
// update_prompt();
- LOCK_IDLE_SCOPE();
print_accounts();
}
else if (command == "switch" && local_args.size() == 1)
@@ -9394,14 +9397,15 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
fail_msg_writer() << tr("failed to parse index: ") << local_args[0];
return true;
}
+ LOCK_IDLE_SCOPE();
if (index_major >= m_wallet->get_num_subaddress_accounts())
{
fail_msg_writer() << tr("specify an index between 0 and ") << (m_wallet->get_num_subaddress_accounts() - 1);
return true;
}
m_current_subaddress_account = index_major;
// update_prompt();
- show_balance();
+ show_balance_unlocked();
}
else if (command == "label" && local_args.size() >= 1)
{
@@ -9417,8 +9421,8 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
std::string label = boost::join(local_args, " ");
try
{
- m_wallet->set_subaddress_label({index_major, 0}, label);
LOCK_IDLE_SCOPE();
+ m_wallet->set_subaddress_label({index_major, 0}, label);
print_accounts();
}
catch (const std::exception& e)
@@ -9443,6 +9447,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
}
try
{
+ LOCK_IDLE_SCOPE();
m_wallet->set_account_tag(account_indices, tag);
print_accounts(tag);
}
@@ -9467,6 +9472,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
}
try
{
+ LOCK_IDLE_SCOPE();
m_wallet->set_account_tag(account_indices, "");
print_accounts();
}
@@ -9487,6 +9493,7 @@ bool simple_wallet::account(const std::vector<std::string> &args/* = std::vector
}
try
{
+ LOCK_IDLE_SCOPE();
m_wallet->set_account_tag_description(tag, description);
print_accounts(tag);
}
@@ -9568,6 +9575,7 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
// address label <index> <label text with white spaces allowed>
// address device [<index>]
+ LOCK_IDLE_SCOPE();
std::vector<std::string> local_args = args;
tools::wallet2::transfer_container transfers;
m_wallet->get_transfers(transfers);Why this scored 32/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.