3 minor findings · 4 suggestions
Earlier concerns neither republished nor resolved: 2 suggestions. See the Run archive for their assessments.
Findings
[minor] · Startup unlinks an active RPC socket instead of reporting a conflict
A second node using the same custom Unix socket path can take over the first node’s RPC endpoint, unlike a TCP bind that reports an existing listener.
Location: src/netbase.cpp:801 (head).
Details and suggested fix
UnixSocketAddr::PreparePath() removes any existing socket at the path without checking whether a listener is using it. Because BindAndStartListening() calls this before bind(), the Unix-socket path cannot produce the “probably already running” error for an active socket.
If a second bitcoind with a different datadir starts with the same absolute -rpcbind=unix:<path>, it removes the first node’s pathname and binds its own listener there. The first node keeps running, but new clients reach the second node. If both nodes share RPC credentials, commands intended for the first run on the second; otherwise, authentication fails. Stopping the second node does not restore the first node’s path.
The datadir lock protects the default and datadir-relative paths, but not absolute paths or relative paths that escape the datadir with ... The release notes describe removing a stale socket left by a previous run, which is narrower than the behavior here. Before unlinking, attempt to connect to the path: if the connection succeeds, return the existing “probably already running” error; remove the socket only on ECONNREFUSED. -ipcbind uses the same unconditional removal in ProcessImpl::bind(). No in-tree configuration shares a custom path, so whether this occurs in practice depends on operator configuration.
[minor] · Socket permission change can follow a symlink swapped in after bind
A local user able to modify the socket’s parent directory could race startup and make bitcoind change the mode of another file it owns.
Location: src/httpserver.cpp:846 (head).
Details and suggested fix
After bind(), fs::permissions(socket_path, owner_read | owner_write, replace) sets permissions by pathname. Without perm_options::nofollow, std::filesystem::permissions follows symlinks.
If another local user can unlink entries in the socket’s parent directory, they could replace the new socket with a symlink between bind() and this call. bitcoind would then apply mode 0600 to the symlink target, for example removing a directory’s search bit or group read access to a file owned by the bitcoind user. If bitcoind runs as root, any file could be affected. The earlier symlink_status() check in PreparePath() does not protect this step. SetupEnvironment() already sets umask 0077, so bind() creates the socket as owner-only. Remove the pathname chmod and rely on the umask, or apply permissions without following symlinks. The documentation advises using a restricted directory, and no in-tree configuration places the socket where another user can modify the directory, so practical exposure depends on configuration.
[minor] · Unix peer-path filter depends on plain char signedness
On platforms with signed char, a client socket path containing non-ASCII bytes is replaced with unix; on platforms with unsigned char, it is retained.
Location: src/netbase.cpp:736 (head).
Details and suggested fix
The filter [](char c) { return c < 0x20 || c == 0x7F; } compares plain char. Where char is signed, such as x86, bytes 0x80–0xFF are negative and match c < 0x20, so a valid UTF-8 client path is replaced by unix. Where char is unsigned, such as aarch64 Linux, the same path is retained.
This affects only the peer label in HTTP logs and in JSONRPCRequest::peerAddr, which is also only logged. Cast to unsigned char before comparing, as LogEscapeMessage() does, so the result is consistent across platforms. bitcoin-cli and the test client do not bind named client sockets, so no current caller produces such a path.
Optional improvements
[suggestion] · Release notes overstate when a non-socket path prevents startup
A node can start without the configured Unix socket if another RPC endpoint binds successfully.
Location: doc/release-notes-36434.md:21 (head).
Details and suggested fix
The release notes say, “Startup fails if the path exists and is not a socket.” PreparePath() fails for that endpoint, but InitHTTPServer() only logs a warning when an endpoint fails to bind. Startup fails only if no endpoint binds successfully.
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. Revise the wording to say that binding that endpoint fails, and startup fails only if no RPC endpoint can be bound.
[suggestion] · Unix RPC socket cannot grant group access
Deployments that use group membership for RPC access cannot use the Unix socket, even though -rpccookieperms supports group-readable cookies.
Location: src/httpserver.cpp:842 (head).
Details and suggested fix
After binding, the socket mode is always set to 0600. The comment says this is needed because the umask “may leave it accessible to other local users,” but SetupEnvironment() always sets umask 0077, so the socket would be owner-only without the chmod. No configuration can therefore grant the socket group access.
doc/init.md says access to bitcoin-cli can be controlled by group membership, and -rpccookieperms=group lets group members read the cookie. With -rpcbind=unix, those members can read the cookie but get EACCES when connecting to the socket, so these deployments must use TCP. Clarify whether group access is out of scope. If it is not, let the socket mode follow -rpccookieperms or add a dedicated option, with owner-only access as the default. Also update the comment to note that the umask already restricts the mode.
[suggestion] · Negative log check in rpc_bind.py never matches
The expected substring omits the unix: prefix, so the check cannot detect the corresponding bind log line.
Location: test/functional/rpc_bind.py:242 (head).
Details and suggested fix
InitHTTPServer() logs Binding RPC on address %s using ToStringAddrPort(), which produces unix:/tmp/... for a Unix socket. The unexpected_msgs entry uses f"Binding RPC on address {unix_bind}", without that prefix. Because assert_debug_log() uses substring matching, the entry cannot match the actual log line.
The later assert not os.path.exists(unix_bind) still provides coverage, but the log assertion adds none. Include the prefix as f"Binding RPC on address unix:{unix_bind}", as the next block does.
[suggestion] · Functional tests do not verify the RPC socket’s owner-only mode
The tests do not assert the documented owner-only restriction applied to the RPC socket.
Location: test/functional/interface_http.py:213 (head).
Details and suggested fix
The --httpunix checks in interface_http.py and rpc_bind.py assert only that the path is a socket. The release notes and JSON-RPC-interface.md say the socket is restricted to its owner, and BindAndStartListening() applies mode 0600.
Add an assertion that stat.S_IMODE(st_mode) & 0o077 == 0 beside the socket-type check, as rpc_users.py does for cookie permissions. If the explicit chmod remains, asserting exactly 0o600 would also cover it.
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]: Report the address bitcoin-cli actually attempted