What changed, and why it matters
This Monero wallet patch fixes two related issues. First, it prevents the wallet from ever estimating a ring size of zero, which could have caused fee or transaction-building errors. Second, it tightens a check that validates the number of available spendable outputs reported by a remote daemon, making it harder for a malicious or buggy daemon to trick the wallet with a suspicious output distribution. The changes are defensive hardening rather than a clear remote exploit fix.
Treat as a security-hardening fix and include in the next maintenance release. Users running wallet software built from this repository should update to a build containing this commit. Wallet operators using remote daemons should prioritize the update because the output-distribution check is a daemon-trust boundary control.
Security signals we found
Hardened daemon output-distribution validation against suspicious/malicious rct_offsets
Eliminated zero ring-size fallback that could affect transaction/fee construction
Fixed potential underflow in fee-estimation ring-size calculation
Defensive checks in wallet output selection path
Evidence from the diff
wallet2::get_min_ring_size() now returns 3 instead of 0 as the final fallback, so callers can no longer receive a ring size of 0. The wallet API’s estimateTransactionFee() is updated to use std::max
Changed components
src/wallet/wallet2.cppsrc/wallet/api/wallet.cppwallet2::get_min_ring_size()wallet2::get_outs()WalletImpl::estimateTransactionFee()Inspect captured patch +4 / −3
### src/wallet/api/wallet.cpp
@@ -42,6 +42,7 @@
#include "mnemonics/electrum-words.h"
#include "mnemonics/english.h"
+#include <algorithm>
#include <boost/format.hpp>
#include <cstring>
#include <sstream>
@@ -2006,7 +2007,7 @@ uint64_t WalletImpl::estimateTransactionFee(const std::vector<std::pair<std::str
m_wallet->use_fork_rules(HF_VERSION_PER_BYTE_FEE, 0),
m_wallet->use_fork_rules(4, 0),
1,
- m_wallet->get_min_ring_size() - 1,
+ std::max<uint64_t>(m_wallet->get_min_ring_size(), 1) - 1,
destinations.size() + 1,
extra_size,
m_wallet->use_fork_rules(8, 0),
### src/wallet/wallet2.cpp
@@ -9091,7 +9091,7 @@ uint64_t wallet2::get_min_ring_size()
return 5;
if (use_fork_rules(2, 10))
return 3;
- return 0;
+ return 3;
}
//------------------------------------------------------------------------------------------------------------------------------
uint64_t wallet2::get_max_ring_size()
@@ -9555,7 +9555,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
error::get_output_distribution, "Not enough rct outputs");
THROW_WALLET_EXCEPTION_IF(!std::is_sorted(rct_offsets.begin(), rct_offsets.end()),
error::get_output_distribution, "Daemon reports non-monotonic rct output distribution");
- THROW_WALLET_EXCEPTION_IF(rct_offsets.back() <= max_rct_index,
+ THROW_WALLET_EXCEPTION_IF(rct_offsets[rct_offsets.size() - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE] <= max_rct_index,
error::get_output_distribution, "Daemon reports suspicious number of rct outputs");
}
Why this scored 65/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.