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