{"id":"XE-9660","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":693,"title":"TypeScript SDK: XeClient.frontier() trusts the node-served chain total — an understated total returns a stale mid-chain hash that every write path signs on","area":"sdk-docs-web","claimed_tier":"minor","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-12T06:18:00.355713+00:00","updated_at":"2026-11-20T00:33:17.458463+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:17.528286+00:00","status_changed_at":"2026-11-20T00:33:17.513502+00:00","url":"https://bounty.xe.network/XE-9660","body":"Component: xeprotocol/sdk @ 116f4b7 — `sdk/src/client.ts` (`frontier`, lines 253–266); consumers `sdk/src/xe.ts` (`send` line 168, `receive` line 203, claim line 235, `burn`, and `#position` line 568, through which every lease write also passes).\r\n\r\nSummary\r\n\r\n`XeClient.frontier()` — the function every SDK write path takes the account's `previous` from — learns where the chain ends purely from the `total` field of the chain endpoint's first response: it reads `total`, then fetches the single block at `offset = total - 1` and returns its hash. The only cross-check is that the fetch returns a non-empty page (\"chain shrank while reading the frontier\"), which an understated `total` never triggers: the page at the wrong offset is full and well-formed. A node that answers with ordinary 200 responses but understates `total` therefore chooses which block the SDK believes is the frontier, and `send`, `receive`, `burn` and all lease writes sign their block on that stale `previous` — a conflict sibling of the real tip block, which leaves the account conflict-locked and the transfer unlanded, while the client reports a successful read.\r\n\r\nMechanism\r\n\r\n1. Real chain length 100. First response (`?limit=1`) carries `total: 25` (lie; all fields well-formed, HTTP 200).\r\n2. `frontier()` fetches the single block at `offset = total - 1 = 24` and returns its hash — the hash of block 25 of 100. The page is non-empty, so the \"chain shrank\" check passes.\r\n3. `xe.ts` write paths (`send`, `receive`, claim, `burn`, and `#position` for leases) take that hash as `previous`, sign the new block on it and submit. On the real chain the block is a conflict sibling of block 26: the account ends conflict-locked and the transfer never lands.\r\n\r\nUnlike the Python dao client (XE-2353), the SDK never proves the tail — e.g. by fetching the last two blocks and checking that the second-to-last block's hash is the last block's `previous`, or by confirming a fetch at `offset = total` comes back empty. The served count is the only evidence it ever consults.\r\n\r\nReproduction (the real SDK module from this tree, `fetch` stubbed as the account's node; chain of 100 blocks)\r\n\r\n```\r\nhonest total=100 -> frontier() returns hash100 (the real tip)\r\nlying   total=25  -> frontier() returns hash25  (stale; every write signs on this previous)\r\n```\r\n\r\nImpact\r\n\r\nThe attacker needs control of (or a position in front of) the node the victim's SDK client is pointed at — the threat model every other client in this programme is audited under (cf. XE-5418, XE-9589). One understated `total` makes every write the SDK signs build on a stale frontier: the resulting block cannot land, and the account is left conflict-locked, while the client reported a successful frontier read. Send, receive, burn and all lease operations pass through this one function, so no SDK write path is unaffected.\r\n\r\nRemediation direction\r\n\r\nDo not let the served `total` be the only evidence of the tail: prove it before signing — for example fetch the final two blocks and verify linkage (`blocks[last].previous == blocks[last-1].hash`), and confirm that a read at `offset = total` returns an empty page; any inconsistency must be a read error, never a shorter chain.\r\n\r\nDistinctness (searches run against the live index: `frontier`, `total`, `XeClient`, `client.ts`)\r\n\r\n- **XE-5418** (ours, new) is this pattern in the **Go CLI client** (`GetChain`'s count-bounded walk); **XE-9589** (ours, new) is the **web wallet** (`fetchChainTail`). This report is the TypeScript SDK's instance, in a third language and a different function, including the lease-write reach through `#position`, which neither sibling has.\r\n- **XE-0479** covers the `total = 0` / not-yet-synced case (an empty or absent chain read); here the chain is long and every response is a well-formed 200 — the failure is an understated positive count, which XE-0479's framing does not cover.\r\n- **XE-2353** (Python dao client) is the inverse evidence: that client proves the end of the chain with a `limit=2` read before trusting it. The proof pattern exists in the programme's own clients and is absent here, which is exactly the defect.\r\n- A search for `frontier` surfaces no ticket on this function (XE-0017, the top hit, concerns lease-cancel validation ordering — a different mechanism).","patch_refs":[],"thread":[{"id":13195,"source":"desk","source_ref":"reply:11217","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-9660 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:17.458463+00:00"}]}