<!-- XE-0125 · net/discovery: peerCount() counts inbound peers, so 24 sybil inbound connections stop DHT discovery permanently (no - -dial means no recovery) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0125>. The page is the record; this is the same page for reading.*

XE-0125 · Bounty

# net/discovery: peerCount() counts inbound peers, so 24 sybil inbound connections stop DHT discovery permanently (no --dial means no recovery)

Triaging
claimed Minor
[xe#201](https://github.com/xeprotocol/xe/issues/201)
filed 2026-10-29 16:51 UTC
by hayokakoweda75

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-08 20:17 UTC

Told
:   2026-11-08 20:18 UTC

### Patches

- [xe#207](https://github.com/xeprotocol/xe/pull/207) open by NePreby
  fix(net/discovery): count outbound peers to prevent inbound sybil discovery suppression (fixes #201)
- [xe#239](https://github.com/xeprotocol/xe/pull/239) open by tipprb
  fix(net/discovery): count outbound peers to prevent inbound sybil discovery suppression (fixes #201)

### History

- [43819](https://bounty.xe.network/log/43819) 2026-11-08 20:19 UTC reply.mirror\_failed
- [43779](https://bounty.xe.network/log/43779) 2026-11-08 20:18 UTC proposal.adopted
- [43778](https://bounty.xe.network/log/43778) 2026-11-08 20:18 UTC reply.sent
- [43221](https://bounty.xe.network/log/43221) 2026-11-08 20:18 UTC proposal.adopted
- [43220](https://bounty.xe.network/log/43220) 2026-11-08 20:18 UTC ticket.facts area
- [43219](https://bounty.xe.network/log/43219) 2026-11-08 20:18 UTC proposal.adopted
- [43218](https://bounty.xe.network/log/43218) 2026-11-08 20:18 UTC ticket.facts
- [43217](https://bounty.xe.network/log/43217) 2026-11-08 20:18 UTC proposal.adopted
- [43216](https://bounty.xe.network/log/43216) 2026-11-08 20:18 UTC ticket.facts
- [43215](https://bounty.xe.network/log/43215) 2026-11-08 20:18 UTC proposal.adopted
- [43214](https://bounty.xe.network/log/43214) 2026-11-08 20:18 UTC ticket.facts
- [43213](https://bounty.xe.network/log/43213) 2026-11-08 20:18 UTC proposal.adopted

[Full history](https://bounty.xe.network/log?ref=XE-0125) · [JSON](https://bounty.xe.network/v1/tickets/XE-0125) · [markdown](https://bounty.xe.network/XE-0125.md)

### 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

1. 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.
2. `peerCount()` is now ≥ `target`, so `round()` — the only code that dials peers learned from the rendezvous namespace — is never called again.
3. The bootstrap watchdog only re-dials statically configured `--dial` peers (`node/node.go:688-699`); with no `--dial`, there is no recovery path.
4. 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.

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

**Joseph Denne**team2026-11-08 20:17 UTCdesk

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.
