Review report

core: PR #36434

2 minor findings · 5 suggestions

Earlier concerns neither republished nor resolved: 2 minor findings · 3 suggestions. See the Run archive for their assessments.

Findings

Link

[minor] · Startup replaces a live Unix RPC socket at a shared custom path

If independent nodes share a custom Unix RPC socket path, the later startup redirects new clients to itself while the first node keeps running.

Location: src/netbase.cpp:801 (head).

Details and suggested fix

PreparePath() checks only the existing file's type before unlinking it, and BindAndStartListening() calls it immediately before bind(). Two instances with separate datadirs and permission to remove the same absolute custom socket path can therefore replace one another's live endpoint. A relative path escaping the datadir with .. can cause the same collision. Clients using the first node's cookie receive authorization errors; clients using credentials accepted by both nodes can execute commands on the wrong node. Stopping the second node does not restore the first endpoint. The directory lock protects the default datadir-local case, and IPC already uses the same cleanup approach. Before unlinking, probe the socket with connect(): reject a live listener and remove the socket only on ECONNREFUSED. This catches an already-running listener but still permits a concurrent-startup race. If live replacement is intentional, document it rather than describing cleanup only as stale-file removal. No in-tree configuration sharing a custom path was found, so production impact is unconfirmed.


Link

[minor] · BitcoinHTTPConnection.reset_conn() drops the configured socket timeout

The HTTP functional-test helper now uses unbounded TCP sockets or a fixed 60-second Unix timeout instead of the configured, timeout-factor-scaled RPC timeout.

Location: test/functional/interface_http.py:48 (head).

Details and suggested fix

reset_conn() still constructs an HTTPConnection with timeout=self.timeout, but both branches replace it before connecting. The replacement TCP connection omits the timeout and uses the global default, which remains unbounded in this test. The Unix replacement instead uses UnixHTTPConnection's 60-second default. Callers such as check_default_connection() and the raw-receive checks do not all install their own deadline. If the server neither replies nor closes, the TCP test can therefore wait until an external timeout terminates it rather than failing after node.rpc_timeout. Remove the overwritten construction and pass timeout=self.timeout to both replacement constructors.


Optional improvements

Link

[suggestion] · Unix RPC sockets have no configurable group-access mode

On Linux, group clients cannot connect through the configured Unix socket even when -rpccookieperms=group lets them read the RPC cookie.

Location: src/httpserver.cpp:840 (head).

Details and suggested fix

After binding, the server unconditionally replaces the socket mode with 0600. Group members therefore lack the socket write permission Linux requires for connect(), even in the group-based RPC deployment described in doc/init.md. A manual chmod is lost when startup recreates the socket, leaving these deployments dependent on TCP or external permission management. Provide an opt-in socket-permission setting for group access while retaining owner-only access by default. Widening socket access also makes the unauthenticated REST endpoints reachable when -rest is enabled. The current comment should also account for SetupEnvironment() already setting umask 0077: removing the chmod alone would still leave group access disabled.


Link

[suggestion] · Release notes overstate when a non-socket path stops startup

An existing non-socket path prevents that endpoint from binding, but another successful RPC bind allows startup to continue.

Location: doc/release-notes-36434.md:20 (head).

Details and suggested fix

The note says startup fails whenever the socket path exists and is not a socket. PreparePath() does reject that endpoint without deleting the file, but InitHTTPServer() only logs its failure and continues. For example, -rpcbind=unix -rpcbind=unix:/some/regular-file can start successfully on the first socket. A Unix path plus a TCP bind can do the same when -rpcallowip is supplied. Reword the note to say that binding the affected endpoint fails and leaves the existing file untouched; failure to bind any RPC endpoint prevents HTTP server startup.


Link

[suggestion] · Discarded RPC bind addresses still emit exposure warnings

With -rpcbind=0.0.0.0 and no -rpcallowip, startup now emits the public-network warning even though it still binds only localhost.

Location: src/httpserver.cpp:260 (head).

Details and suggested fix

GetBindAddresses() logs the wildcard-address and lookup-failure warnings while parsing IP endpoints, before checking has_ip && !has_allowip. That configuration therefore produces warnings about an address the subsequent localhost fallback discards. Previously the fallback happened before lookup, so these endpoint warnings were not emitted. Defer them until after deciding to retain the IP endpoints, while preserving the existing localhost fallback and its configuration warning.


Link

[suggestion] · A negative Unix-bind log assertion cannot match the server message

The forbidden message omits the unix: prefix, so this assertion cannot detect an attempted Unix RPC bind.

Location: test/functional/rpc_bind.py:242 (head).

Details and suggested fix

unix_bind is a filesystem pathname, but InitHTTPServer() logs the endpoint through ToStringAddrPort(), producing Binding RPC on address unix:/tmp/.... Because assert_debug_log() matches literal substrings, f"Binding RPC on address {unix_bind}" cannot match that message. The following assert not os.path.exists(unix_bind) still checks for an unexpectedly created socket. Add unix: to the forbidden log message, as the next test block already does.


Link

[suggestion] · Unix RPC tests omit the promised owner-only mode check

The --httpunix tests verify the socket's type or existence but do not assert that its mode excludes group and other access.

Location: test/functional/interface_http.py:216 (head).

Details and suggested fix

Unix connections bypass -rpcallowip, and the release notes promise an owner-restricted socket. BindAndStartListening() explicitly installs that mode, but check_socket_exclusivity() only checks S_ISSOCK; the Unix bind tests likewise check type or existence. Add assert stat.S_IMODE(os.stat(path).st_mode) & 0o077 == 0 alongside the socket-type check. Testing the absence of group and other bits rather than requiring exactly 0o600 also preserves the test if the implementation later relies on the existing 0077 umask.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.