[Medium] Unauthenticated list endpoints do full-table scans before pagination — /leases, /conflicts, /reputation, /directory
Report
Summary
The list handlers for /leases, /conflicts, /reputation, and /directory load and JSON-unmarshal every row from the store, then slice a page in memory. None of these routes has the perClientLimit wrapper -- only /accounts and /pending do -- so an unauthenticated client can fire full-scan requests at high rate with unbounded per-client concurrency. CPU/memory DoS on the node; cost scales with table size, not page size.
Root Cause
handleGetAllConflicts(api/handler.go:772-775):paginateSlice(h.node.GetAllConflicts(), offset, limit)-- loads all conflicts.handleGetLeases(api/handler.go:808-820):paginateSlice(h.node.GetLeases()/GetLeasesByState(state), offset, limit)-- loads all leases.handleGetAllReputations(api/handler.go:904-907):paginateMap(h.node.GetAllReputations(), offset, limit)-- loads all reputations and sorts all keys (O(N log N)) per request./directory(api/directory.go:25-31): same full-load pattern (bounded by the 50k registration cap).- The store has no paginated query for leases, conflicts, or reputations (
store/badger_store.goGetAllLeases/GetLeasesByState/GetAllConflicts/GetAllReputationstake no limit). - Only
/pending(and/accounts) usenewPerClientLimit(maxHeavyListPerClient).wrap(...)(api/handler.go:169-170); these endpoints have no per-client limit.
Impact
CPU/memory DoS on the node. /reputation additionally sorts all keys per request. Leases/conflicts grow with chain activity, so the cost grows unboundedly.
Verification (executed PoC)
After inserting 2,000 leases/conflicts/reputations into a MemStore, GetAllLeases=2000 GetAllConflicts=2000 GetAllReputations=2000 -- no limit parameter exists on any of them. Audited at HEAD 8cc209d (testnet-0006).
Note on related reports
Distinct endpoints from XE-0072 (/accounts -- now cache-backed, appears fixed), XE-9108/XE-9121 (/pending -- now uses GetPendingPage), #215 (/frontiers -- now cache-backed via GetFrontiersPage). The same fix pattern was applied to those endpoints but not to these.
Suggested fix
Add paginated store queries (or cache-backed pages like /frontiers), and apply the perClientLimit wrapper to these routes.
Thread
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-16707 and says what differs; it is read like any other.