3 minor findings · 4 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding · 2 suggestions. See the Run archive for their assessments.
Findings
[minor] · Startup can replace an active Unix RPC socket
A second node using the same custom socket path can take over the first node’s RPC endpoint, sending new clients to the wrong instance.
Location: src/netbase.cpp:801 (head).
Details and suggested fix
UnixSocketAddr::PreparePath() removes an existing socket without checking whether a listener is using it, so the later bind() cannot report the existing-listener conflict. For example, a second bitcoind using the same absolute -rpcbind=unix:<path> unlinks the first node’s socket path and binds its own listener there. The first node keeps running, but new clients reach the second node. Different credentials produce authorization failures; shared rpcauth lets commands run on the wrong node. Stopping the second node does not restore the path. This affects explicit absolute paths and relative paths that escape the datadir with ..; the default and datadir-relative paths are under the locked network datadir. The same unconditional removal exists for -ipcbind. No in-tree configuration shares a custom path, so whether operators encounter this is unconfirmed. Before unlinking, try to connect to the path and report the existing “probably already running” error if a listener responds. Remove the socket only when the connection returns ECONNREFUSED.
[minor] · bitcoin-cli rejects -rpcconnect=0.0.0.0 before connecting
The new validity check rejects a destination that previously reached a local listener on Linux; affected callers are unconfirmed.
Location: src/netbase.cpp:834 (head).
Details and suggested fix
bitcoin-cli now connects through SocketAddr::Connect(), which returns early when IsValid() is false. For a CService, that check rejects 0.0.0.0 and the IPv6 unspecified address. Previously, HTTPClient::Connect() passed each resolved CService directly to ConnectDirectly(), which has no such check. On Linux, connecting to 0.0.0.0 reaches a local listener. As a result, bitcoin-cli -rpcconnect=0.0.0.0, for example when copied from rpcbind=0.0.0.0, now fails with “Could not connect to the server.” With -rpcwait and the default -rpcwaittimeout=0, it retries indefinitely. Keep the validity check in Proxy::Connect() and remove it from the CService branch of SocketAddr::Connect(); an invalid Unix path already fails in GetSockAddr(). Update the unit tests that expect SocketAddr{}.Connect() to return null. No in-tree caller or test uses this destination, so production use is unconfirmed.
[minor] · BitcoinHTTPConnection.reset_conn() drops the configured timeout
Functional-test TCP sockets can block without limit, while Unix sockets use a fixed 60-second timeout that ignores --timeout-factor.
Location: test/functional/interface_http.py:48 (head).
Details and suggested fix
The base reset_conn() constructed HTTPConnection with timeout=self.timeout, scaled from node.rpc_timeout. The current method still constructs that object, but then replaces it before connecting. The TCP branch omits timeout, so http.client uses its default of no timeout. The Unix branch also omits it, so UnixHTTPConnection uses its fixed 60-second default. Helpers such as recv_raw() in expect_timeout() rely on the constructor timeout. If the server never responds or closes, a TCP test can hang instead of failing after rpc_timeout. Remove the first, overwritten construction and pass timeout=self.timeout to both connection constructors.
Optional improvements
[suggestion] · Release note overstates when a non-socket path prevents startup
A node can start without one configured Unix RPC socket if another endpoint binds successfully.
Location: doc/release-notes-36434.md:20 (head).
Details and suggested fix
The release note says startup fails if the path exists and is not a socket. PreparePath() does fail that endpoint, but InitHTTPServer() only logs a warning for each failed endpoint and returns failure only if none bind. For example, with -rpcbind=unix -rpcbind=unix:/some/regular-file, the node starts and serves RPC without the second socket. The same applies when a Unix path is configured alongside a TCP -rpcbind and -rpcallowip. The functional test covers only a single failing endpoint. Clarify that binding that endpoint fails without deleting the existing file, and that startup fails only if no RPC endpoint can be bound.
[suggestion] · Unix RPC sockets cannot grant group access
Deployments that grant RPC access through group membership cannot use the Unix socket, even when the cookie is group-readable through -rpccookieperms.
Location: src/httpserver.cpp:840 (head).
Details and suggested fix
After bind(), the socket mode is always replaced with 0600. The stated concern is that the process umask might leave the socket accessible to other local users, but SetupEnvironment() sets umask 0077 in bitcoind and bitcoin-qt before binding. The socket is therefore already owner-only, as are directories created by create_directories; the documented “default permissions” for parent directories are 0700 in practice. No configuration can grant the socket group access. doc/init.md describes controlling bitcoin-cli access by group membership, and -rpccookieperms=group makes the cookie group-readable for that purpose. With -rpcbind=unix, those group members can read the cookie but cannot connect, so such deployments must use TCP. If group access is out of scope, document that and correct the comment. Otherwise, apply the -rpccookieperms mode, or a dedicated option, to the socket while keeping owner-only access as the default.
[suggestion] · The negative log check in rpc_bind.py cannot match
The expected log message omits the unix: prefix, so the assertion cannot detect the message it is meant to exclude.
Location: test/functional/rpc_bind.py:242 (head).
Details and suggested fix
InitHTTPServer() logs Binding RPC on address %s using ToStringAddrPort(), which formats a Unix socket as unix:/tmp/.... The unexpected_msgs entry uses Binding RPC on address {unix_bind} without the prefix. Because assert_debug_log() checks for a substring, that entry cannot match the real log line. The later assert not os.path.exists(unix_bind) still provides some coverage, but the log assertion adds none. Include the unix: prefix, as the next block does.
[suggestion] · Connection error can name an address that bitcoin-cli never tried
If an earlier address exhausts the shared deadline, the error pairs that attempt’s failure with the last resolved address, which may not have been contacted.
Location: src/bitcoin-cli.cpp:1296 (head).
Details and suggested fix
In CallRPC(), the connection loop breaks when the shared deadline expires, but the error reports host_and_sockaddrs.second.back() alongside last_error. If -rpcconnect resolves to several addresses and the first attempt times out, the message names the last resolved address even though that address was never tried. Before this change, the error named the user-supplied host and port. Track the last attempted SocketAddr for the error, or fall back to the -rpcconnect value. This affects only the diagnostic.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Share generic Unix socket path resolution with IPC
- [suggestion]: Assert restrictive Unix socket permissions
- [minor]: Socket permission hardening can follow a raced symlink