Bounty
XE-9181 · Bounty

ChatStore `seen` cap fails closed: a sustained flood of valid envelopes rejects all new chat

Closed · duplicate —claimed Medium web filed 2026-11-12 03:11 UTC by xe:c76743e7

Report

ChatStore seen cap fails closed: a sustained flood of valid envelopes rejects all new chat

Suggested XE tier: Medium (chat starvation only; Track 2 treats chat starvation as High when one client can cause it — this claim is narrower, because sustaining it at the default PoW difficulty needs substantial compute and several peers; see Limitations. Triage may raise or lower.) Area: P2P / sync (chat ingestion; also Node / API via POST /chat/send) Severity: CVSS 3.1 AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H — 5.9 Medium

CVSS justification:

  • AV:N — envelopes arrive over the P2P account_chat handler (and via the HTTP API) from the network.
  • AC:H — sustaining the cap needs a continuous ~167 valid envelopes/second for as long as the denial lasts (see Impact), each carrying proof-of-work at the configured difficulty, delivered through enough peers/IPs to stay under per-peer and per-IP rate limits. At the default difficulty this is a substantial compute commitment; if ChatDifficulty is 0, PoW is skipped and the cost collapses (see Limitations).
  • PR:N — envelopes are self-signed with the sender's own keypair; no account, lease, or admin privilege is needed.
  • UI:N — no victim interaction.
  • S:U — impact stays within the target node's chat ingestion; the ledger, consensus, and other node functions are not claimed to be affected.
  • C:N, I:N — no confidentiality or integrity impact shown.
  • A:H — while the cap is held full, all new envelopes are rejected by Store, including legitimate ones, on the target node.

Asset: xeprotocol/xe, chat/chat.go + node/node.go (account_chat handler), at commit 89a542ea51d38375299aee54c6c99102e9bfa666 (2026-11-10, testnet-0005) Accounts: none on any live network. Local harness / isolated private nodes only, with test keypairs generated locally.

Summary

ChatStore.Store caps its seen map at 100,000 IDs and, when the cap is reached, only prunes entries older than 10 minutes before rejecting the new envelope. An attacker who keeps 100,000 fresh, valid envelope IDs in the map therefore makes Store return false for every new envelope, including legitimate ones, for as long as the flood is sustained. There is no LRU eviction and no exception for envelopes addressed to the local account.

Affected component

  • xe/chat/chat.go:10 (maxSeenIDs = 100_000), :30-42 (Store), :63-70 (pruneSeenLocked)
  • Ingress: xe/node/node.go:2456-2466 (account_chat handler — validated envelope, then Store, failure reported as "duplicate envelope"), xe/node/node.go:2482-2506 (SendChat), xe/api/chat.go (POST /chat/send → SendChat)
  • Envelope validation: xe/chat/envelope.go:17 (DefaultPoWDifficulty), :19 (MaxEnvelopeSkew = 5 minutes), :85-113 (VerifyFull — freshness window, ID recomputation, PoW, key/signature checks)
  • Rate limits that bound the flood: P2P Messenger 50 RPS/peer, 200 RPS global (xe/net/msg.go:26-30); HTTP write limit 10 RPS/IP, burst 50 (xe/api/handler.go:297)

Steps to reproduce (local only, isolated — do NOT run against the public testnet)

The reproduction is a local harness, not a live flood. It has not been executed yet. This report is based on static code review at the stated HEAD; the steps below describe the local reproduction that can confirm it.

  1. On an isolated machine/network with no connection to the public testnet, check out xeprotocol/xe at the commit above and install a Go toolchain (Go 1.25 per .go-version). No live node is involved.
  2. Write a small local Go harness that constructs a chat.ChatStore directly and calls Store:
    • Generate one test keypair locally.
    • Create 100,000 distinct valid envelopes with that keypair (distinct messages/timestamps, valid signatures; PoW is not exercised by Store itself — see step 4 for the full-path variant).
    • Call Store for each; all should return true until the cap is reached.
  3. Create one further legitimate envelope (different test keypair, fresh timestamp) and call Store.
    • Expected from the code (not yet observed): Store returns false, because pruneSeenLocked only removes entries older than 10 minutes and all 100,000 entries are fresh.
  4. Full-path variant (optional, still isolated): run two local nodes on a private libp2p network with no public peers, with ChatDifficulty set to a low test value so the harness can generate envelopes cheaply, flood node B's account_chat handler from node A, then send one legitimate envelope to B and observe the "duplicate envelope" error.

Evidence

Code at HEAD (xe/chat/chat.go):

const maxSeenIDs = 100_000

