{"id":"XE-1249","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"301","source_url":"https://github.com/xeprotocol/xe/issues/301","reporter_id":7,"title":"Peer capability table evicts legitimate representatives under throwaway-identity flood, blinding DAO activation readiness","area":"p2p-sync","claimed_tier":null,"assessed_tier":"medium","verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-08T01:42:34.565184+00:00","updated_at":"2026-11-14T22:51:20.465936+00:00","source_created_at":"2026-11-08T01:42:11+00:00","told_at":"2026-11-14T22:50:40+00:00","status_changed_at":"2026-11-08T20:32:00.147281+00:00","url":"https://bounty.xe.network/XE-1249","body":"## Summary\n\n`GET /network/readiness` is the gate the DAO reads before signing an\nactivation. It builds its numbers from the peer capability table, which\nmaps each libp2p peer ID to the version and features that peer advertised\nduring the netcheck handshake. That table holds at most 4096 entries and\nevicts the oldest entry when it fills up. A single machine can fill it\nwith throwaway peer IDs in about two minutes, because a netcheck\nhandshake needs nothing the attacker does not already have: the network\nID and genesis hash are public, and any compatible version string passes.\nOnce the table is full of throwaway entries, every legitimate\nrepresentative's capabilities are gone from it, `GetReadiness` counts\ntheir weight as unknown, and the readiness endpoint reports low numbers\nfor features the network actually supports. The DAO then holds off on\nsigning the activation. Nothing gets activated wrongly. Activation just\nstalls.\n\n## Affected code\n\n- `net/features.go:12`, `maxPeerCapEntries = 4096`\n- `net/features.go:37-49`, `(*peerCapTable).record`, FIFO eviction\n- `net/netcheck.go:415` and `net/netcheck.go:471`,\n  `RecordPeerCapabilities` on inbound and outbound handshakes\n- `net/netcheck.go:329`, handshake rate limit, 32 per second global,\n  burst 128\n- `node/activations.go:155-180`, `GetReadiness`, reps without recorded\n  capabilities fall into `UnknownWeight`\n- `api/handler.go:151`, `GET /network/readiness`\n- `docs/activations.md:166`, activation needs readiness at or above 90%\n  for 7 consecutive days\n\n## Root cause\n\n`record` appends each new peer ID to an order list and, while the list\nis longer than 4096, drops the oldest ID from both the list and the map:\n\n```go\nt.caps[p] = c\nfor len(t.order) > maxPeerCapEntries {\n    oldest := t.order[0]\n    t.order = t.order[1:]\n    delete(t.caps, oldest)\n}\n```\n\nThree properties around it turn this into an eviction primitive:\n\n1. Nothing removes a peer from the table when it disconnects, and\n   nothing re-verifies a connected peer on a schedule. `verifyPeer`\n   runs only when a new connection arrives (`net/netcheck.go:342`).\n   A legitimate peer that stays connected is never re-recorded, so\n   once it is evicted it stays evicted until it reconnects.\n2. Recording a peer needs no authentication beyond the handshake\n   itself. `checkPeer` verifies network ID, genesis hash, and a\n   compatible semver version, all of which are public or trivially\n   chosen. The attacker does not need stake, delegation, or any\n   account on the network.\n3. The rate limit does not stop a flood of new identities. Each new\n   peer ID gets a fresh per-peer bucket with burst 3, and the global\n   limit is 32 handshakes per second with burst 128. At that rate\n   4096 handshakes take about two minutes. The cap of 256 simultaneous\n   inbound connections (`net/netcheck.go:40`) does not apply either,\n   because the attacker can connect, handshake, and disconnect in\n   sequence instead of holding connections open.\n\n`GetReadiness` looks up each representative through the directory\n(`ListDirectory`) and then through the table\n(`AllPeerCapabilities`). A representative whose peer ID is no longer\nin the table is skipped, its weight goes to `UnknownWeight`, and its\nfeatures contribute nothing to `FeatureWeight`. The readiness endpoint\nthen shows the network as unready.\n\n## Measured evidence\n\nTested locally against the real `peerCapTable` code with a temporary\nGo test in package `net` (written, run, then deleted; the repository\nis untouched):\n\n- Record one legitimate peer with feature `messaging`.\n- Record 4096 throwaway peer IDs.\n- The legitimate peer is gone from the table. Table size is exactly\n  4096.\n- Record the legitimate peer again and it is visible again.\n\nOutput:\n\n```text\n=== RUN   TestZZCapsEvictProbe\n    PROBE CONFIRMED: 4096 throwaway peer IDs evict a legit peer's\n    capabilities from the 4096-entry FIFO; re-record restores it\n--- PASS: TestZZCapsEvictProbe (0.02s)\n```\n\nThe step from an evicted table to a wrong readiness number follows\nfrom the code in `GetReadiness` (`node/activations.go:155-180`):\na representative with no entry in the capabilities map is counted\nin `UnknownWeight` and contributes no feature weight. That part was\nchecked by reading the code, not by running a live node.\n\n## Impact\n\nThe readiness numbers the DAO relies on go wrong in the\nunder-reporting direction. A representative that has upgraded and\nadvertises a feature is counted as unknown, so the feature looks\nless ready than it is. The DAO procedure asks for readiness at or\nabove 90% for 7 consecutive days before signing (`docs/activations.md:166`),\nso even a short dip can restart that 7 day wait. The effect ends when\nlegitimate peers reconnect and their capabilities are recorded again,\nwhich means an attacker who wants to hold the eviction has to keep\nhandshaking at roughly 32 per second. The failure stays on the side\nof caution: activation is delayed, never wrongly granted, and no funds\nmove.\n\n## Related findings\n\nThis is a different defect from #287, which is about the contents of\nthe table: duplicate feature strings from one peer inflating its\nweight. That issue says nothing about the size of the table or about\neviction, and its use of the word \"capping\" refers to the 8 feature\nlimit per peer. This report is about the table itself: new identities\npushing old entries out.\n\nThe shape is similar to #202, where the ban store FIFO of 4096\nentries can be flushed with throwaway identities. The store here is\ndifferent and so is the result: instead of a ban being evaded, the\nreadiness gate goes blind. #201 and #47 cover Sybil-style pressure\non neighbouring pieces (peer counting and per-peer rate limiting)\nwith different mechanisms.\n\n## Suggested fix\n\nAny one of these closes the hole:\n\n- Keep capability entries for peers the node is currently connected\n  to, and evict disconnected peers first.\n- Re-verify capabilities for connected peers on a schedule, so an\n  evicted legitimate peer comes back without waiting for a reconnect.\n- Reserve part of the table for peers that appear in the directory\n  or hold delegated weight, and let throwaway identities compete\n  only for the rest.\n\n## Method limits\n\n- The eviction itself was reproduced in process against the real\n  table code. The wrong readiness number was traced through the\n  `GetReadiness` code, not measured on a running node. No live\n  node was driven and no testnet traffic was sent.\n- The two minute estimate for 4096 handshakes follows from the\n  configured global limit of 32 per second with burst 128. It was\n  not measured against a live node.\n- The 7 day soak comes from the written DAO procedure in\n  `docs/activations.md:166`. Whether the DAO measures the streak\n  from this endpoint continuously is a matter of their procedure,\n  not of this code.","patch_refs":[{"id":348,"repo":"xeprotocol/xe","kind":"pr","ref":"302","title":"fix(net, directory, node): protect connected and directory representatives from peercap eviction under throwaway flood","url":"https://github.com/xeprotocol/xe/pull/302","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-08T01:54:58.565467+00:00"}],"thread":[{"id":763,"source":"github","source_ref":"6716874393","author":"rusdiwireng","team":false,"body":"Thanks for the fix in PR #302 — I reviewed it locally against the PR code (commit 015ccbf), and it closes the core of this issue for an ordinary throwaway flood (connected, trusted, and directory-listed peers are now retained). Five legs are still open:\n\n1. No periodic re-verification. verifyPeer still runs only when a new connection arrives. A legitimate representative evicted while connected does not come back until it reconnects.\n\n2. Handshake without authentication. checkPeer is unchanged: it still verifies only network ID, genesis hash, and a compatible semver version.\n\n3. Rate limit unchanged. netcheckGlobalRPS is still 32 per second with burst 128, so the flood rate is the same as before.\n\n4. No removal on disconnect. There is no hook that deletes a peer's capabilities when it disconnects. PR #302 replaces removal with eviction preference (a disconnected peer is evicted first), so stale entries still occupy the table until eviction pressure arrives.\n\n5. The third suggested fix in this issue (reserve part of the table for directory peers or peers holding delegated weight) is only partly implemented. Retention through the directory has no quota on retained non-connected entries and no delegated-weight check at all. That gap is the root cause of the follow-up finding I filed separately as #304, where a throwaway identity registers itself in the directory for free and claims retain protection.","created_at":"2026-11-08T03:46:46+00:00"},{"id":3412,"source":"github","source_ref":"6885450450","author":"XE desk","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, 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-1249 and says what differs; it is read like any other.","created_at":"2026-11-14T22:50:40+00:00"}]}