{"id":"XE-16707","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"648","source_url":"https://github.com/xeprotocol/xe/issues/648","reporter_id":2920,"title":"[Medium] Unauthenticated list endpoints do full-table scans before pagination — /leases, /conflicts, /reputation, /directory","area":"node-api","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1030","internal_url":"https://github.com/xeprotocol/core/issues/1030","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T05:17:33.024486+00:00","updated_at":"2026-11-22T23:26:17.094112+00:00","source_created_at":"2026-11-17T05:17:01+00:00","told_at":"2026-11-22T23:26:17.117773+00:00","status_changed_at":"2026-11-22T23:26:17.104283+00:00","url":"https://bounty.xe.network/XE-16707","body":"## Summary\nThe 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.\n\n## Root Cause\n- `handleGetAllConflicts` (`api/handler.go:772-775`): `paginateSlice(h.node.GetAllConflicts(), offset, limit)` -- loads all conflicts.\n- `handleGetLeases` (`api/handler.go:808-820`): `paginateSlice(h.node.GetLeases()/GetLeasesByState(state), offset, limit)` -- loads all leases.\n- `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.\n- `/directory` (`api/directory.go:25-31`): same full-load pattern (bounded by the 50k registration cap).\n- The store has no paginated query for leases, conflicts, or reputations (`store/badger_store.go` `GetAllLeases`/`GetLeasesByState`/`GetAllConflicts`/`GetAllReputations` take no limit).\n- Only `/pending` (and `/accounts`) use `newPerClientLimit(maxHeavyListPerClient).wrap(...)` (`api/handler.go:169-170`); these endpoints have no per-client limit.\n\n## Impact\nCPU/memory DoS on the node. `/reputation` additionally sorts all keys per request. Leases/conflicts grow with chain activity, so the cost grows unboundedly.\n\n## Verification (executed PoC)\nAfter 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).\n\n## Note on related reports\nDistinct 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.\n\n## Suggested fix\nAdd paginated store queries (or cache-backed pages like `/frontiers`), and apply the `perClientLimit` wrapper to these routes.","patch_refs":[],"thread":[{"id":18881,"source":"desk","source_ref":"reply:16558","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16707 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:17.094112+00:00"}]}