take m_daemon_rpc_mutex in wallet2::get_daemon_address
What changed, and why it matters
This commit fixes a thread-safety bug in the Monero wallet. A function that reads the daemon's network address (get_daemon_address) was accessing shared data without holding a lock, while other parts of the code can change that same data under a mutex. The fix adds the missing lock and makes the mutex 'mutable' so it can be locked even in functions that promise not to modify anything. In practice this could lead to race conditions such as reading a partially updated or inconsistent daemon address, which might cause the wallet to connect to the wrong node or behave unpredictably. There is no direct evidence in the commit of an exploitable security outcome such as remote code execution or theft of funds.
Treat as a low-to-moderate reliability/concurrency fix. Review other const accessors in wallet2 that touch daemon-related state to ensure they also hold m_daemon_rpc_mutex. No emergency response is warranted based on the diff alone, but include in the next maintenance release.
Security signals we found
missing lock/synchronization on shared state
data race on m_daemon_address
const-correctness fix for mutex (mutable)
defensive concurrency hardening
Evidence from the diff
wallet2::get_daemon_address() now acquires m_daemon_rpc_mutex before returning m_daemon_address. The mutex is declared mutable so it can be locked inside a const method. The change addresses a data race where m_daemon_address could be read concurrently with writes protected by the same mutex elsewhere. The patch is minimal and defensive; it does not by itself demonstrate a reachable exploit, but removes a concurrency hazard that could produce torn reads, stale values, or logic errors in daemon selection.
Changed components
src/wallet/wallet2.cppsrc/wallet/wallet2.hwallet2::get_daemon_addressm_daemon_rpc_mutexInspect captured patch +2 / −1
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index c128eda..16504e3 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -12667,6 +12667,7 @@ std::string wallet2::get_keys_file() const
std::string wallet2::get_daemon_address() const
{
+ boost::lock_guard lock(m_daemon_rpc_mutex);
return m_daemon_address;
}
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index e310d64..816fbc4 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -1659,7 +1659,7 @@ private:
std::atomic<bool> m_run;
- boost::recursive_mutex m_daemon_rpc_mutex;
+ mutable boost::recursive_mutex m_daemon_rpc_mutex;
bool m_trusted_daemon;
i_wallet2_callback* m_callback;
Why this scored 35/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.