What changed, and why it matters
This change improves how Monero handles OpenAlias address lookups via DNS. Previously, the software only knew whether DNSSEC validation passed or not, treating 'not available' and 'invalid' the same. Now it distinguishes three states: DNSSEC unavailable, valid, or invalid. This lets the wallet and RPC give clearer warnings and reject addresses when DNSSEC actually fails validation, rather than silently treating unsigned domains the same as tampered ones. It is a defensive hardening change, not a fix for an active exploit.
Review the updated DNSSEC handling to ensure all OpenAlias resolution paths reject dnssec_status::invalid responses. Consider whether the public WalletManager API should eventually expose the richer enum to callers. No urgent patch or incident response is indicated.
Security signals we found
Improved DNSSEC status granularity reduces risk of accepting addresses from DNS responses that failed validation
User-facing and RPC error messages now distinguish 'DNSSEC not available' from 'DNSSEC invalid'
No memory safety, cryptographic, or remote-code-execution signals present in diff
Change is defensive/hardening rather than remediation of a reported vulnerability
Evidence from the diff
The commit refactors dns_utils to replace a boolean dnssec_valid flag with a dnssec_status enum having unavailable, valid, and invalid states. Call sites in daemon, simplewallet, wallet RPC server, and wallet API are updated to check for the valid state explicitly and to emit distinct error messages for invalid vs unavailable DNSSEC. The public WalletManager::resolveOpenAlias API preserves its existing boolean contract by mapping only dnssec_status::valid to true. Unit tests are updated to use the enum.
Changed components
src/common/dns_utils.cppsrc/common/dns_utils.hsrc/cryptonote_basic/cryptonote_basic_impl.cppsrc/cryptonote_basic/cryptonote_basic_impl.hsrc/daemon/command_parser_executor.cppsrc/simplewallet/simplewallet.cppsrc/wallet/api/wallet_manager.cppsrc/wallet/wallet_rpc_server.cpptests/unit_tests/address_from_url.cppInspect captured patch +84 / −52
### src/common/dns_utils.cpp
@@ -394,29 +394,35 @@ std::string address_from_txt_record(const std::string& s)
*
* gets the monero address from the TXT record of the DNS entry associated
* with <url>. If this lookup fails, or the TXT record does not contain an
- * XMR address in the correct format, returns an empty string. <dnssec_valid>
- * will be set true or false according to whether or not the DNS query passes
- * DNSSEC validation.
+ * XMR address in the correct format, returns an empty string. <dnssec>
+ * will be set to a dnssec_status value reflecting whether DNSSEC was
+ * available and whether the query passed DNSSEC validation.
*
* @param url the url to look up
- * @param dnssec_valid return-by-reference for DNSSEC status of query
+ * @param dnssec return-by-reference for DNSSEC status of query
*
* @return a monero address (as a string) or an empty string
*/
-std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec_valid)
+std::vector<std::string> addresses_from_url(const std::string& url, dnssec_status& dnssec)
{
std::vector<std::string> addresses;
// get txt records
bool dnssec_available, dnssec_isvalid;
std::string oa_addr = DNSResolver::instance().get_dns_format_from_oa_address(url);
auto records = DNSResolver::instance().get_txt_record(oa_addr, dnssec_available, dnssec_isvalid);
- // TODO: update this to allow for conveying that dnssec was not available
- if (dnssec_available && dnssec_isvalid)
+ if (!dnssec_available)
{
- dnssec_valid = true;
+ dnssec = dnssec_status::unavailable;
+ }
+ else if (dnssec_isvalid)
+ {
+ dnssec = dnssec_status::valid;
+ }
+ else
+ {
+ dnssec = dnssec_status::invalid;
}
- else dnssec_valid = false;
// for each txt record, try to find a monero address in it.
for (auto& rec : records)
@@ -430,16 +436,16 @@ std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec
return addresses;
}
-std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm)
+std::string get_account_address_as_str_from_url(const std::string& url, dnssec_status& dnssec, std::function<std::string(const std::string&, const std::vector<std::string>&, dnssec_status)> dns_confirm)
{
// attempt to get address from dns query
- auto addresses = addresses_from_url(url, dnssec_valid);
+ auto addresses = addresses_from_url(url, dnssec);
if (addresses.empty())
{
LOG_ERROR("wrong address: " << url);
return {};
}
- return dns_confirm(url, addresses, dnssec_valid);
+ return dns_confirm(url, addresses, dnssec);
}
bool load_txt_records_from_dns(std::vector<std::string> &good_records, const std::vector<std::string> &dns_urls)
### src/common/dns_utils.h
@@ -165,10 +165,23 @@ class DNSResolver
namespace dns_utils
{
+/**
+ * @brief DNSSEC validation status for a DNS query
+ *
+ * Distinguishes between DNSSEC being unavailable, validation passing,
+ * and validation failing (which may indicate tampering).
+ */
+enum class dnssec_status
+{
+ unavailable, //!< DNSSEC was not available for this query (no signed records)
+ valid, //!< DNSSEC validation passed
+ invalid //!< DNSSEC validation failed; the record may be tampered with
+};
+
std::string address_from_txt_record(const std::string& s);
-std::vector<std::string> addresses_from_url(const std::string& url, bool& dnssec_valid);
+std::vector<std::string> addresses_from_url(const std::string& url, dnssec_status& dnssec);
-std::string get_account_address_as_str_from_url(const std::string& url, bool& dnssec_valid, std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> confirm_dns);
+std::string get_account_address_as_str_from_url(const std::string& url, dnssec_status& dnssec, std::function<std::string(const std::string&, const std::vector<std::string>&, dnssec_status)> confirm_dns);
bool load_txt_records_from_dns(std::vector<std::string> &records, const std::vector<std::string> &dns_urls);
### src/cryptonote_basic/cryptonote_basic_impl.cpp
@@ -233,7 +233,7 @@ namespace cryptonote {
address_parse_info& info
, network_type nettype
, const std::string& str_or_url
- , std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm
+ , std::function<std::string(const std::string&, const std::vector<std::string>&, tools::dns_utils::dnssec_status)> dns_confirm
)
{
return get_account_address_from_str_or_url(info, nettype, str_or_url, true, dns_confirm);
@@ -244,15 +244,15 @@ namespace cryptonote {
, network_type nettype
, const std::string& str_or_url
, bool allow_dns
- , std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm
+ , std::function<std::string(const std::string&, const std::vector<std::string>&, tools::dns_utils::dnssec_status)> dns_confirm
)
{
if (get_account_address_from_str(info, nettype, str_or_url))
return true;
if (!allow_dns)
return false;
- bool dnssec_valid;
- std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(str_or_url, dnssec_valid, dns_confirm);
+ tools::dns_utils::dnssec_status dnssec;
+ std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(str_or_url, dnssec, dns_confirm);
return !address_str.empty() &&
get_account_address_from_str(info, nettype, address_str);
}
### src/cryptonote_basic/cryptonote_basic_impl.h
@@ -32,6 +32,7 @@
#include "cryptonote_basic.h"
#include "crypto/hash.h"
+#include "common/dns_utils.h"
namespace cryptonote {
@@ -41,7 +42,7 @@ namespace cryptonote {
namespace
{
- inline std::string return_first_address(const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)
+ inline std::string return_first_address(const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)
{
if (addresses.empty())
return {};
@@ -88,15 +89,15 @@ namespace cryptonote {
address_parse_info& info
, network_type nettype
, const std::string& str_or_url
- , std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm = return_first_address
+ , std::function<std::string(const std::string&, const std::vector<std::string>&, tools::dns_utils::dnssec_status)> dns_confirm = return_first_address
);
bool get_account_address_from_str_or_url(
address_parse_info& info
, network_type nettype
, const std::string& str_or_url
, bool allow_dns
- , std::function<std::string(const std::string&, const std::vector<std::string>&, bool)> dns_confirm = return_first_address
+ , std::function<std::string(const std::string&, const std::vector<std::string>&, tools::dns_utils::dnssec_status)> dns_confirm = return_first_address
);
/**
### src/daemon/command_parser_executor.cpp
@@ -382,16 +382,19 @@ bool t_command_parser_executor::start_mining(const std::vector<std::string>& arg
{
if(!cryptonote::get_account_address_from_str(info, cryptonote::STAGENET, args.front()))
{
- bool dnssec_valid;
- std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec_valid,
- [](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid) -> std::string {
- if (!dnssec_valid) return {};
+ tools::dns_utils::dnssec_status dnssec;
+ std::string address_str = tools::dns_utils::get_account_address_as_str_from_url(args.front(), dnssec,
+ [](const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec) -> std::string {
+ if (dnssec != tools::dns_utils::dnssec_status::valid) return {};
if (addresses.empty()) return {};
return addresses[0];
});
- if(!dnssec_valid)
+ if(dnssec != tools::dns_utils::dnssec_status::valid)
{
- std::cout << "Invalid syntax: Invalid DNSSEC for " << args.front() << std::endl;
+ const char *dnssec_msg = dnssec == tools::dns_utils::dnssec_status::invalid
+ ? "Invalid DNSSEC"
+ : "DNSSEC not available";
+ std::cout << "Invalid syntax: " << dnssec_msg << " for " << args.front() << std::endl;
return true;
}
if(!cryptonote::get_account_address_from_str(info, cryptonote::MAINNET, address_str))
### src/simplewallet/simplewallet.cpp
@@ -488,20 +488,25 @@ namespace
return boost::lexical_cast<std::string>(version >> 16) + "." + boost::lexical_cast<std::string>(version & 0xffff);
}
- std::string oa_prompter(const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)
+ std::string oa_prompter(const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)
{
if (addresses.empty())
return {};
// prompt user for confirmation.
// inform user of DNSSEC validation status as well.
std::string dnssec_str;
- if (dnssec_valid)
+ switch (dnssec)
{
+ case tools::dns_utils::dnssec_status::valid:
dnssec_str = sw::tr("DNSSEC validation passed");
- }
- else
- {
- dnssec_str = sw::tr("WARNING: DNSSEC validation was unsuccessful, this address may not be correct!");
+ break;
+ case tools::dns_utils::dnssec_status::unavailable:
+ dnssec_str = sw::tr("WARNING: DNSSEC validation was not available, this address could not be verified!");
+ break;
+ case tools::dns_utils::dnssec_status::invalid:
+ default:
+ dnssec_str = sw::tr("WARNING: DNSSEC validation failed, this address may have been tampered with!");
+ break;
}
std::stringstream prompt;
prompt << sw::tr("For URL: ") << url
### src/wallet/api/wallet_manager.cpp
@@ -352,7 +352,11 @@ bool WalletManagerImpl::stopMining()
std::string WalletManagerImpl::resolveOpenAlias(const std::string &address, bool &dnssec_valid) const
{
- std::vector<std::string> addresses = tools::dns_utils::addresses_from_url(address, dnssec_valid);
+ tools::dns_utils::dnssec_status dnssec;
+ std::vector<std::string> addresses = tools::dns_utils::addresses_from_url(address, dnssec);
+ // Preserve the public API's boolean contract: only report valid when DNSSEC
+ // was both available and successfully validated.
+ dnssec_valid = dnssec == tools::dns_utils::dnssec_status::valid;
if (addresses.empty())
return "";
return addresses.front();
### src/wallet/wallet_rpc_server.cpp
@@ -1137,10 +1137,10 @@ namespace tools
cryptonote::tx_destination_entry de;
er.message = "";
if(!get_account_address_from_str_or_url(info, m_wallet->nettype(), it->address, m_wallet->is_dns_enabled(),
- [&er](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
- if (!dnssec_valid)
+ [&er](const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)->std::string {
+ if (dnssec != tools::dns_utils::dnssec_status::valid)
{
- er.message = std::string("Invalid DNSSEC for ") + url;
+ er.message = std::string(dnssec == tools::dns_utils::dnssec_status::invalid ? "Invalid DNSSEC for " : "DNSSEC not available for ") + url;
return {};
}
if (addresses.empty())
@@ -2611,10 +2611,10 @@ namespace tools
cryptonote::address_parse_info info;
er.message = "";
if(!get_account_address_from_str_or_url(info, m_wallet->nettype(), req.address, m_wallet->is_dns_enabled(),
- [&er](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
- if (!dnssec_valid)
+ [&er](const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)->std::string {
+ if (dnssec != tools::dns_utils::dnssec_status::valid)
{
- er.message = std::string("Invalid DNSSEC for ") + url;
+ er.message = std::string(dnssec == tools::dns_utils::dnssec_status::invalid ? "Invalid DNSSEC for " : "DNSSEC not available for ") + url;
return {};
}
if (addresses.empty())
@@ -3415,10 +3415,10 @@ namespace tools
cryptonote::address_parse_info info;
er.message = "";
if(!get_account_address_from_str_or_url(info, m_wallet->nettype(), req.address, m_wallet->is_dns_enabled(),
- [&er](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
- if (!dnssec_valid)
+ [&er](const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)->std::string {
+ if (dnssec != tools::dns_utils::dnssec_status::valid)
{
- er.message = std::string("Invalid DNSSEC for ") + url;
+ er.message = std::string(dnssec == tools::dns_utils::dnssec_status::invalid ? "Invalid DNSSEC for " : "DNSSEC not available for ") + url;
return {};
}
if (addresses.empty())
@@ -3463,10 +3463,10 @@ namespace tools
{
er.message = "";
if(!get_account_address_from_str_or_url(info, m_wallet->nettype(), req.address, m_wallet->is_dns_enabled(),
- [&er](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
- if (!dnssec_valid)
+ [&er](const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)->std::string {
+ if (dnssec != tools::dns_utils::dnssec_status::valid)
{
- er.message = std::string("Invalid DNSSEC for ") + url;
+ er.message = std::string(dnssec == tools::dns_utils::dnssec_status::invalid ? "Invalid DNSSEC for " : "DNSSEC not available for ") + url;
return {};
}
if (addresses.empty())
@@ -4895,10 +4895,10 @@ namespace tools
{
std::string address;
res.valid = get_account_address_from_str_or_url(info, net_type.type, req.address, allow_dns,
- [&er, &address](const std::string &url, const std::vector<std::string> &addresses, bool dnssec_valid)->std::string {
- if (!dnssec_valid)
+ [&er, &address](const std::string &url, const std::vector<std::string> &addresses, tools::dns_utils::dnssec_status dnssec)->std::string {
+ if (dnssec != tools::dns_utils::dnssec_status::valid)
{
- er.message = std::string("Invalid DNSSEC for ") + url;
+ er.message = std::string(dnssec == tools::dns_utils::dnssec_status::invalid ? "Invalid DNSSEC for " : "DNSSEC not available for ") + url;
return {};
}
if (addresses.empty())
### tests/unit_tests/address_from_url.cpp
@@ -86,7 +86,7 @@ TEST(AddressFromURL, Success)
{
const std::string addr = MONERO_DONATION_ADDR;
- bool dnssec_result = false;
+ tools::dns_utils::dnssec_status dnssec_result = tools::dns_utils::dnssec_status::unavailable;
std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("donate.getmonero.org", dnssec_result);
@@ -107,12 +107,12 @@ TEST(AddressFromURL, Success)
TEST(AddressFromURL, Failure)
{
- bool dnssec_result = false;
+ tools::dns_utils::dnssec_status dnssec_result = tools::dns_utils::dnssec_status::unavailable;
std::vector<std::string> addresses = tools::dns_utils::addresses_from_url("nonexistent.getmonero.org", dnssec_result);
// The absence of a TXT record is authenticated with DNSSEC denial records.
- ASSERT_TRUE(dnssec_result);
+ ASSERT_EQ(tools::dns_utils::dnssec_status::valid, dnssec_result);
ASSERT_EQ(0, addresses.size());
}Why this scored 34/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.