func (s *ChatStore) Store(env *Envelope) bool {
	s.mu.Lock()
	if _, dup := s.seen[env.ID]; dup { s.mu.Unlock(); return false }
	if len(s.seen) >= maxSeenIDs {
		s.pruneSeenLocked()
		if len(s.seen) >= maxSeenIDs { s.mu.Unlock(); return false }
	}
	s.seen[env.ID] = env.Timestamp
	...
}

func (s *ChatStore) pruneSeenLocked() {
	cutoff := core.Now().Add(-2 * MaxEnvelopeSkew).UnixNano() // 10 minutes
	for id, ts := range s.seen { if ts < cutoff { delete(s.seen, id) } }
}

Ingress (xe/node/node.go, account_chat handler): a validated envelope that Store rejects is answered with fmt.Errorf("duplicate envelope") — indistinguishable, from the sender's side, from a genuine duplicate.

Arithmetic (from the code, not from a live measurement): entries survive in seen for up to 10 minutes (2 × 5-minute skew). Holding 100,000 fresh entries therefore needs roughly 100,000 / 600 s ≈ 167 valid envelopes/second, sustained. That rate fits within the 200 RPS global Messenger limit if delivered through at least 4 peers at 50 RPS each, or through enough distinct HTTP IPs at 10 RPS/IP.

Impact

While the flood is sustained, the target node's chat ingestion is fully denied: every new envelope — including legitimate messages to any account on that node — is rejected. The denial ends when the flood stops and entries age past the 10-minute prune cutoff; no persistent corruption is claimed. The ledger and consensus paths are not affected by this mechanism as far as this report shows.

Dedup / related reports

  • Variant, not a duplicate of the closest reports (as assessed from the 300-report desk snapshot of 2026-11-12 and targeted GitHub searches; dedup is provisional — see Limitations):
    • GitHub xeprotocol/xe#247: the messages map grows without bound (memory/OOM). This report is about the capped seen map failing closed, not unbounded growth.
    • XE-0001 finding 4: storage sink for arbitrary accounts. Different mechanism (per-account storage), different cap.
    • XE-0610: per-account inbox eviction. Different map and different eviction behaviour.
    • XE-3519: the seen map in chat-auth (api/chat_auth.go), a different map with a different claim (unbounded memory).
  • No entry in the 300-report snapshot mentions total rejection caused by the seen cap. If the team finds an earlier report of this exact fail-closed behaviour, this should be treated as a duplicate/variant of it.

Limitations — what was NOT verified

  • Not executed. No Go toolchain was available during preparation, so no harness, go vet, or go test was run. The Store behaviour above is read from the code; the local run is still outstanding.
  • PoW cost at the default difficulty is substantial. ValidatePoW requires powHash >= 0xffffc00000000000, i.e. success probability 2⁻¹⁸, about 262,144 hashes per envelope on average. Sustaining 167 envelopes/second at that difficulty needs on the order of 44M hashes/second plus the peer/IP distribution above. The claim is therefore sustained flood by a well-resourced sender, not a trivial single-request DoS. If ChatDifficulty is configured to 0, VerifyFull skips PoW entirely and the cost collapses — the deployed testnet value was not verified (no live testing).
  • No live testing. Whether the public testnet nodes run this HEAD, what ChatDifficulty they use, and how the flood interacts with peer scoring/banning in practice were not tested and are not claimed.
  • Dedup is provisional: private reports are not visible and GitHub issues were searched by targeted query, not enumerated in full.

Remediation

Evict instead of failing closed, at the layer that owns the cap (chat/chat.go):

  1. Replace the fail-closed cap with bounded eviction: when seen is full, evict the oldest entries (LRU / oldest-timestamp) to make room, so a flood degrades replay protection for old envelopes instead of denying all new chat. Size the cap and eviction so the map stays bounded.
  2. Alternatively, prune more aggressively (for example, drop entries older than the 5-minute freshness window rather than 2× skew, since envelopes older than the skew window are rejected by VerifyFull anyway) — this narrows, but does not remove, the flood window, so it should be combined with eviction.
  3. Consider per-sender/per-peer accounting for seen growth so one keypair cannot fill the whole map, and return a distinct error for "store full" instead of "duplicate envelope" so operators can distinguish a flood from genuine duplicates.

Notes

  • Reviewed 2026-11-12 against a local clone at the commit above. No live testing, no testnet contact, no accounts on any live network.
  • Track 2 note: any future volume measurement against the public testnet would require a pre-notice report first under the program rules, and the reporter's explicit go-ahead. None was done for this report.

Thread

Joseph Denneteam2026-11-20 00:04 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, 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, file a new report that links https://bounty.xe.network/XE-9181 and says what differs; it is read like any other.