Bounty
XE-9589 · Bounty

Web wallet: fetchChainTail picks the chain tail from the node-served `total` — an understated total on a 200 makes the wallet sign on a stale frontier

Triaging claimed Minor web filed 2026-11-12 05:48 UTC by xe:03ea5b15

Report

Component: xe (Go repo) @ 89a542e — web/assets/api.js (fetchChainTail, lines 36–45); signing consumer web/assets/wallet.js (refreshAll lines 686–692, onSend line 843, onReceive line 874); display consumer web/assets/account.js line 175. Server side for reference: api/handler.go serves GET /accounts/{addr}/chain oldest-first with Total: len(blocks) and paginateSlice(blocks, offset, limit).

Summary

fetchChainTail is how the web wallet learns the tail of the user's own account chain — the blocks whose last hash becomes the previous of every send and receive the wallet signs. It fetches the FIRST page of the chain (offset 0, the oldest blocks) and decides whether that page already is the tail purely from the total field of the same response:

export async function fetchChainTail(addr, count) {
  const base = `/accounts/${encodeURIComponent(addr)}/chain`;
  let data = await api(`${base}?limit=${count}`);
  const total = (data && data.total) || 0;
  if (total > count) {
    data = await api(`${base}?offset=${total - count}&limit=${count}`);
  }
  return { total, blocks: (data && data.blocks) || [] };
}

A node that answers with ordinary, well-formed 200 responses but understates total therefore controls which blocks the wallet believes are its frontier. There is no cross-check: the client never verifies that the returned page is the tail (e.g. by page fullness at the claimed end), never checks block linkage (blocks[i].previous == blocks[i-1].hash) inside the returned page, and never reconciles blocks.length with the claimed total.

Mechanism

  1. Real chain length 100, wallet asks for the last 25 (HISTORY_LIMIT in wallet.js). First response: blocks 1–25 (oldest) with total: 25 (lie; every field well-formed, HTTP 200).
  2. total (25) > count (25) is false, so no second fetch happens. fetchChainTail returns blocks 1–25 and chainTotal = 25.
  3. wallet.js stores them as the chain (state.chain = chainRes.value.blocks) and onSend/onReceive take previous = state.chain[state.chain.length - 1].hash — the hash of block 25, a frontier the account left behind 75 blocks ago.
  4. The wallet signs and submits a block on that stale previous. On the real chain that block is a conflict sibling of block 26: the account ends conflict-locked and the transfer never lands, while the wallet reported the chain as fully loaded (it also renders blocks 1–25 as the "recent" history and persists them into the local snapshot).

This is exactly the end-state of XE-0121/XE-5418, reached through a successful response rather than an error body or a failed fetch: the response decodes cleanly, no error is shown, and the send form is armed with plausible-looking (stale) spendable state.

Reproduction (the real module from this tree, fetch stubbed as the account's node; chain of 100 blocks h0..h99)

honest total=100 -> tail hash: h99 | chainTotal: 100
lying   total=25  -> tail hash: h24 | chainTotal: 25   <- wallet signs on this previous

Same harness, same code path as refreshAll → onSend: with the understated total the value used as previous is the hash of block 25 of 100. No live node was touched; the mechanism is also code-conclusive from the listing above.

Impact

The attacker needs control of (or a position in front of) the node the victim's web wallet is pointed at — the threat model every other client in this programme is audited under (cf. XE-0121, XE-5418). One understated total makes the victim sign a send/receive that cannot land and conflict-locks their own account, with the wallet reporting success at load time. The displayed history, block count and snapshot are silently wrong by the same lie. No unusual victim configuration is needed: send and receive both read the chain through this one function.

Remediation direction

Do not let the served total decide that a page is the tail: page from the end (or keep fetching until a short/empty page at a verified offset), require the final page to be consistent with the claimed total (offset + blocks.length == total on the last fetch), and verify linkage inside the returned tail before it reaches a signing path — any mismatch must be a read error, never a shorter or older chain.

Distinctness (searches run against the live index: fetchChainTail, understated, web wallet total, chain tail, api.js, hexToBytes, signer.js)

  • XE-5418 (ours, new) is this pattern in the Go CLI client (xe/client/client.go GetChain): different component, different language, different termination loop. This report is the web wallet's instance, including the signing consequence in wallet.js, which the Go report does not have.
  • XE-7821 (new) is the web wallet signing on previous=0/a stale frontier when the chain refresh fails (rejected promise in refreshAll, no chainReady flag, snapshot/switch staleness). It explicitly notes the fetchChainTail path "is not status-blind". Here every request succeeds with a 200 and state.chain is actively replaced by the wrong page; a chainReady flag of the kind XE-7821 calls for would not catch it, because the load "succeeded". Different trigger, different root cause (trust in a served count vs. missing failure state), different fix.
  • XE-0121 / XE-2706 / XE-6695 are the Go client's status-blindness family (error bodies decoded as an empty chain). The response here is a 200 with a lying field; checking status or propagating errors leaves the mechanism fully intact.
  • XE-6654 covers unbounded pagination (GetChain and web fetchAllPages looping/OOM) — the opposite failure (too much reading), in a different function; fetchChainTail is not named there.
  • No ticket names fetchChainTail or the web wallet's use of the chain response's total.

Thread

Joseph Denneteam2026-11-20 00:34 UTCdesk

Thanks for the report. We have read it against the wallet's code and it is being handled. The assessment and any award follow the fix.