net/discovery: peerCount() counts inbound peers, so 24 sybil inbound connections stop DHT discovery permanently (no --dial means no recovery)
Report
Suggested severity: Low (1,300 XE) — mechanism verified, full effect needs 24 inbound peers
Area: net/discovery.go, net/netcheck.go (accept gate)
Repo pin: 9787859 (testnet-0005)
Summary
Discovery stops as soon as Network().Peers() reaches the target, and Peers() counts inbound connections too:
// net/discovery.go:83-91
wait := discoveryInterval
if a.peerCount() < a.target {
if n := a.round(ctx); n == 0 { wait = discoveryBackoff }
}
// net/discovery.go:137-139
func (a *AmbientDiscovery) peerCount() int {
return len(a.host.Network().Peers())
}
Inbound connections are gated only by netcheck (network_id + version, both public) — InterceptAccept returns true unconditionally (net/netcheck.go:302-304).
Chain
- An attacker opens 24 inbound connections from a few IPs (inbound cap is 256, per-IP 8) with distinct peer IDs that answer netcheck correctly.
peerCount()is now ≥target, soround()— the only code that dials peers learned from the rendezvous namespace — is never called again.- The bootstrap watchdog only re-dials statically configured
--dialpeers (node/node.go:688-699); with no--dial, there is no recovery path. - Block/vote/cert sync and attestation all iterate
Network().Peers()(net/sync.go:351,net/certsync.go:53,node/attestation.go:121), so the node stays confined to the attacker's set./readyonly needs one peer (--ready-min-peersdefault 1), so nothing alarms.
Verified with target=1: after one inbound peer connected, rounds stayed 0 at t=31/62/93 s; after that peer disconnected, rounds=1. End-to-end finality impact is an inference: it needs the 24 sybil hosts to be live, which this environment did not have.
Fix
Count only outbound/established-by-us peers, or count discovery-sourced peers separately from inbound ones; require at least one discovery round per interval regardless of peerCount; make the watchdog dial from the discovered set, not only from static --dial entries.
Thread
Thanks for the report. We have confirmed the peer-discovery behaviour you describe and it is being handled; we will update this ticket when the fix is in.