{"id":"XE-0125","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"201","source_url":"https://github.com/xeprotocol/xe/issues/201","reporter_id":39,"title":"net/discovery: peerCount() counts inbound peers, so 24 sybil inbound connections stop DHT discovery permanently (no --dial means no recovery)","area":"p2p-sync","claimed_tier":"minor","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T16:53:40.495310+00:00","updated_at":"2026-11-08T20:17:41.885067+00:00","source_created_at":"2026-10-29T16:51:37+00:00","told_at":"2026-11-08T20:18:50.412785+00:00","status_changed_at":"2026-11-08T20:18:36.648648+00:00","url":"https://bounty.xe.network/XE-0125","body":"**Suggested severity: Low (1,300 XE) — mechanism verified, full effect needs 24 inbound peers**\n**Area:** `net/discovery.go`, `net/netcheck.go` (accept gate)\n**Repo pin:** 9787859 (testnet-0005)\n\n## Summary\n\nDiscovery stops as soon as `Network().Peers()` reaches the target, and `Peers()` counts **inbound** connections too:\n\n```go\n// net/discovery.go:83-91\nwait := discoveryInterval\nif a.peerCount() < a.target {\n\tif n := a.round(ctx); n == 0 { wait = discoveryBackoff }\n}\n```\n\n```go\n// net/discovery.go:137-139\nfunc (a *AmbientDiscovery) peerCount() int {\n\treturn len(a.host.Network().Peers())\n}\n```\n\nInbound connections are gated only by `netcheck` (`network_id` + version, both public) — `InterceptAccept` returns `true` unconditionally (`net/netcheck.go:302-304`).\n\n## Chain\n\n1. 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.\n2. `peerCount()` is now ≥ `target`, so `round()` — the only code that dials peers learned from the rendezvous namespace — is never called again.\n3. The bootstrap watchdog only re-dials statically configured `--dial` peers (`node/node.go:688-699`); with no `--dial`, there is no recovery path.\n4. 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. `/ready` only needs one peer (`--ready-min-peers` default 1), so nothing alarms.\n\nVerified 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.\n\n## Fix\n\nCount 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.\n","patch_refs":[{"id":207,"repo":"xeprotocol/xe","kind":"pr","ref":"207","title":"fix(net/discovery): count outbound peers to prevent inbound sybil discovery suppression (fixes #201)","url":"https://github.com/xeprotocol/xe/pull/207","note":"","state":"open","author":"NePreby","added_by":"desk","created_at":"2026-10-29T17:36:51.559938+00:00"},{"id":238,"repo":"xeprotocol/xe","kind":"pr","ref":"239","title":"fix(net/discovery): count outbound peers to prevent inbound sybil discovery suppression (fixes #201)","url":"https://github.com/xeprotocol/xe/pull/239","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-02T00:04:19.431851+00:00"}],"thread":[{"id":1598,"source":"desk","source_ref":"reply:717","author":"Joseph Denne","team":true,"body":"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.","created_at":"2026-11-08T20:17:41.885067+00:00"}]}