Bounty
XE-17376 · Bounty

GET /reputation offset paging skips and duplicates accounts when a reputation aggregate is created or deleted mid-walk (no cursor, no snapshot)

Triaging claimed Medium web filed 2026-11-17 12:33 UTC by Irwan0000

Report

Summary

GET /reputation pages with a numeric offset over the set of reputation aggregates. The page order is deterministic — the handler sorts the map keys — so the list is stable at rest. But the key set is not: a reputation aggregate is created the first time an account takes part in a lease event, and deleted when its counters revert to zero. An aggregate created or deleted between two page fetches shifts the offset window, so a consumer walking the enumeration silently misses one account and counts another twice. There is no snapshot, no cursor, and no total anywhere in the path, so the loss is undetectable. This is the GET /reputation instance of the offset-paging defect class filed as XE-17296 for GET /pending and XE-17331 for GET /accounts — with the weakest trigger of the family: key-set insert/delete driven by lease events, which are infrequent on the current testnet.

Target

  • Repo: xeprotocol/xe @ 8cc209d65c16089158da8fabd392628b71fe0711 (remote HEAD, verified 2026-11-17).
  • Files: api/handler.go:904-906 (handleGetAllReputations), :626-638 (paginateMap), node/node.go:911 (GetAllReputations), core/reputation.go:196 (PutReputation on apply), :203-226 (DeleteReputation on revert to zero counters), api/handler.go:640-656 (parsePagination).

Code path

handleGetAllReputations calls parsePagination then paginateMap(h.node.GetAllReputations(), offset, limit). paginateMap collects the map keys, sort.Strings(keys), then slices by offset — so the order is deterministic at rest. But the key set changes: ApplyReputationDelta persists a new aggregate with PutReputation (core/reputation.go:196) the first time an account accrues lease activity, and RevertReputationDelta deletes the aggregate with DeleteReputation (:215, inside :203-226) when its counters revert to zero. Each page request therefore slices a freshly sorted list of the live aggregate set by numeric offset, with no snapshot held across pages. An aggregate inserted or deleted before the walk's offset shifts every entry after it by one: the walk returns the boundary account twice and never returns the account pushed past the end of the walk. parsePagination takes only offset/limit; no cursor parameter exists anywhere in the reputation path.

Reproduction (read-only, no crafted input)

  1. GET https://test.network/api/v1/reputation?limit=100&offset=0 — the full aggregate set (verified live 2026-11-17: only 2 aggregates on testnet-0006).
  2. Wait for a lease event that creates a first-time aggregate (or a revert that deletes one), then fetch the next page.
  3. Diff the boundary: an aggregate inserted or deleted before the offset shifts the window by one entry.

Impact

Medium — same class and tier as XE-17296 and XE-17331, with a frankly weaker trigger: the defect corrupts enumeration, not reputation values, and on the current testnet the key set changes only on lease events (30 leases live), so a mid-walk shift is infrequent. The hazard is structural — any consumer paginating /reputation (reputation census, provider ranking) silently misses accounts or counts them twice, with no total to detect the loss — and it grows with network activity.

Suggested fix

Snapshot the sorted key list for the duration of a walk, or add a keyset cursor (the sort key — account address — is already total), or at minimum return a total plus a stable-ordering guarantee so consumers can detect a shifted walk.

Distinctness

  • XE-17296 (Medium) is GET /pending only — different endpoint, different store and trigger.
  • XE-17331 (Medium, ours) is GET /accounts — different endpoint and a strictly stronger trigger (re-sort on every balance change). Its body does not mention /reputation.
  • XE-17327 / XE-17339 (Medium) are GET /leases and GET /conflicts — different endpoints, and a different mechanism: unsorted Go-map ranges reshuffle on every request even with zero mutation. That mechanism does NOT apply here: paginateMap sorts the keys, so /reputation is stable at rest and shifts only on key-set insert/delete.
  • XE-16443 (High) lists /reputation among the five endpoints loading the full collection before paginating — a performance defect (cost), not a correctness defect (wrong enumeration). Different mechanism, different fix.
  • XE-10919 / XE-10920 are delegation-weight drift on undo — different mechanism (weights, not enumeration).
  • XE-16497 is reputation self-inflation via self-leases — different mechanism (values, not enumeration).
  • Corpus searches over all 2,885 public tickets: offset / cursor / pagination / reputation — no ticket names an offset-paging skip/duplicate on /reputation.

Honest limitations

  • Live observation: two full fetches 60 s apart (2026-11-17) were identical — only 2 aggregates exist and neither changed inside the window. The defect is proven in code (fresh sorted key list per page + offset slicing with no snapshot), and the shift requires a lease event creating or deleting an aggregate between two page fetches. No live skip/duplicate was captured in this run; the trigger is infrequent on the current testnet and this is the weakest instance of the family.
  • With 2 live aggregates the endpoint currently fits on one page at any sane limit; the hazard bites when the aggregate set grows past one page and a lease event lands mid-walk.

Reporter

XE address: db4043dea0d12c476c2644a3df09c4ce51fa1ce04617723405916ade3fa3305f

Thread

Joseph Denneteam2026-11-23 01:01 UTCdesk

Thanks for the report. The reputation list is cut into pages from the live set of accounts, so an account that appears or disappears between pages can be skipped or repeated. This is being read.