Flooding 1,000 chat messages to one account evicts the victim's entire chat history on that node
Report
Suggested severity tier: Low
Area: chat storage, chat/chat.go (storeFor), node/node.go (chat handler, NewChatStore)
Repository state checked: xeprotocol/xe HEAD 978785929bc17a2f4ab30c383e5fc9cf4d634512
Summary
The chat store keeps at most 1,000 messages per account in a sliding window. When the window is full, each new message evicts the oldest one. Any sender can store a validly signed envelope addressed to any account, and there is no per-sender quota and no re-sync protocol for chat. Flooding 1,000 valid messages to one account therefore deletes that account's entire stored history on the receiving node, including messages the victim sent, with no way to recover them on that node.
What was proven
storeFor in chat/chat.go (lines 72-83) drops the oldest message whenever the per-account list reaches maxPerAccount, which is 1,000 (node/node.go:314, chat.NewChatStore(1000)). Store in chat/chat.go (lines 30-60) performs no check on whether the sender is allowed to write to the destination account beyond envelope verification, and the account_chat handler (node/node.go:2455-2470) stores any valid envelope it receives. There is no mechanism to re-sync chat history, so an evicted message is gone from GET /chat/messages on that node permanently.
Proven with a local test against the real ChatStore code: 1,000 legitimate messages were stored for one account, then 1,000 spam envelopes were flooded to the same account. After the flood, 0 of the 1,000 legitimate messages remained, and the oldest stored message was the first spam message. The test is TestR4ChatHistoryEviction, and it passes.
The cost was measured on this machine: minting and verifying one envelope at the default proof-of-work difficulty takes about 489 ms, so 1,000 envelopes cost about 8 minutes of CPU, and delivery takes about 20 seconds at the 50 messages per second per-peer rate limit (net/msg.go:52-53). Sending through POST /chat/send is slower, about 100 seconds at the 10 per second write bucket.
Reproduction
- Clone https://github.com/xeprotocol/xe and confirm HEAD is 978785929bc17a2f4ab30c383e5fc9cf4d634512.
- Build a test harness against the chat package and store 1,000 legitimate messages for one account.
- Deliver 1,000 validly signed envelopes addressed to that account.
- Read the account's messages back and observe that none of the legitimate messages remain.
Impact
The victim loses their chat history on the flooded node, including messages they sent themselves. No funds move, and no other account's messages become readable: reading still requires the victim's key proof (api/chat_auth.go). Recovery is partial at best: the other party would have to send the messages again, and there is no re-sync protocol to pull them back. The cost to the attacker is real but modest, about 8 minutes of CPU plus delivery time, and parallel machines make it cheaper.
Suggested fix
Add a per-sender quota inside the per-account window so one sender cannot evict another sender's messages, or keep a separate bounded list per sender. As a second step, add a chat re-sync path so a node can recover history it lost.
Honest limits of this proof
The proof ran at the ChatStore level with the real code, and the account_chat delivery path was read from code rather than executed between two nodes. A two-node run would confirm the end-to-end delivery, but the eviction mechanism itself is proven in the store. This report makes no claim about the public testnet, and the flood cost was measured on one local machine.
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0189, 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.