{"id":"XE-7916","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":1790,"title":"net/banstore: FIFO eviction at maxBannedPeers lets any peer flush the persistent ban list - bans never stick","area":"p2p-sync","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0126","tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-11T19:20:18.956266+00:00","updated_at":"2026-11-17T09:38:14.977489+00:00","source_created_at":null,"told_at":"2026-11-17T09:38:15.035910+00:00","status_changed_at":"2026-11-17T09:38:14.995904+00:00","url":"https://bounty.xe.network/XE-7916","body":"## Summary\r\n\r\nThe 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.\r\n\r\n## Impact\r\n\r\n- 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.\r\n- 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.\r\n- 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).\r\n\r\n## Reproduction (unit test)\r\n\r\nTemporary test in package `net` (run on commit 89a542e, removed afterwards to keep the tree clean):\r\n\r\n```go\r\ns := newBanStore(3)\r\ns.ban(p1, now+1h); s.ban(p2, now+1h); s.ban(p3, now+1h)\r\ns.ban(p4, now+1h)\r\n// size()==3, banned(p1)==false, banned(p4)==true\r\n```\r\n\r\nTest output (also attached as a screenshot):\r\n\r\n```\r\neviction confirmed: size=3 banned(p1)=false banned(p4)=true evictions=1\r\n```\r\n\r\n## Root cause (code)\r\n\r\n- `net/banstore.go:13`: `maxBannedPeers = 4096`.\r\n- `net/banstore.go:60-77`: `ban()` loops `for len(s.entries) >= s.max { if !s.evictOldestLocked() { break } }` before inserting.\r\n- `net/banstore.go:152-168`: `evictOldestLocked` removes the oldest entry.\r\n- `net/netcheck.go:286-290,395-467`: a bad handshake is the only trigger that calls `ban()`.\r\n- `net/host.go:117-127`: the per-/32 connection rate limit that slows single-IP filling (see calibration above).\r\n\r\n## Relationship to known tickets\r\n\r\nNo 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.\r\n\r\n## Suggested fix\r\n\r\nDo 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.\r\n\r\n## Environment\r\n\r\n- Commit: 89a542e (\"release: testnet-0005 quorum withhold fix\", 2026-11-10)\r\n- Evidence is a unit test on that commit; no public testnet nodes were involved.\r\n- Attachments: screenshot of the passing test output.","patch_refs":[],"thread":[{"id":9679,"source":"desk","source_ref":"reply:8117","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0126, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-7916 and says what differs; it is read like any other.","created_at":"2026-11-17T09:38:14.977489+00:00"}]}