<!-- XE-0450 · [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) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0450>. The page is the record; this is the same page for reading.*

XE-0450 · Bounty

# \[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)

Closed · duplicate
—claimed Minor
[xe#258](https://github.com/xeprotocol/xe/issues/258)
filed 2026-11-04 09:24 UTC
by Fahri Raditya Arrifudin

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   —

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-10 00:11 UTC

Told
:   2026-11-05 22:07 UTC

### Patches

- [xe#261](https://github.com/xeprotocol/xe/pull/261) open by tipprb
  fix(chat): evict oldest entries on dedup cache saturation and bound accounts map (fixes #258)

### History

- [9355](https://bounty.xe.network/log/9355) 2026-11-05 22:08 UTC github.state\_pushed
- [9354](https://bounty.xe.network/log/9354) 2026-11-05 22:08 UTC github.labels
- [9272](https://bounty.xe.network/log/9272) 2026-11-05 22:07 UTC reply.mirrored
- [9236](https://bounty.xe.network/log/9236) 2026-11-05 22:07 UTC reply.sent
- [9235](https://bounty.xe.network/log/9235) 2026-11-05 22:07 UTC proposal.adopted
- [9234](https://bounty.xe.network/log/9234) 2026-11-05 22:07 UTC proposal.adopted
- [9233](https://bounty.xe.network/log/9233) 2026-11-05 22:07 UTC ticket.status triaging → closed
- [9232](https://bounty.xe.network/log/9232) 2026-11-05 22:07 UTC proposal.adopted
- [9231](https://bounty.xe.network/log/9231) 2026-11-05 22:07 UTC ticket.facts
- [9230](https://bounty.xe.network/log/9230) 2026-11-05 22:07 UTC proposal.adopted
- [9229](https://bounty.xe.network/log/9229) 2026-11-05 22:07 UTC ticket.facts
- [7299](https://bounty.xe.network/log/7299) 2026-11-05 14:02 UTC proposal.created

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

### Report

**Suggested severity: Low-Medium**

**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).

Reviewed at commit `02e9641b0ac64437f57e09d63301f88cce61a802`.

## Summary

The 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.

## Evidence

`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).

Observed (PoC against a copy of the repo):

```
filled: len(seen)=100000 (cap 100000), len(messages map)=104096
Store() after cache is full -> false (node maps this to 'duplicate envelope')
entries older than the 2*MaxEnvelopeSkew cutoff: 0 of 100000 -> pruneSeenLocked evicts nothing
s.messages still holds 104096 account keys after the flood (never pruned)
```

## Impact

After 100 k envelopes the node rejects every chat message (HTTP and libp2p) as duplicate until entries age out; `s.messages` grows without bound.

**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.

**Fix direction:** prune by insertion order / LRU when at capacity, or bound `s.messages` per account.

### Thread

**Joseph Denne**team2026-11-05 22:07 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0144, 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, reply with what differs and we will look again.
