1 minor finding · 5 suggestions
Findings
[minor] · Scope-blind deduplication skips required IPv6 RPC endpoints
Explicit IPv6 RPC endpoints with identical address bytes and ports but different interface scopes compare equal, so startup silently omits the second listener.
Location: src/httpserver.cpp:1371 (head).
Details and suggested fix
With the same link-local address configured on two interfaces, -rpcallowip=... -rpcbind=[fe80::1%eth0] -rpcbind=[fe80::1%eth1] requests two distinct socket endpoints. Lookup preserves their scope IDs, and GetSockAddr supplies them to bind, but CService ordering compares only the network, address bytes and port. After the first bind succeeds, endpoints_seen treats the second endpoint as a duplicate and skips it before logging or checking its required status. Unlike base, the node starts without attempting every distinct explicit endpoint. Another local account could bind the omitted endpoint and receive credentials from clients connecting there. Use a bind-specific deduplication key that includes the scope ID, without changing general CService comparison semantics, and test identical endpoints versus different scopes. No current RPC configuration producing this trigger was found, so production impact is unconfirmed.
Optional improvements
[suggestion] · Occupied default IPv6 RPC endpoints remain optional
The pre-existing credential exposure remains for non-default clients such as bitcoin-cli -rpcconnect=localhost when resolution selects an occupied ::1 endpoint before IPv4.
Location: src/httpserver.cpp:237 (head).
Details and suggested fix
If another local account already holds [::1]:port, its bind failure only produces a warning because the default IPv6 endpoint is optional for every error. A successful IPv4 bind then permits startup and cookie generation. With -rpcconnect=localhost, bitcoin-cli uses HTTP and sends the cookie to the first resolved address that accepts a connection; selecting ::1 depends on resolver ordering and AI_ADDRCONFIG. Although this exposure predates the PR and falls within its acknowledged non-default-client risk, distinguishing address-in-use from unavailable IPv6 would close this case without requiring IPv6 support. Return a structured error from BindAndStartListening and make EADDRINUSE fatal for default ::1, while retaining optional handling when IPv6 is unavailable. The bind implementation already identifies WSAEADDRINUSE, but currently reduces it to a string.
[suggestion] · RPC bind startup requirements lack upgrade documentation
Previously accepted configurations with unavailable IPv4 loopback or a partly failing explicit RPC bind list now abort startup, but no release note explains the migration.
Location: src/httpserver.cpp:1382 (head).
Details and suggested fix
Base started once any RPC endpoint bound successfully. This change instead aborts when default 127.0.0.1 fails, or when an explicit endpoint selected with -rpcallowip cannot be looked up or bound. A hostname entry alongside a working numeric entry therefore also changes from a warning to a startup failure. These failures occur before RPC authentication starts. Add a PR-specific release note, as requested by doc/developer-notes.md, explaining that default IPv4 loopback is now required, every active explicit -rpcbind must be numeric and bind successfully, and IPv6-only setups need both options, for example -rpcbind=[::1] -rpcallowip=::1. The existing -rpcbind help text also does not describe the new required-bind policy.
[suggestion] · RPC bind tests do not cover occupied IPv6 endpoints
The partial-bind tests only occupy IPv4, so they do not protect the distinction between optional default IPv6 and required explicit IPv6 binds.
Location: test/functional/rpc_bind.py:70 (head).
Details and suggested fix
run_partial_bind_test always occupies 127.0.0.1, and its explicit configuration lists that required endpoint before [::1]. Startup therefore fails before attempting explicit IPv6. Making explicit IPv6 optional would leave the assertions passing, as would making default IPv6 required while that endpoint remains available. The other loopback cases only exercise successful binds, and the failure assertion checks the generic HTTP initialization error. Under the existing IPv6 availability gate, add cases that occupy ::1 with an AF_INET6 socket and IPV6_V6ONLY: default mode should warn about the optional endpoint and serve RPC over IPv4, while an explicit IPv4-then-IPv6 configuration should fail on the required IPv6 endpoint. Assert the specific bind diagnostic in both cases.
[suggestion] · IPv4 bind recovery advice omits -rpcallowip
The default IPv4 bind error recommends specifying -rpcbind, but that option is ignored unless -rpcallowip is also present.
Location: src/httpserver.cpp:1385 (head).
Details and suggested fix
An IPv6-only operator following this advice by adding only -rpcbind=[::1] remains in default-loopback mode because BindDefaultLoopbackAddresses() returns true whenever -rpcallowip is empty. Startup then warns that -rpcbind was ignored and fails on the same required IPv4 endpoint. Although the ignored-option warning identifies the missing prerequisite, the recovery advice itself should mention both options, for example: “specify endpoints via -rpcbind together with -rpcallowip, e.g. -rpcbind=[::1] -rpcallowip=::1”.
[suggestion] · Overlapping RPC binds produce a misleading startup failure
With -rpcallowip, a wildcard followed by a same-family specific -rpcbind on the same port now aborts on Linux with an error blaming another Bitcoin Core instance.
Location: src/httpserver.cpp:1382 (head).
Details and suggested fix
For -rpcbind=0.0.0.0 -rpcbind=127.0.0.1, or [::] followed by [::1], the deduplication set retains both entries. BindAndStartListening starts listening on the wildcard before attempting the specific address. Linux rejects the second bind with EADDRINUSE despite SO_REUSEADDR, and the new required-bind handling aborts with “Bitcoin Core is probably already running.” Base instead warned and continued serving through the wildcard listener. Here bitcoind's own socket causes the conflict and already covers the requested address, so aborting adds no protection against an unserved endpoint being occupied by another process. Detect this overlap and report a targeted configuration error rather than suggesting another instance is responsible. Windows also rejects overlapping binds with SO_EXCLUSIVEADDRUSE; BSD/macOS may permit them. The prevalence of these configurations is unknown.