XE-10126 · Bounty
P2P Inbound Connection Overflow: NetworkGater.InterceptSecured time-of-check to time-of-use race permits unbounded connection exhaustion
Closed · duplicate
—
web
filed 2026-11-12 10:07 UTC
by xe:e4cd6974
Report
Vulnerability Summary
In net/netcheck.go:310-350, NetworkGater manages connection limits for inbound peers:
func (g *NetworkGater) InterceptSecured(dir network.Direction, p peer.ID, _ network.ConnMultiaddrs) bool {
if g.isBanned(p) {
return false
}
if dir == network.DirInbound && !g.isTrusted(p) {
max := atomic.LoadInt64(&g.maxInbound)
if max > 0 && g.inbound.Load() >= max {
g.inboundRefused.Add(1)
return false
}
}
return true
}
// ConnectedF increments inbound count only AFTER handshake and negotiation complete
h.Network().Notify(&network.NotifyBundle{
ConnectedF: func(_ network.Network, conn network.Conn) {
if conn.Stat().Direction == network.DirInbound {
gater.inbound.Add(1)
}
go verifyPeer(h, conn.RemotePeer(), gater)
},
DisconnectedF: func(_ network.Network, conn network.Conn) {
if conn.Stat().Direction == network.DirInbound {
if gater.inbound.Add(-1) < 0 {
gater.inbound.Store(0)
}
}
},
})
A critical Time-of-Check to Time-of-Use (TOCTOU) concurrency vulnerability exists:
- Non-Atomic Check: In
InterceptSecured,g.inbound.Load() >= maxreads the current count, but does not atomically reserve or increment a connection slot. - Deferred Accounting:
gater.inbound.Add(1)is only executed in the asynchronousConnectedFnotification bundle after the connection completes transport security (TLS/Noise) and stream multiplexer negotiation. - Concurrency Burst Bypass: When an attacker initiates hundreds or thousands of simultaneous TCP connections, all concurrent connections evaluate
InterceptSecuredbefore any of them triggerConnectedF. At evaluation time,g.inbound.Load()remains belowmaxInbound(default 256).
As a result, all connections pass the security gater check. Once upgraded, ConnectedF runs repeatedly, blowing past defaultMaxInboundConns without constraint.
Impact & Severity
- File Descriptor & Socket Starvation: Thousands of unauthorized concurrent libp2p connections saturate host file descriptors (
EMFILE) and kernel TCP buffers. - Memory Exhaustion: Each established peer session allocates multiplexer buffers (yamux/mplex), exhausting validator RAM and triggering kernel OOM termination.
- Consensus & Sync Disruption: Legitimate validators and timekeepers are unable to dial or maintain P2P gossip streams with the node.
Proposed Remediation
- Atomically reserve slots in
InterceptSecured:if dir == network.DirInbound && !g.isTrusted(p) { max := atomic.LoadInt64(&g.maxInbound) if max > 0 { if cur := g.inbound.Add(1); cur > max { g.inbound.Add(-1) g.inboundRefused.Add(1) return false } } } - Remove the delayed increment from
ConnectedFand ensure thatDisconnectedF(or handshake failure) decrements the counter reliably.
Thread
Joseph Denneteam2026-11-20 00:33 UTCdesk
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-10126 and says what differs; it is read like any other.