Bounty
XE-0704 · Bounty

GET /chat/messages and GET /providers return entire collections with no pagination or limit

Closed · duplicate — xe#275 filed 2026-11-05 12:54 UTC by rusdiwireng

Report

Summary

Two GET endpoints return their full collection on every request, with no limit or offset parameter. GET /chat/messages returns up to 1,000 envelopes per account, measured at 8,574,002 bytes for maximum-size messages. GET /providers ranges the whole provider advertisement map, measured at 271,002 bytes for 1,000 entries and 2,710,002 bytes for 10,000 entries. The codebase already has a pagination pattern (parsePagination / paginateSlice, used by GET /directory and ten other collection endpoints). These two endpoints skip it.

Affected endpoints

  • GET /chat/messages, handler api/chat.go:49-60
  • GET /providers, handler api/vm.go:10-11

Root cause

handleChatMessages calls h.node.GetChatMessages(account, since) and writes the result straight to the response. It reads a since filter from the query string and nothing else. There is no limit or offset parameter. The store behind it holds up to 1,000 messages per account (chat.NewChatStore(1000), node/node.go:314) and each message can be up to 8,192 bytes (MaxMessageBytes, chat/envelope.go:15).

handleGetProviders calls h.node.GetProviders() and writes the result straight to the response. GetProviders (node/node.go:1071-1099) ranges the entire providerAds map, which has no cap and is never pruned. It also scans the full lease list once per advertisement, so the work grows with both collections.

No layer in between caps the response. writeJSON (api/handler.go:402-406) encodes whatever it is given. The HTTP server write timeout is 60 seconds (cmd/xe/main.go:1458), far above the observed handler times. Both endpoints are GET requests on the read rate bucket: 200 requests per second sustained, burst 1,000 per IP (api/handler.go:296,314-322).

Measured evidence

Measured locally against the real handler code with the Go test harness, using a filled chat.ChatStore and a built provider list of the stated size. The ownership proof for /chat/messages was a real one: a challenge issued by the handler itself, signed with an ed25519 keypair that derives the account.

Chat, 1,000 messages of 8,192 bytes each:

  • Full fetch: HTTP 200, 1,000 envelopes, 8,574,002 bytes, handler time 60 to 215 ms across runs.
  • With ?limit=10: HTTP 200, 1,000 envelopes, 8,574,002 bytes. The parameter is ignored; the response is byte-identical.
  • With ?since= set near the newest timestamp: 1 envelope. The since filter works, and it is the only filter. It does not bound the count: 1,000 messages inside one since window still return all 1,000.

Providers, one entry about 263 to 271 bytes of JSON:

  • 1 entry: 273 bytes.
  • 1,000 entries: 271,002 bytes, handler time under 2.2 ms.
  • 10,000 entries: 2,710,002 bytes, handler time under 15 ms.
  • With ?limit=10: 1,000 entries, 271,002 bytes. The parameter is ignored.

The per-entry figure depends on address length. The test used 72-character account strings while real addresses are 64 hex characters, so a real 10,000-entry response is about 2.63 MB rather than 2.71 MB.

Impact

GET /chat/messages needs an ownership proof, so an attacker can only inflate their own account: send 1,000 messages to themselves (each message needs a proof of work, roughly 8 minutes of CPU for 1,000 messages at the default difficulty on a 4-vCPU machine) and then request the 8.5 MB response repeatedly. That is a bandwidth and CPU cost on the node operator, not on another user. No funds move and no other account data leaks.

