What changed, and why it matters
This commit adds a new command-line option, --rpc-restricted-no-login, that lets a Monero node operator run a separate restricted RPC port without requiring HTTP digest authentication. It is an intentional feature, not a hidden backdoor, and the code enforces that the option can only be used together with the separate restricted RPC port. The change is defensive in design: it does not remove authentication from the main RPC port and explicitly prevents accidental misconfiguration.
Treat as a feature commit rather than a vulnerability. Operators choosing --rpc-restricted-no-login should ensure the restricted RPC port is not exposed to untrusted networks, since it removes authentication. Reviewers may want to confirm that the restricted command set is sufficiently limited to make loginless exposure acceptable.
Security signals we found
New authentication bypass option added, but gated to a separate restricted RPC port
Guard condition prevents using the option without an explicit restricted bind port
Main RPC port authentication behavior is unchanged
Functional tests assert 401 on main port and 200 on restricted no-login port
No CVE, vendor security advisory, or independent researcher attribution present in commit
Evidence from the diff
The patch introduces arg_rpc_restricted_no_login and threads a disable_login flag through daemon.cpp, rpc.h, core_rpc_server.cpp/.h, and rpc_args.cpp/.h. When set, rpc_args::process is told not to parse/require rpc_login for the restricted RPC server instance. A guard in daemon.cpp throws if –rpc-restricted-no-login is supplied without –rpc-restricted-bind-port. Functional tests verify that the main RPC port still requires login, the restricted port can be loginless, and the option is rejected when no restricted port is configured.
Changed components
src/daemon/daemon.cppsrc/daemon/rpc.hsrc/rpc/core_rpc_server.cppsrc/rpc/core_rpc_server.hsrc/rpc/rpc_args.cppsrc/rpc/rpc_args.htests/functional_tests/functional_tests_rpc.pytests/functional_tests/http_digest_auth.pyInspect captured patch +115 / −9
### src/daemon/daemon.cpp
@@ -136,12 +136,15 @@ struct t_internals {
const auto main_rpc_port = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_bind_port);
const auto restricted_rpc_port_arg = cryptonote::core_rpc_server::arg_rpc_restricted_bind_port;
const bool has_restricted_rpc_port_arg = !command_line::is_arg_defaulted(vm, restricted_rpc_port_arg);
- rpcs.emplace_back(new t_rpc{vm, core, p2p, restricted, main_rpc_port, "core"});
+ const bool restricted_no_login = command_line::get_arg(vm, cryptonote::core_rpc_server::arg_rpc_restricted_no_login);
+ if (restricted_no_login && !has_restricted_rpc_port_arg)
+ throw std::runtime_error("--rpc-restricted-no-login requires --rpc-restricted-bind-port");
+ rpcs.emplace_back(new t_rpc{vm, core, p2p, restricted, main_rpc_port, "core", false});
if(has_restricted_rpc_port_arg)
{
auto restricted_rpc_port = command_line::get_arg(vm, restricted_rpc_port_arg);
- rpcs.emplace_back(new t_rpc{vm, core, p2p, true, restricted_rpc_port, "restricted"});
+ rpcs.emplace_back(new t_rpc{vm, core, p2p, true, restricted_rpc_port, "restricted", restricted_no_login});
}
if (!command_line::get_arg(vm, daemon_args::arg_zmq_rpc_disabled))
### src/daemon/rpc.h
@@ -59,12 +59,13 @@ class t_rpc final
, const bool restricted
, const std::string & port
, const std::string & description
+ , const bool disable_login
)
: m_server{core.get(), p2p.get()}, m_description{description}
{
MGINFO("Initializing " << m_description << " RPC server...");
- if (!m_server.init(vm, restricted, port, command_line::get_arg(vm, daemon_args::arg_proxy)))
+ if (!m_server.init(vm, restricted, port, command_line::get_arg(vm, daemon_args::arg_proxy), disable_login))
{
throw std::runtime_error("Failed to initialize " + m_description + " RPC server.");
}
### src/rpc/core_rpc_server.cpp
@@ -109,6 +109,7 @@ namespace cryptonote
{
command_line::add_arg(desc, arg_rpc_bind_port);
command_line::add_arg(desc, arg_rpc_restricted_bind_port);
+ command_line::add_arg(desc, arg_rpc_restricted_no_login);
command_line::add_arg(desc, arg_restricted_rpc);
cryptonote::rpc_args::init_options(desc, true);
command_line::add_arg(desc, arg_rpc_max_connections_per_public_ip);
@@ -137,13 +138,14 @@ namespace cryptonote
, const bool restricted
, const std::string& port
, const std::string& proxy
+ , const bool disable_login
)
{
m_restricted = restricted;
m_net_server.set_threads_prefix("RPC");
m_net_server.set_connection_filter(&m_p2p);
- auto rpc_config = cryptonote::rpc_args::process(vm, true);
+ auto rpc_config = cryptonote::rpc_args::process(vm, true, !disable_login);
if (!rpc_config)
return false;
@@ -3128,6 +3130,12 @@ namespace cryptonote
, ""
};
+ const command_line::arg_descriptor<bool> core_rpc_server::arg_rpc_restricted_no_login = {
+ "rpc-restricted-no-login"
+ , "Do not require --rpc-login on the separate restricted RPC port"
+ , false
+ };
+
const command_line::arg_descriptor<bool> core_rpc_server::arg_restricted_rpc = {
"restricted-rpc"
, "Restrict RPC to view only commands and do not return privacy sensitive data in RPC calls"
### src/rpc/core_rpc_server.h
@@ -56,6 +56,7 @@ namespace cryptonote
static const command_line::arg_descriptor<std::string, false, true, 2> arg_rpc_bind_port;
static const command_line::arg_descriptor<std::string> arg_rpc_restricted_bind_port;
+ static const command_line::arg_descriptor<bool> arg_rpc_restricted_no_login;
static const command_line::arg_descriptor<bool> arg_restricted_rpc;
static const command_line::arg_descriptor<std::string> arg_rpc_ssl;
static const command_line::arg_descriptor<std::string> arg_rpc_ssl_private_key;
@@ -82,7 +83,8 @@ namespace cryptonote
const boost::program_options::variables_map& vm,
const bool restricted,
const std::string& port,
- const std::string& proxy = {}
+ const std::string& proxy = {},
+ const bool disable_login = false
);
network_type nettype() const { return m_core.get_nettype(); }
### src/rpc/rpc_args.cpp
@@ -135,7 +135,7 @@ namespace cryptonote
command_line::add_arg(desc, arg.rpc_ssl_allow_any_cert);
}
- boost::optional<rpc_args> rpc_args::process(const boost::program_options::variables_map& vm, const bool any_cert_option)
+ boost::optional<rpc_args> rpc_args::process(const boost::program_options::variables_map& vm, const bool any_cert_option, const bool parse_login)
{
const descriptors arg{};
rpc_args config{};
@@ -230,7 +230,7 @@ namespace cryptonote
const bool has_rpc_arg = command_line::has_arg(vm, arg.rpc_login);
const bool use_rpc_env = !has_rpc_arg && (env_rpc_login = getenv("RPC_LOGIN")) != nullptr && strlen(env_rpc_login) > 0;
boost::optional<tools::login> login{};
- if (has_rpc_arg || use_rpc_env)
+ if (parse_login && (has_rpc_arg || use_rpc_env))
{
config.login = tools::login::parse(
has_rpc_arg ? command_line::get_arg(vm, arg.rpc_login) : std::string(env_rpc_login), true, [](bool verify) {
### src/rpc/rpc_args.h
@@ -77,7 +77,7 @@ namespace cryptonote
static void init_options(boost::program_options::options_description& desc, const bool any_cert_option = false);
//! \return Arguments specified by user, or `boost::none` if error
- static boost::optional<rpc_args> process(const boost::program_options::variables_map& vm, const bool any_cert_option = false);
+ static boost::optional<rpc_args> process(const boost::program_options::variables_map& vm, const bool any_cert_option = false, const bool parse_login = true);
//! \return SSL arguments specified by user, or `boost::none` if error
static boost::optional<epee::net_utils::ssl_options_t> process_ssl(const boost::program_options::variables_map& vm, const bool any_cert_option = false);
### tests/functional_tests/functional_tests_rpc.py
@@ -59,7 +59,7 @@
["--offline"],
["--add-exclusive-node", "127.0.0.1:18283"],
["--add-exclusive-node", "127.0.0.1:18282"],
- ["--rpc-login", "md5_lover:Z1ON0101", "--offline"],
+ ["--rpc-login", "md5_lover:Z1ON0101", "--rpc-restricted-bind-port", "18194", "--offline"],
]
wallet_base = [builddir + "/bin/monero-wallet-rpc", "--wallet-dir", WALLET_DIRECTORY, "--rpc-bind-port", "wallet_port", "--rpc-ssl", "disabled", "--daemon-ssl", "disabled", "--log-level", "1", "--allow-mismatched-daemon-version"]
wallet_extra = [
### tests/functional_tests/http_digest_auth.py
@@ -30,7 +30,13 @@
from framework.daemon import Daemon
from framework.wallet import Wallet
+import requests
+from requests.auth import HTTPDigestAuth
+import os
+import socket
+import subprocess
+import tempfile
import time
@@ -46,6 +52,8 @@
class HttpDigestAuthTest():
def run_test(self):
self.test_daemon_login_required()
+ self.test_restricted_no_login_requires_port()
+ self.test_restricted_daemon_login()
self.test_wallet_login_required()
self.make_daemon_conn()
@@ -63,6 +71,90 @@ def test_daemon_login_required(self):
rejected = True
assert(rejected)
+ def test_restricted_daemon_login(self):
+ monerod = os.path.join(os.environ['FUNCTIONAL_TESTS_DIRECTORY'],
+ '..', '..', 'bin', 'monerod')
+ processes = []
+ with tempfile.TemporaryDirectory() as data_dir:
+ try:
+ for idx in (5, 6):
+ cmd = [monerod, '--regtest', '--offline', '--non-interactive',
+ '--rpc-bind-port', str(18180 + idx),
+ '--rpc-restricted-bind-port', str(18190 + idx),
+ '--rpc-restricted-no-login', '--p2p-bind-port', str(18280 + idx),
+ '--zmq-rpc-bind-port', str(18380 + idx), '--rpc-ssl', 'disabled',
+ '--data-dir', os.path.join(data_dir, str(idx))]
+ env = os.environ.copy()
+ env.pop('RPC_LOGIN', None)
+ if idx == 5:
+ env['RPC_LOGIN'] = 'env_lover:Z1ON0101'
+ else:
+ cmd += ['--rpc-login', 'md5_lover:Z1ON0101', '--restricted-rpc']
+ log_path = os.path.join(os.environ['FUNCTIONAL_TESTS_DIRECTORY'],
+ 'monerod_rpc_auth_{}.log'.format(idx))
+ with open(log_path, 'a') as log:
+ processes.append(subprocess.Popen(cmd, stdout=log, stderr=log, env=env))
+
+ deadline = time.monotonic() + 20
+ for port in (18185, 18195, 18186, 18196):
+ while True:
+ try:
+ with socket.create_connection(('127.0.0.1', port), timeout=1):
+ break
+ except OSError:
+ assert all(p.poll() is None for p in processes)
+ assert time.monotonic() < deadline
+ time.sleep(.1)
+
+ self.check_restricted_daemon_login()
+ finally:
+ for p in processes:
+ if p.poll() is None:
+ p.terminate()
+ for p in processes:
+ try:
+ p.wait(timeout=10)
+ except subprocess.TimeoutExpired:
+ p.kill()
+ p.wait()
+
+ def check_restricted_daemon_login(self):
+ payload = {'jsonrpc': '2.0', 'id': '0', 'method': 'get_block_count'}
+
+ def status(port, auth=None):
+ url = 'http://127.0.0.1:{}/json_rpc'.format(port)
+ return requests.post(url, json=payload, auth=auth, timeout=5).status_code
+
+ for port in (18184, 18194, 18185, 18186):
+ assert status(port) == 401
+
+ for port in (18184, 18194, 18186):
+ assert status(port, HTTPDigestAuth(DAEMON_USER, DAEMON_PASS)) == 200
+
+ assert status(18185, HTTPDigestAuth('env_lover', DAEMON_PASS)) == 200
+ assert status(18195) == 200
+ assert status(18196) == 200
+
+ payload['method'] = 'get_connections'
+ main = requests.post('http://127.0.0.1:18185/json_rpc', json=payload,
+ auth=HTTPDigestAuth('env_lover', DAEMON_PASS), timeout=5)
+ assert main.status_code == 200 and 'result' in main.json()
+ restricted = requests.post('http://127.0.0.1:18195/json_rpc', json=payload, timeout=5)
+ assert restricted.status_code != 200 or 'error' in restricted.json()
+
+ def test_restricted_no_login_requires_port(self):
+ monerod = os.path.join(os.environ['FUNCTIONAL_TESTS_DIRECTORY'],
+ '..', '..', 'bin', 'monerod')
+ with tempfile.TemporaryDirectory() as data_dir:
+ result = subprocess.run([monerod, '--regtest', '--offline', '--non-interactive',
+ '--rpc-restricted-no-login', '--rpc-bind-port', '18187',
+ '--p2p-bind-port', '18287', '--zmq-rpc-bind-port', '18387',
+ '--rpc-ssl', 'disabled', '--data-dir', data_dir],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ universal_newlines=True, timeout=30)
+ assert result.returncode != 0
+ assert '--rpc-restricted-no-login requires --rpc-restricted-bind-port' in result.stdout
+
def test_wallet_login_required(self):
print('Attempting to connect to wallet server loginless with RPC digest authentication required...')
bad_wallet = Wallet(idx = WALLET_IDX)Why this scored 32/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.