net/banstore: FIFO 4096 ban table is flushable with 4096 throwaway identities — a live 24 h ban on a real offender is evicted
Report
Suggested severity: Low (1,300 XE)
Area: net/banstore.go
Repo pin: 9787859 (testnet-0005)
Summary
The ban list is a bounded FIFO (4096). When it is full, the oldest ban is evicted to make room:
// net/banstore.go:129-141
for len(s.entries) >= s.max {
if !s.evictOldestLocked() { break }
}
Bans are added by netcheck rejections, and an attacker controls how often those happen: one connection attempt with a fresh peer ID and a wrong answer is enough to earn an entry. Churning 4096 identities therefore flushes every existing ban, including long (24 h) bans on peers that were isolated for a reason.
Verified against the shipped store: a 24 h ban on one peer → IsBanned=true; after 4 200 throwaway bans → live=4096, evictions=105, IsBanned(real offender)=false. The persisted bans.json snapshot also keeps only 4096 entries, so the eviction survives restart.
Impact
network_id / sys.min_protocol_version isolation becomes best-effort: a peer that was banned for speaking the wrong network or an old protocol can return after identity churn. Cost is roughly one connection plus one netcheck answer per ban (global limiter 32 RPS ≈ two minutes for the full flush).
Fix
Keep a separate, non-evictable set for security bans (wrong network id / protocol version) with a longer TTL, or evict by a policy that prefers short-lived / low-severity entries and never removes a ban younger than some floor. Cap per-IP/ASN ban creation so a single actor cannot fill the table.
Thread
Thanks for the report. We have confirmed the ban-table behaviour you describe and it is being handled; we will update this ticket when the fix is in.