{"id":"XE-0450","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"258","source_url":"https://github.com/xeprotocol/xe/issues/258","reporter_id":190,"title":"[Low-Medium] chat: dedup-cache prune cannot evict a running flood — 100k envelopes permanently disable a node's chat store (distinct from the #50 SSE vector)","area":null,"claimed_tier":"minor","assessed_tier":null,"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-04T09:26:12.830399+00:00","updated_at":"2026-11-10T00:11:31.220919+00:00","source_created_at":"2026-11-04T09:24:36+00:00","told_at":"2026-11-05T22:07:52+00:00","status_changed_at":"2026-11-05T22:07:33.803884+00:00","url":"https://bounty.xe.network/XE-0450","body":"**Suggested severity: Low-Medium**\n\n**Duplicate check:** swept the full live tracker. #50 is the SSE-overflow vector and explicitly refutes chat starvation *via SSE*; no issue covers the dedup cache. Different endpoint (`POST /chat/send` and p2p chat, not `/chat/events`), different code (`chat/chat.go` prune path, not the SSE listener buffer).\n\nReviewed at commit `02e9641b0ac64437f57e09d63301f88cce61a802`.\n\n## Summary\nThe chat dedup cache's prune can never evict a flood's entries while the flood is running: `VerifyFull` guarantees every stored `seen` timestamp is within ±5 min, while the prune cutoff is `now - 2*MaxEnvelopeSkew` (= 10 min). After 100 k envelopes, a node answers `duplicate envelope` to every chat message until entries age out — and the `messages` map grows without bound.\n\n## Evidence\n`chat/chat.go:36-42` (cap), `:63-70` (`pruneSeenLocked`), `:72-83` (`storeFor`); reached from `api/chat.go:37` → `node/node.go:2483` → `chat/envelope.go:92` (±5 min skew enforced).\n\nObserved (PoC against a copy of the repo):\n```\nfilled: len(seen)=100000 (cap 100000), len(messages map)=104096\nStore() after cache is full -> false (node maps this to 'duplicate envelope')\nentries older than the 2*MaxEnvelopeSkew cutoff: 0 of 100000 -> pruneSeenLocked evicts nothing\ns.messages still holds 104096 account keys after the flood (never pruned)\n```\n\n## Impact\nAfter 100 k envelopes the node rejects every chat message (HTTP and libp2p) as duplicate until entries age out; `s.messages` grows without bound.\n\n**Honest cost caveat:** each envelope needs a PoW at `chat.DefaultPoWDifficulty`. Measured on 4 cores: 112 ms/solution → ~3 h of 4-core mining to reach the cap (far less on larger hardware). This is why it ranks Low-Medium rather than High.\n\n**Fix direction:** prune by insertion order / LRU when at capacity, or bound `s.messages` per account.\n","patch_refs":[{"id":269,"repo":"xeprotocol/xe","kind":"pr","ref":"261","title":"fix(chat): evict oldest entries on dedup cache saturation and bound accounts map (fixes #258)","url":"https://github.com/xeprotocol/xe/pull/261","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-04T09:48:40.775168+00:00"}],"thread":[{"id":394,"source":"github","source_ref":"6670803511","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0144, 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, reply with what differs and we will look again.","created_at":"2026-11-05T22:07:52+00:00"}]}