1 major finding · 3 minor findings · 3 suggestions
Findings
[major] · Wildcard listeners use the unspecified address as each inbound peer’s local address
On wildcard listeners, inbound peers lose addrbind in getpeerinfo, and peers connecting to different same-family local addresses share a GETADDR cache key, enabling address-linking by any inbound peer.
Location: src/common/sockman.cpp:514 (head).
Details and suggested fix
SocketHandlerListening now passes the listening socket’s address as the connection’s local address. With the default :: and 0.0.0.0 listeners, or a wildcard -bind or -whitebind, that is an unspecified address rather than the IP and port the peer connected to. CConnman::EventNewConnectionAccepted stores it in CNode::addrBind and uses it to derive m_network_key.
Because 0.0.0.0 and :: are invalid addresses, getpeerinfo omits addrbind for these inbound peers. The shared network key also indexes the GETADDR response cache. A multi-homed node therefore sends identical cached ADDR responses to peers reaching different IPv4 addresses, or different IPv6 addresses, through one wildcard listener. Any inbound peer can use those responses to link the addresses, contrary to the documented per-local-socket separation. Explicit specific binds, onion binds, and I2P inbound connections are unaffected; the functional tests bind 127.0.0.1 and do not cover this case.
Keep the listening address for the m_listen_permissions and m_onion_binds lookups, but pass the accepted socket’s local address separately to EventNewConnectionAccepted. Add a test using a wildcard listener.
[minor] · Unordered peer iteration disrupts the GUI peer table and makes saved anchors arbitrary
Unspecified m_nodes iteration order can remove and re-add connected GUI rows, losing the selected peer, and can save a block-relay probe instead of an established peer as an anchor.
Location: src/net.h:1488 (head).
Details and suggested fix
Changing m_nodes from an append-ordered vector to std::unordered_map makes GetNodeStats() and GetCurrentBlockRelayOnlyConns() return entries in unspecified order.
getpeerinfo sorts its results, but NodeImpl::getNodesStats() passes GetNodeStats() directly to PeerTableModel::refresh(), which relies on node-ID order. If the order changes, the table removes and re-adds still-connected rows. This clears the selection, and updateDetailWidget() then hides the details panel.
At shutdown, StopNodes() truncates GetCurrentBlockRelayOnlyConns() to MAX_BLOCK_RELAY_ONLY_ANCHORS. The base kept the earliest-added block-relay peers; the new iteration order can instead save an extra block-relay probe in place of an established peer. Whether this measurably weakens eclipse resistance after restart is unclear.
Use std::map<NodeId, CNode*> to preserve node-ID order for consumers, or sort the results within both GetNodeStats() and GetCurrentBlockRelayOnlyConns().
[minor] · An I2P connection attempt without a proxy aborts in debug and fuzz builds
A manual I2P connection without -i2psam reaches an Assume and aborts in debug and fuzz builds; release builds fail the connection attempt as the base did.
Location: src/common/sockman.cpp:157 (head).
Details and suggested fix
Without -i2psam, ConnectNode passes no proxy when GetProxy(NET_I2P) fails. The base used the SAM path only when the target was I2P and a proxy was available; otherwise it tried ConnectDirectly(), which fails cleanly for I2P. The new code sends every I2P CService through the I2P branch, where Assume(proxy.has_value()) aborts in builds with ABORT_ON_FAILED_ASSUME, including debug and fuzz builds.
A manual path can reach this check: addnode <x>.b32.i2p onetry resolves to a valid I2P CService. The connman fuzz target can also generate an I2P address without configuring a proxy. Release builds do not abort and, as in the base, fail the connection attempt. Return std::nullopt when an I2P target has no proxy, without using Assume; an explanatory log line is optional.
[minor] · Unpolled connections skip the per-connection I/O completion hook
When receive is paused and nothing is queued to send, the connection is not polled and its inactivity check is deferred until the message handler drains the queue; no indefinite stall was identified.
Location: src/common/sockman.cpp:432 (head).
Details and suggested fix
The base SocketHandlerConnected ran InactivityCheck for every node with a socket on each pass. Now GenerateWaitSockets() excludes a connection when both ShouldTryToRecv and ShouldTryToSend return false, and SocketHandlerConnected calls EventIOLoopCompletedForOne only for entries in events_per_sock. For CConnman, this occurs when fPauseRecv is set because the process queue exceeds the receive-flood size and nothing is queued to send. Inactivity and handshake timeouts are therefore deferred until the message handler drains the queue. No way for a peer to keep this state indefinitely was identified.
The header describes the hook as running after a connection’s send-and-receive iteration and says it can run periodic tasks. Call EventIOLoopCompletedForOne for every ID in the connected snapshot, while keeping ids_per_sock for I/O dispatch, or document that the hook runs only for polled connections.
Optional improvements
[suggestion] · The connman fuzz target no longer exercises the socket I/O loop
Removing the fuzz action for the socket loop leaves the rewritten readiness, receive-dispatch, and accept paths without coverage in the connman fuzz target.
Location: src/test/fuzz/connman.cpp:213 (base).
Details and suggested fix
The base connman fuzz target called SocketHandlerPublic(), exercising GenerateWaitSockets, WaitMany, send and receive on FuzzedSock nodes, and listening and accept paths on sockets created by InitBindsPublic. This change removes that action and wrapper without adding a replacement. SockMan::ThreadSocketHandler() is a private loop that runs until interrupted, and there are no SockMan tests.
As a result, the target no longer fuzzes SockMan::GenerateWaitSockets, SocketHandlerConnected dispatch to EventGotData, EventGotEOF, and EventGotPermanentReadError, or the listening and accept paths through NewSockAccepted, including rejection and CloseConnection. The FuzzedSock instances attached through AddTestNode are only touched by PushMessage’s optimistic send. Factor one loop iteration into a protected method, such as SocketHandlerOnce(), have ThreadSocketHandler call it, expose it through ConnmanTestMsg, and restore the fuzz action.
[suggestion] · RecordBytesSent() reacquires the global counter lock while cs_vSend is held
The send path restores the per-peer-to-global lock nesting that #20816 deliberately removed, increasing lock-scope coupling without an identified deadlock.
Location: src/net.cpp:1589 (head).
Details and suggested fix
SendMessagesAsBytes() requires node.cs_vSend and now calls RecordBytesSent(), which acquires the global m_total_bytes_sent_mutex. Both callers hold cs_vSend: EventReadyToSend through WITH_LOCK, and PushMessage during its optimistic write. In the base, both recorded bytes after releasing cs_vSend. PR #20816 made that change to reduce the per-peer lock’s scope. No deadlock was identified, but the current code holds a per-peer lock while acquiring a global one.
Return the byte count from SendMessagesAsBytes() and have both callers invoke RecordBytesSent() after releasing cs_vSend. PushMessage will need to capture the return value again.
[suggestion] · sockman.h uses standard-library types without including their headers
The header relies on transitive includes for std::unordered_map, string types, and fixed-width integer types.
Location: src/common/sockman.h:348 (head).
Details and suggested fix
sockman.h uses std::unordered_map, std::string, std::string_view, int64_t, uint8_t, and uint16_t, but its standard include list does not include their defining headers. The developer notes require headers to include directly used definitions, since changes to transitive includes can break compilation. Add <cstdint>, <string>, <string_view>, and <unordered_map>.