What changed, and why it matters
This Monero wallet update fixes how the wallet checks whether a daemon address is a special privacy-protected .onion or .i2p address when using a proxy or SSL. Before the fix, the wallet could be tricked by unusual addresses containing spaces, tabs, null characters, or IPv6 scope symbols into thinking an ordinary internet address was a trusted .onion/.i2p address, which would let it skip required SSL certificate checks. That could allow a malicious daemon to impersonate a trusted node and potentially spy on or manipulate wallet traffic. The patch now properly parses the URL and rejects suspicious characters before deciding whether strong verification is needed.
Treat this as a security fix and include it in the next release. Users who run monero-wallet-cli or monero-wallet-rpc with --proxy or daemon SSL enabled should upgrade, because prior versions could be misled into skipping certificate verification against non-.onion/.i2p hosts. Review any custom daemon-address handling elsewhere in the codebase for the same substring-vs-parse and control-character issues.
Security signals we found
Bypass of strong SSL/TLS verification requirement for proxy/SSL mode
Host extraction via substring instead of URL parsing
Insufficient validation of control characters in daemon host
IPv6 scope ID (%suffix) could alter .onion/.i2p suffix matching
Functional tests include explicit bypass payloads and expected failures
Evidence from the diff
The commit replaces a naive host extraction (substr(0, rfind(':'))) with proper URL parsing (epee::net_utils::parse_url) and adds validation that the parsed host contains no control characters (<= 0x20 or 0x7F). It also updates ssl_options_t::has_strong_verification to ignore IPv6 scope IDs (%) before checking the .onion/.i2p suffix. The functional tests demonstrate bypass attempts such as http://[::1%1.onion], https://example.org/foo.onion:443, and hosts with embedded null/space/tab/del characters that previously could defeat the strong-verification requirement when a proxy or SSL was enabled.
Changed components
src/wallet/wallet2.cppsrc/wallet/wallet_rpc_server.cppcontrib/epee/src/net_ssl.cpptests/functional_tests/wallet.pyutils/python-rpc/framework/wallet.pyInspect captured patch +55 / −7
### contrib/epee/src/net_ssl.cpp
@@ -330,7 +330,9 @@ bool ssl_options_t::has_strong_verification(boost::string_ref host) const noexce
{
// onion and i2p addresses contain information about the server cert
// which both authenticates and encrypts
- if (host.ends_with(".onion") || host.ends_with(".i2p"))
+ // an IPv6 scope ID is removed before the address is sent to the proxy
+ if (host.find('%') == boost::string_ref::npos &&
+ (host.ends_with(".onion") || host.ends_with(".i2p")))
return true;
switch (verification)
{
### src/wallet/wallet2.cpp
@@ -424,7 +424,14 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
daemon_address = std::string("http://") + daemon_host + ":" + std::to_string(daemon_port);
{
- const boost::string_ref real_daemon = boost::string_ref{daemon_address}.substr(0, daemon_address.rfind(':'));
+ epee::net_utils::http::url_content parsed{};
+ const bool parsed_address = epee::net_utils::parse_url(daemon_address, parsed);
+
+ THROW_WALLET_EXCEPTION_IF(
+ parsed_address && std::any_of(parsed.host.begin(), parsed.host.end(), [](unsigned char c) { return c <= ' ' || c == 0x7f; }),
+ tools::error::wallet_internal_error,
+ tools::wallet2::tr("Invalid daemon address")
+ );
/* If SSL or proxy is enabled, then a specific cert, CA or fingerprint must
be specified. This is specific to the wallet. */
@@ -433,7 +440,7 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
(ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_enabled || use_proxy);
THROW_WALLET_EXCEPTION_IF(
- verification_required && !ssl_options.has_strong_verification(real_daemon),
+ verification_required && (!parsed_address || !ssl_options.has_strong_verification(parsed.host)),
tools::error::wallet_internal_error,
tools::wallet2::tr("Enabling --") + std::string{use_proxy ? opts.proxy.name : opts.daemon_ssl.name} + tools::wallet2::tr(" requires --") +
opts.daemon_ssl_allow_any_cert.name + tools::wallet2::tr(" or --") +
### src/wallet/wallet_rpc_server.cpp
@@ -32,6 +32,7 @@
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/preprocessor/stringize.hpp>
+#include <algorithm>
#include <cstdint>
#include <chrono>
#include <cstring>
@@ -4952,7 +4953,9 @@ namespace tools
}
epee::net_utils::http::url_content parsed{};
- if (!req.address.empty() && !epee::net_utils::parse_url(req.address, parsed))
+ if (!req.address.empty() &&
+ (!epee::net_utils::parse_url(req.address, parsed) ||
+ std::any_of(parsed.host.begin(), parsed.host.end(), [](unsigned char c) { return c <= ' ' || c == 0x7f; })))
{
er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
er.message = "Failed to parse daemon address";
@@ -5002,13 +5005,12 @@ namespace tools
};
// If a proxy or SSL is explicitly enabled, then ssl_allow_any_cert, ssl_ca_file, ssl_allowed_fingerprints, or use of a .onion or .i2p address is required
- const boost::string_ref real_daemon = boost::string_ref{req.address}.substr(0, req.address.rfind(':'));
const bool use_proxy = !req.proxy.empty();
const bool verification_required =
ssl_options.verification != epee::net_utils::ssl_verification_t::none &&
(ssl_options.support == epee::net_utils::ssl_support_t::e_ssl_support_enabled || use_proxy);
- if (verification_required && !ssl_options.has_strong_verification(real_daemon))
+ if (verification_required && !ssl_options.has_strong_verification(parsed.host))
{
er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
er.message = "SSL or proxy is enabled but no strong verification was configured; set ssl_allow_any_cert, ssl_ca_file, or ssl_allowed_fingerprints, or use a .onion or .i2p address";
### tests/functional_tests/wallet.py
@@ -42,6 +42,7 @@ class WalletTest():
def run_test(self):
self.reset()
self.create()
+ self.set_daemon_with_proxy()
self.check_main_address()
self.check_keys()
self.create_subaddresses()
@@ -56,6 +57,41 @@ def run_test(self):
self.change_password()
self.store()
+ def set_daemon_with_proxy(self):
+ print('Testing daemon URLs with a proxy')
+ wallet = Wallet()
+ wallet.auto_refresh(False)
+ try:
+ wallet.set_daemon('https://example.onion', proxy = '127.0.0.1:9050')
+ wallet.set_daemon('http://example.i2p', proxy = '127.0.0.1:9050')
+ wallet.set_daemon('https://example.onion:443', proxy = '127.0.0.1:9050')
+
+ for address, proxy in (('https://example.org', '127.0.0.1:9050'),
+ ('https://example.org/foo.onion:443', '127.0.0.1:9050'),
+ ('http://[::1%1.onion]', 'socks5://127.0.0.1:9050'),
+ ('http://[::1%1.i2p]', 'socks5://127.0.0.1:9050')):
+ ok = False
+ try:
+ wallet.set_daemon(address, proxy = proxy)
+ except AssertionError as e:
+ assert 'no strong verification was configured' in str(e)
+ ok = True
+ assert ok
+
+ for address in ('https://example.org\0.onion', 'https://example.org\0.onion:443',
+ 'http://1.2.3.4 x.onion', 'http://1.2.3.4 x.onion:18081',
+ 'http://1.2.3.4\tx.onion', 'http://1.2.3.4\x7fx.onion'):
+ ok = False
+ try:
+ wallet.set_daemon(address, proxy = '127.0.0.1:9050')
+ except AssertionError as e:
+ assert 'Failed to parse daemon address' in str(e)
+ ok = True
+ assert ok
+ finally:
+ wallet.set_daemon('http://127.0.0.1:18180', trusted = True, ssl_support = 'disabled')
+ wallet.auto_refresh(True)
+
def reset(self):
print('Resetting blockchain')
daemon = Daemon()
### utils/python-rpc/framework/wallet.py
@@ -501,7 +501,7 @@ def auto_refresh(self, enable, period = 0):
}
return self.rpc.send_json_rpc_request(auto_refresh)
- def set_daemon(self, address, trusted = False, ssl_support = "autodetect", ssl_private_key_path = "", ssl_certificate_path = "", ssl_allowed_certificates = [], ssl_allowed_fingerprints = [], ssl_allow_any_cert = False):
+ def set_daemon(self, address, trusted = False, ssl_support = "autodetect", ssl_private_key_path = "", ssl_certificate_path = "", ssl_allowed_certificates = [], ssl_allowed_fingerprints = [], ssl_allow_any_cert = False, proxy = ""):
set_daemon = {
'method': 'set_daemon',
'params' : {
@@ -513,6 +513,7 @@ def set_daemon(self, address, trusted = False, ssl_support = "autodetect", ssl_p
'ssl_allowed_certificates': ssl_allowed_certificates,
'ssl_allowed_fingerprints': ssl_allowed_fingerprints,
'ssl_allow_any_cert': ssl_allow_any_cert,
+ 'proxy': proxy,
},
'jsonrpc': '2.0',
'id': '0'Why this scored 62/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.