GET /providers needs no authentication at all. On its own the response is small on a quiet network, so the standalone impact is low. The response grows with the advertisement map, and that map grows without cap through unauthenticated sybil advertisements (handleMarketplace, case "advertisement", node/node.go:1399), so this endpoint is the read side of an unbounded collection. The advertisement growth itself is a separate matter already reported under the freshness issue (#18); this report is about the missing pagination on the read side.

Severity: Low. No funds at risk, no cross-account data exposure, no permanent state change. The failure clears as soon as requests stop.

Related issues

This is the same pattern as #70 (GET /accounts), #215 (GET /frontiers), and #78 (GET /pending, GET /accounts), on endpoints those reports do not cover. Each endpoint is a separate location with a separate fix, so this is filed as a distinct report for these two endpoints.

Reproduction

No live node is needed. The read side can be reproduced in a test in package api:

  1. Implement the nodeBackend interface with a stub. Point GetChatMessages at a real chat.ChatStore and GetProviders at a slice of node.ProviderInfo of the size under test.
  2. Fill the store with 1,000 envelopes of 8,192-byte messages for one account.
  3. Build a handler with that backend. Issue a challenge through the handler, sign it with a keypair that derives the account, and call handleChatMessages with the proof query parameters through httptest. Read the response body length.
  4. Call handleGetProviders through httptest with provider slices of 1,000 and 10,000 entries. Read the response body length.
  5. Repeat both calls with ?limit=10 and confirm the response is unchanged.

The arithmetic alone also shows the chat bound: 1,000 messages times 8,192 bytes is 8,192,000 bytes of message content, plus JSON framing, which matches the measured 8,574,002 bytes.

Suggested fix

Apply the existing pagination helpers to both handlers: read parsePagination(r) and return paginateSlice(...), the same as handleDirectoryList does. For GET /providers, consider also bounding the work inside GetProviders when the lease list is large, since the per-advertisement lease scan runs before pagination.

Method limits

  • The measurement ran the real handler in-process through httptest, not over a socket to a running node. Response bytes are identical to what writeJSON sends; handler times are in-process CPU cost, not wire latency.
  • The chat store was filled directly through ChatStore.Store, not through POST /chat/send or gossip delivery, which verify signatures and proof of work. The read side under test is identical either way, since the handler reads the same store, but the end-to-end fill cost was not re-executed here.
  • The provider list was built directly at the stated sizes rather than grown through gossip advertisements. The serialization measured is exactly what GetProviders returns after ranging the map. The per-advertisement lease scan cost was read from code, not measured.
  • The per-IP bandwidth figures implied by the read bucket (200 requests per second times the response size) are arithmetic, not wire measurements.

Thread

rusdiwireng2026-11-09 02:34 UTCgithub

Hi, thanks for triaging. I am asking for a re-check of the duplicate closure on this issue. The nearest public reports in the pagination family describe different defects on different endpoints, and this report's fix is a separate change.

Concrete differences from #70, #78, and #215:

  1. Different endpoints and code paths. #275 is about GET /chat/messages (api/chat.go:49-60) and GET /providers (api/vm.go:10-11). #70 and #78 are about GET /accounts and GET /pending; #215 is about GET /frontiers. No public report before #275 mentions /chat/messages or /providers pagination at all.
  2. Different defect — in #78's case, the opposite defect. #70 and #215: pagination exists but is applied after full-lattice work, so a limit=1 request still costs the full scan. #78: pagination exists (default 100, max 1000) but is undeclared, so responses are silently truncated. #275: there is no pagination at all — both handlers write the entire collection straight to the response (/chat/messages measured at 8,574,002 bytes for maximum-size messages; /providers ranges the whole uncapped providerAds map). Unbounded response is not the same defect as silent truncation, and neither is the same as late pagination.
  3. Different fix. #70/#78 were fixed by PR #124 (accounts/pending only); #215 by PR #216 (frontiers only). #275 is fixed by a separate change, PR #286 §5, which wires parsePagination/paginateSlice into handleChatMessages and handleGetProviders — a different hunk in different files, listed by the fix author as "Fixes #275".

I understand these reports sit in the same family (list endpoints and pagination), and if this was closed as a duplicate of a desk entry that already covered /chat/messages and /providers specifically, please point me to it and I will withdraw this appeal. If it was closed as a duplicate of #70/#78/#215, I ask that it be reconsidered on the three points above: different endpoints, a defect that runs in the opposite direction from #78, and a separate fix.

Thank you for re-checking.

XE deskteam2026-11-14 22:53 UTCgithub

Thanks. This is the same finding as https://bounty.xe.network/XE-0610, 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-0704 and says what differs; it is read like any other.