{"id":"XE-17372","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":2799,"title":"GET /frontiers offset paging skips and duplicates accounts when a new account sorts in mid-walk (no cursor, no snapshot)","area":"node-api","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T12:32:58.280992+00:00","updated_at":"2026-11-23T01:01:14.024991+00:00","source_created_at":null,"told_at":"2026-11-23T01:01:14.059717+00:00","status_changed_at":"2026-11-23T01:01:14.034997+00:00","url":"https://bounty.xe.network/XE-17372","body":"## Summary\r\n`GET /frontiers` pages with a numeric offset over a list sorted by account address. The address is immutable, so the order is deterministic at rest — but the key set is not: every new account sorts into the list, and the cached order is discarded whenever any account is dirty. A new account sorting in before the walk's current offset shifts every later entry by one, 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.\r\nThis is the `GET /frontiers` instance of the offset-paging defect class filed as XE-17296 for `GET /pending` and XE-17331 for `GET /accounts` — but with its own trigger: key-set insertion into an immutable-key sort, not a mutable-value re-sort.\r\n## Target\r\n- Repo: `xeprotocol/xe` @ `8cc209d65c16089158da8fabd392628b71fe0711` (remote HEAD, verified 2026-11-17).\r\n- Files: `api/handler.go:766-769` (`handleGetFrontiers`), `node/node.go:1008-1026` (`GetFrontiersPage`), `core/account_summary.go:125-135` (`AccountsByAddress`), `:40-73` (`refreshSummariesLocked`), `api/handler.go:640-656` (`parsePagination`).\r\n## Code path\r\n`handleGetFrontiers` calls `parsePagination` then `h.node.GetFrontiersPage(offset, limit)`. `GetFrontiersPage` takes `n.Ledger.AccountsByAddress()`, slices `all[offset:end]`. `AccountsByAddress` returns a list sorted by `strings.Compare(a.Account, b.Account)` (address: immutable key), cached in `summaryByID`, but `refreshSummariesLocked` rebuilds summaries whenever any account is dirty and ends with `l.summaryByXE, l.summaryByID = nil, nil`, discarding the cached order. Each page request therefore materialises a fresh sorted list of the live account set and slices it by numeric offset. A new account created between page N and page N+1 sorts into the list before the walk's offset and shifts every entry after it by one: the walk returns the boundary account twice and never returns the account that was pushed past the end of the walk. `parsePagination` takes only `offset`/`limit`; no cursor parameter exists anywhere in the frontiers path.\r\n## Reproduction (read-only, no crafted input)\r\n1. `GET https://test.network/api/v1/frontiers?limit=50&offset=0` — 50 frontiers, strictly address-ascending (verified live 2026-11-17: page 0 ends `09dadfd6…`, page 1 begins `09e2d306…`).\r\n2. Wait for a new account to be created, then `GET .../frontiers?limit=50&offset=50`.\r\n3. Diff the boundary: if the new account's address sorts before the offset-50 boundary, the boundary account appears in both pages and the last account of the walk is never returned.\r\nLive scale on testnet-0006 (2026-11-17): 1,307 accounts at the previous cycle, 1,367 by this cycle's check — new accounts sort in constantly, so the hazard is exercised on every multi-page walk that spans an account creation.\r\n## Impact\r\nMedium — same class and tier as XE-17296 and XE-17331. No direct fund loss: the defect corrupts enumeration, not frontiers. Anyone paginating `/frontiers` — explorers, indexers, sync clients reconciling frontier state — silently misses accounts or counts them twice, with no `total` to detect the loss. The trigger is the network's normal operation (account creation), not an attacker action.\r\n## Suggested fix\r\nSnapshot the sorted list under `summaryMu` 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.\r\n## Distinctness\r\n- **XE-17296** (Medium) is `GET /pending` only — different endpoint, different store and trigger (pending-set insert/delete vs account-set insertion into an address sort).\r\n- **XE-17331** (Medium, ours) is `GET /accounts` — different endpoint and a strictly stronger trigger (re-sort on every balance change anywhere on the network). Its body does not mention `/frontiers`.\r\n- **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: `AccountsByAddress` sorts deterministically, so `/frontiers` is stable at rest and shifts only on key-set insertion.\r\n- **XE-16443** (High) is the five endpoints loading the full collection before paginating — a performance defect (cost), not a correctness defect (wrong enumeration). Different mechanism, different fix.\r\n- **XE-0058 / XE-14068** are silent truncation (bare array, no `total`, 100-item default) — a detection problem, not the skip/duplicate mechanism. The missing `total` is cited here only as why the loss is undetectable.\r\n- **XE-11844** (Minor, docs) claims `/accounts` paging IS stable because the handler sorts before slicing — the same at-rest-only reasoning would wrongly clear `/frontiers` too; it does not consider the concurrent-mutation case at all.\r\n- Corpus searches over all 2,885 public tickets: `offset` / `cursor` / `pagination` / `frontiers` — no ticket names an offset-paging skip/duplicate on `/frontiers`.\r\n## Honest limitations\r\n- **Live observation:** two back-to-back two-page walks (limit 50, ~60 s apart, 2026-11-17) showed no shift — the boundary accounts were unchanged inside that window, because the new accounts created in that window sorted after the offset-50 boundary. The defect is proven in code (fresh sorted list per page + offset slicing with no snapshot), and the shift requires an insertion sorting before the walk's offset; on a growing network it is routine over a full 27-page walk at the default limit. No live skip/duplicate was captured in this run.\r\n- The walk is 14 pages at limit 100; the hazard needs an insertion before the walk's offset, so a single walk may or may not exhibit it — the defect is in the paging contract, not in any single response.\r\n## Reporter\r\nXE address: db4043dea0d12c476c2644a3df09c4ce51fa1ce04617723405916ade3fa3305f","patch_refs":[],"thread":[{"id":19444,"source":"desk","source_ref":"reply:17121","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-17372 and says what differs; it is read like any other.","created_at":"2026-11-23T01:01:14.024991+00:00"}]}