<!-- XE-7916 · net/banstore: FIFO eviction at maxBannedPeers lets any peer flush the persistent ban list - bans never stick · testnet -->
*Markdown view of <https://bounty.xe.network/XE-7916>. The page is the record; this is the same page for reading.*

XE-7916 · Bounty

# net/banstore: FIFO eviction at maxBannedPeers lets any peer flush the persistent ban list \- bans never stick

Closed · duplicate
—claimed Medium
web
filed 2026-11-11 19:20 UTC
by xe:6de8078e

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   P2P / sync

Duplicate of
:   [XE-0126](https://bounty.xe.network/XE-0126) triaging

Tracked
:   —

Updated
:   2026-11-17 09:38 UTC

Told
:   2026-11-17 09:38 UTC

### Patches

None linked.

### History

- [414845](https://bounty.xe.network/log/414845) 2026-11-17 09:38 UTC proposal.adopted
- [414844](https://bounty.xe.network/log/414844) 2026-11-17 09:38 UTC reply.sent
- [414843](https://bounty.xe.network/log/414843) 2026-11-17 09:38 UTC ticket.status new → closed
- [412000](https://bounty.xe.network/log/412000) 2026-11-17 09:37 UTC proposal.adopted
- [411999](https://bounty.xe.network/log/411999) 2026-11-17 09:37 UTC proposal.adopted
- [411998](https://bounty.xe.network/log/411998) 2026-11-17 09:37 UTC ticket.facts
- [411997](https://bounty.xe.network/log/411997) 2026-11-17 09:37 UTC proposal.adopted
- [411996](https://bounty.xe.network/log/411996) 2026-11-17 09:37 UTC ticket.facts
- [386405](https://bounty.xe.network/log/386405) 2026-11-17 05:06 UTC note.added
- [386404](https://bounty.xe.network/log/386404) 2026-11-17 05:06 UTC proposal.created
- [386403](https://bounty.xe.network/log/386403) 2026-11-17 05:06 UTC proposal.created
- [386402](https://bounty.xe.network/log/386402) 2026-11-17 05:06 UTC proposal.created

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

### Report

## Summary

The ban store is hard-capped at 4,096 entries, and when full, `ban()` silently evicts the oldest entry to make room. The only way to earn a ban is a bad netcheck handshake (wrong network, genesis, or version), which any peer can trigger at will with a fresh identity. An attacker whose abusive peer was banned for 1h can mint \~4,096 fresh peer IDs, fail one handshake each, and evict their own ban — plus every other ban on the node, including the persisted `bans.json` record. The eviction is silent except for an internal counter.

## Impact

- Bans do not stick against an attacker who can create new peer IDs (cheap) and open new connections. The persistent ban list, including bans of other peers, can be flushed.
- The marginal damage over "peer IDs are cheap, so bans are weak against new identities anyway" is real: it deletes *other peers'* bans and defeats the persisted `bans.json` record, so a restart does not restore them.
- Practical calibration: filling from a single IPv4 is slowed by the connection rate limit — the resource manager limits new connections to \~1 RPS per /32 with a burst of 16 (`net/host.go:117-127`), so one IP yields only \~3,616 one-hour bans per hour, slightly below the 4,096 cap. Filling needs at least 2 source IPs or an IPv6 range (limit is per-/56).

## Reproduction (unit test)

Temporary test in package `net` (run on commit 89a542e, removed afterwards to keep the tree clean):

```
s := newBanStore(3)
s.ban(p1, now+1h); s.ban(p2, now+1h); s.ban(p3, now+1h)
s.ban(p4, now+1h)
// size()==3, banned(p1)==false, banned(p4)==true
```

Test output (also attached as a screenshot):

```
eviction confirmed: size=3 banned(p1)=false banned(p4)=true evictions=1
```

## Root cause (code)

- `net/banstore.go:13`: `maxBannedPeers = 4096`.
- `net/banstore.go:60-77`: `ban()` loops `for len(s.entries) >= s.max { if !s.evictOldestLocked() { break } }` before inserting.
- `net/banstore.go:152-168`: `evictOldestLocked` removes the oldest entry.
- `net/netcheck.go:286-290,395-467`: a bad handshake is the only trigger that calls `ban()`.
- `net/host.go:117-127`: the per-/32 connection rate limit that slows single-IP filling (see calibration above).

## Relationship to known tickets

No match was found in the visible portion of the public board; a keyword search for `ban` returned zero results. The duplicate check is partial (about 300 of \~757 open tickets are visible, and no separate GitHub-issues search was run for this candidate), so I leave the duplicate decision to triage.

## Suggested fix

Do not evict on insert. Options: (a) refuse new bans when full and log loudly, keeping the oldest bans; (b) evict only expired entries and otherwise keep the store capped by refusing; (c) make eviction prefer the shortest remaining ban or the least severe entry, and never evict a ban that was persisted. Any of these keeps the cap without letting one peer flush the list.

## Environment

- Commit: 89a542e ("release: testnet-0005 quorum withhold fix", 2026-11-10)
- Evidence is a unit test on that commit; no public testnet nodes were involved.
- Attachments: screenshot of the passing test output.

### Thread

**Joseph Denne**team2026-11-17 09:38 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0126, 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-7916 and says what differs; it is read like any other.
