net: no dial-address filtering — a peer's advertised multiaddr makes the node connect to loopback/private/link-local addresses (blind SSRF / internal port probe)
Report
Suggested severity: Medium (2,500 XE)
Area: net/netcheck.go (dial filter), net/discovery.go (dial of advertised addrs)
Repo pin: 9787859 (testnet-0005)
Summary
The gater accepts every dial target:
// net/netcheck.go:298-300
func (g *NetworkGater) InterceptAddrDial(_ peer.ID, _ ma.Multiaddr) bool {
return true
}
AmbientDiscovery dials whatever multiaddrs come back from the rendezvous namespace it reads:
// net/discovery.go:107-127
for pi := range ch {
...
dialCtx, dcancel := context.WithTimeout(ctx, discoveryDialTimeout)
err := a.host.Connect(dialCtx, pi) // pi.Addrs is entirely peer-supplied
A peer record is self-signed, so the Addrs list can contain /ip4/127.0.0.1/..., /ip4/10.0.0.0/8, /ip4/192.168.0.0/16 or /ip4/169.254.169.254/.... Nothing between FindPeers and Connect inspects the address, and InterceptAddrDial returns true for all of them. The node therefore opens TCP connections from its own network position to targets chosen by an unauthenticated peer — a blind SSRF / internal port probe.
PoC (executed)
InterceptAddrDial(/ip4/169.254.169.254/tcp/80) = true
InterceptAddrDial(/ip4/10.0.0.5/tcp/22) = true
FindPeer(attacker) -> addrs=[/ip4/127.0.0.1/tcp/37427]
victim dial -> internal endpoint hit: 32 bytes (libp2p multistream handshake)
A listener on loopback received the connection and the multistream handshake, i.e. the dial actually left the node toward an address the peer selected.
Impact
- Reachability oracle for the node's private network: an attacker learns which internal hosts/ports accept TCP, one dial at a time, from the victim's own position (bypassing the attacker's own network restrictions).
- Any internal service that answers before libp2p negotiation completes sees a connection/request from the node (log poisoning, triggering side effects on GET-style endpoints is protocol-dependent; the handshake itself is fixed bytes, so this is not a data-exfiltration primitive).
- On cloud hosts, link-local
169.254.169.254is dialable, which is the classic metadata target even though the payload here is not an HTTP request.
Suggested fix
Reject non-globally-routable addresses in InterceptAddrDial (loopback, RFC1918, link-local, ULA, unspecified, multicast), or filter AddrInfo.Addrs in the discovery loop before dialing. Keep an explicit allowlist for the private test networks that need it, and add a test that a record advertising 127.0.0.1 / 169.254.169.254 is never dialed.
Thread
Thanks for the report. We have confirmed the behaviour you describe in the node's peer-dialing path and it is being handled; we will update this ticket when the fix is in.