What changed, and why it matters
This commit adds an optional 'all_accounts' flag to two Monero wallet RPC commands: one that lists wallet addresses and one that lists incoming funds. When enabled, the command returns data across every account instead of just one. The change is a feature addition, not a fix for a vulnerability. It does include a minor validation relaxation: if 'all_accounts' is true, the provided account index is ignored rather than checked against the number of accounts. This is intentional and documented by the new tests.
No immediate security action is required. Wallet RPC operators should review whether callers authorized for a single account should be allowed to use the new all_accounts flag, and ensure RPC authentication and access controls remain appropriate now that these endpoints can enumerate all accounts and incoming outputs.
Security signals we found
New optional RPC parameter changes access scope from single account to all accounts
Validation of account_index is skipped when all_accounts is true
RPC API version incremented, signaling a behavioral change
Functional tests explicitly pass account_index=99/subaddr_indices=[999] with all_accounts=true and expect success
Evidence from the diff
The patch extends wallet_rpc_server.cpp to support an all_accounts parameter in get_address and incoming_transfers. For get_address, when all_accounts is set, it iterates every account and every subaddress, populates account_index in the response, and marks addresses as used if any transfer references them. For incoming_transfers, all_accounts bypasses the account/subaddress filter. The request structs gain KV_SERIALIZE_OPT(all_accounts, false) so the field is optional and defaults to false, preserving backward compatibility. The RPC minor version is bumped from 37 to 38. Functional tests verify the new behavior, including that an out-of-range account_index is accepted when all_accounts is true.
Changed components
src/wallet/wallet_rpc_server.cppsrc/wallet/wallet_rpc_server_commands_defs.htests/functional_tests/transfer.pytests/functional_tests/wallet.pyutils/python-rpc/framework/wallet.pyInspect captured patch +70 / −26
### src/wallet/wallet_rpc_server.cpp
@@ -37,6 +37,7 @@
#include <chrono>
#include <cstring>
#include <thread>
+#include <unordered_set>
#include "version.h"
#include "wallet_rpc_server.h"
@@ -759,32 +760,44 @@ namespace tools
if (!m_wallet) return not_open(er);
try
{
- THROW_WALLET_EXCEPTION_IF(req.account_index >= m_wallet->get_num_subaddress_accounts(), error::account_index_outofbound);
+ const size_t account_count = m_wallet->get_num_subaddress_accounts();
+ THROW_WALLET_EXCEPTION_IF(!req.all_accounts && req.account_index >= account_count, error::account_index_outofbound);
res.addresses.clear();
- std::vector<uint32_t> req_address_index;
- if (req.address_index.empty())
- {
- for (uint32_t i = 0; i < m_wallet->get_num_subaddresses(req.account_index); ++i)
- req_address_index.push_back(i);
- }
- else
- {
- req_address_index = req.address_index;
- }
tools::wallet2::transfer_container transfers;
m_wallet->get_transfers(transfers);
- for (uint32_t i : req_address_index)
+ std::unordered_set<cryptonote::subaddress_index> used_addresses;
+ if (req.all_accounts)
+ for (const auto& td : transfers)
+ used_addresses.insert(td.m_subaddr_index);
+
+ const size_t first_account = req.all_accounts ? 0 : req.account_index;
+ const size_t last_account = req.all_accounts ? account_count : first_account + 1;
+ for (size_t account = first_account; account < last_account; ++account)
{
- THROW_WALLET_EXCEPTION_IF(i >= m_wallet->get_num_subaddresses(req.account_index), error::address_index_outofbound);
- res.addresses.resize(res.addresses.size() + 1);
- auto& info = res.addresses.back();
- const cryptonote::subaddress_index index = {req.account_index, i};
- info.address = m_wallet->get_subaddress_as_str(index);
- info.label = m_wallet->get_subaddress_label(index);
- info.address_index = index.minor;
- info.used = std::find_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return td.m_subaddr_index == index; }) != transfers.end();
+ std::vector<uint32_t> address_indices;
+ if (req.all_accounts || req.address_index.empty())
+ {
+ for (uint32_t i = 0; i < m_wallet->get_num_subaddresses(account); ++i)
+ address_indices.push_back(i);
+ }
+ else
+ address_indices = req.address_index;
+
+ for (uint32_t i : address_indices)
+ {
+ THROW_WALLET_EXCEPTION_IF(i >= m_wallet->get_num_subaddresses(account), error::address_index_outofbound);
+ res.addresses.resize(res.addresses.size() + 1);
+ auto& info = res.addresses.back();
+ const cryptonote::subaddress_index index = {static_cast<uint32_t>(account), i};
+ info.address = m_wallet->get_subaddress_as_str(index);
+ info.label = m_wallet->get_subaddress_label(index);
+ info.account_index = index.major;
+ info.address_index = index.minor;
+ info.used = req.all_accounts ? used_addresses.count(index) != 0 :
+ std::find_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return td.m_subaddr_index == index; }) != transfers.end();
+ }
}
- res.address = m_wallet->get_subaddress_as_str({req.account_index, 0});
+ res.address = m_wallet->get_subaddress_as_str({req.all_accounts ? 0 : req.account_index, 0});
}
catch (const std::exception& e)
{
@@ -2363,7 +2376,7 @@ namespace tools
{
if (!filter || available != td.m_spent)
{
- if (req.account_index != td.m_subaddr_index.major || (!req.subaddr_indices.empty() && req.subaddr_indices.count(td.m_subaddr_index.minor) == 0))
+ if (!req.all_accounts && (req.account_index != td.m_subaddr_index.major || (!req.subaddr_indices.empty() && req.subaddr_indices.count(td.m_subaddr_index.minor) == 0)))
continue;
// wallet2::is_transfer_unlocked() needs a daemon connection to work. if it fails, assume locked
### src/wallet/wallet_rpc_server_commands_defs.h
@@ -47,7 +47,7 @@
// advance which version they will stop working with
// Don't go over 32767 for any of these
#define WALLET_RPC_VERSION_MAJOR 1
-#define WALLET_RPC_VERSION_MINOR 37
+#define WALLET_RPC_VERSION_MINOR 38
#define MAKE_WALLET_RPC_VERSION(major,minor) (((major)<<16)|(minor))
#define WALLET_RPC_VERSION MAKE_WALLET_RPC_VERSION(WALLET_RPC_VERSION_MAJOR, WALLET_RPC_VERSION_MINOR)
namespace tools
@@ -168,9 +168,11 @@ namespace wallet_rpc
{
uint32_t account_index;
std::vector<uint32_t> address_index;
+ bool all_accounts;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(account_index)
KV_SERIALIZE(address_index)
+ KV_SERIALIZE_OPT(all_accounts, false)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;
@@ -179,12 +181,14 @@ namespace wallet_rpc
{
std::string address;
std::string label;
+ uint32_t account_index;
uint32_t address_index;
bool used;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
KV_SERIALIZE(label)
+ KV_SERIALIZE(account_index)
KV_SERIALIZE(address_index)
KV_SERIALIZE(used)
END_KV_SERIALIZE_MAP()
@@ -1144,11 +1148,13 @@ namespace wallet_rpc
std::string transfer_type;
uint32_t account_index;
std::set<uint32_t> subaddr_indices;
+ bool all_accounts;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(transfer_type)
KV_SERIALIZE(account_index)
KV_SERIALIZE(subaddr_indices)
+ KV_SERIALIZE_OPT(all_accounts, false)
END_KV_SERIALIZE_MAP()
};
typedef epee::misc_utils::struct_init<request_t> request;
### tests/functional_tests/transfer.py
@@ -1711,5 +1711,18 @@ def check_transfer(txid, expected_type):
assert account_0.transfers[0] in all_accounts.transfers
assert account_1.transfers[0] in all_accounts.transfers
+ daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 1)
+ self.wallet[1].refresh()
+ account_0 = self.wallet[1].incoming_transfers()
+ account_1 = self.wallet[1].incoming_transfers(account_index = 1)
+ all_accounts = self.wallet[1].incoming_transfers(account_index = 99, subaddr_indices = [999], all_accounts = True)
+ def output_key(transfer):
+ return (transfer.tx_hash, transfer.pubkey, transfer.subaddr_index.major, transfer.subaddr_index.minor)
+ assert {output_key(t) for t in all_accounts.transfers} == {output_key(t) for t in account_0.transfers + account_1.transfers}
+ assert any(t.tx_hash == txid and t.subaddr_index.major == 0 for t in all_accounts.transfers)
+ assert any(t.tx_hash == txid and t.subaddr_index.major == 1 for t in all_accounts.transfers)
+ addresses = self.wallet[1].get_address(all_accounts = True).addresses
+ assert all(any(a.account_index == major and a.address_index == 0 and a.used for a in addresses) for major in (0, 1))
+
if __name__ == '__main__':
TransferTest().run_test()
### tests/functional_tests/wallet.py
@@ -264,6 +264,14 @@ def create_subaddresses(self):
assert res.addresses[2].address == '87KfgTZ8ER5D3Frefqnrqif11TjVsTPaTcp37kqqKMrdDRUhpJRczeR7KiBmSHF32UJLP3HHhKUDmEQyJrv2mV8yFDCq8eB'
assert res.addresses[2].label == 'sub_1_2'
+ all_accounts = wallet.get_address(account_index = 99, subaddresses = [999], all_accounts = True)
+ assert all_accounts.address == wallet.get_address().address
+ assert len(all_accounts.addresses) == 6
+ assert [(a.account_index, a.address_index) for a in all_accounts.addresses] == [
+ (0, 0), (0, 1), (1, 0), (1, 1), (1, 2), (2, 0)]
+ assert all(a.address == wallet.get_address(a.account_index, [a.address_index]).addresses[0].address for a in all_accounts.addresses)
+ assert all(not a.used for a in all_accounts.addresses)
+
res = wallet.label_address((1, 2), "sub_1_2_new")
res = wallet.get_address(1, [2])
assert len(res.addresses) == 1
### utils/python-rpc/framework/wallet.py
@@ -225,16 +225,18 @@ def sweep_single(self, address = '', priority = 0, ring_size = 0, outputs = 1, u
}
return self.rpc.send_json_rpc_request(sweep_single)
- def get_address(self, account_index = 0, subaddresses = []):
+ def get_address(self, account_index = 0, subaddresses = [], all_accounts = False):
get_address = {
'method': 'get_address',
'params' : {
'account_index' : account_index,
- 'address_index': subaddresses
+ 'address_index': subaddresses,
},
'jsonrpc': '2.0',
'id': '0'
}
+ if all_accounts:
+ get_address['params']['all_accounts'] = True
return self.rpc.send_json_rpc_request(get_address)
getaddress = get_address
@@ -430,7 +432,7 @@ def refresh(self):
}
return self.rpc.send_json_rpc_request(refresh)
- def incoming_transfers(self, transfer_type='all', account_index = 0, subaddr_indices = []):
+ def incoming_transfers(self, transfer_type='all', account_index = 0, subaddr_indices = [], all_accounts = False):
incoming_transfers = {
'method': 'incoming_transfers',
'params' : {
@@ -441,6 +443,8 @@ def incoming_transfers(self, transfer_type='all', account_index = 0, subaddr_ind
'jsonrpc': '2.0',
'id': '0'
}
+ if all_accounts:
+ incoming_transfers['params']['all_accounts'] = True
return self.rpc.send_json_rpc_request(incoming_transfers)
def get_transfers(self, in_ = True, out = True, pending = True, failed = True, pool = True, min_height = None, max_height = None, account_index = 0, subaddr_indices = [], all_accounts = False, refresh_pool = True):Why this scored 23/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.