[Track 1 Bug Bounty] Descendant-receive race in conflict-resolution swap → supply inflation (plan→apply window skips pending-send destinations)
Report
[Track 1 Bug Bounty] Descendant-receive race in conflict-resolution swap → supply inflation (plan→apply window skips pending-send destinations)
Summary
Two compounding defects in the conflict-resolution path let a receive that lands inside the swap's plan→apply window survive the cascade, leaving the destination holding tokens from a send the resolved chain no longer contains — i.e. balance inflation. Proven on master 9787859 with deterministic and statistical PoCs (public gist: https://gist.github.com/ox-code/8f403d80d2161866d1c65e118f370443).
Root cause (two defects)
Defect 1 — incomplete receive gate (core/ledger.go:1102):
if src := l.GetBlockOrStaged(b.Source); src != nil {
if l.GetConflict(src.Account, src.Previous) != nil {
return fmt.Errorf("source send %s is contested by an unresolved conflict — receive deferred pending resolution", ...)
}
}
The gate defers a receive only when the SEND ITSELF is a conflict participant (GetConflict at the send's own previous). A send that is a descendant of a conflicted block passes: the conflict is registered at the fork point (X, P), while the check looks at (X, L.Hash) — the send's own previous.
Defect 2 — plan/skip race in the cascade (core/ledger.go:2889-2975):
swapBlockLocked builds its rollback plan from unlocked reads. For each descendant send it checks GetPendingSend(b.Hash); if the send is pending, the destination is skipped (assumed not-yet-credited). Foreign-account locks are acquired only after planning, and skipped destinations are neither locked, snapshotted, nor rolled back. If a receive resolves the pending send after the plan read but before/during the cascade apply, the destination keeps tokens from a send the resolved chain no longer contains.
When the receive lands before the plan, the cascade behaves correctly (the pending send is already resolved, the destination is included in the plan and unwound) — the machinery works; the gate and the window are the flaw.
Evidence (all on master 9787859, includes #9 hardening)
- poc5 (deterministic): with a conflict open at
(X,P), a receive of the descendant sendS1is accepted —GetConflict(X, L.Hash) = nilwhile(X,P)is open. The gate gap, demonstrated without any race. - poc6 (statistical): 300 iterations racing
SwapBlockagainst the receive → 6 BUG (destination kept the tokens), 222 safe (receive preceded the plan → unwound), 72 rejected. - poc6b (state dump, single-shot): hit on attempt 0 —
X chain (len=2): mint send <- S1 dropped by the swap
D chain (len=1): receive(src=080582e7) <- receive of S1 survived
pending send S1 record exists: false
X XUSD: 930000 | D XUSD: 1000 | E XUSD: 0
The resolved chain (mint 1,000,000 → W) supports 930,000 at X + 70,000 pending to E. D's 1,000 is recognized by the ledger but supported by no block: 1,000 XUSD created from nothing (amount is attacker-controlled up to the pending send's size).
- Perpetuity check: a fresh ledger rebuilt on the same store still recognizes D's 1,000 XUSD — the inflation survives restart on the producing node.
Impact
- Supply inflation: ledger-recognized balances exceed what the resolved chain supports; perpetual on the producing node (verified via rebuild).
- Two reachable shapes:
- Attacker-driven: attacker forks their own account, wins/forces resolution, and lands the receive inside the window (spamming receives raises the hit rate; the window widens with descendant count — 40 descendants in the PoC).
- Honest network: any user receiving during any conflict resolution on the sender's account can be credited from a rolled-back send — a safety violation with no attacker at all.
- No theft of existing funds; the gain is minted value.
Relation to #226 / #227
#226 (cascade unwind stale store reads; SwapBlock credential bypass) and its fix PR #227 address lease-state staleness and credential verification inside the same function family. This report is a distinct defect: the pending-send destination skip plus the receive-gate ancestry gap, with a different failure mode (supply inflation via a race window) and a different fix. I checked #227's diff — it does not touch the plan/skip logic or the receive gate (its only GetPendingSend mention is a test mock). #227 is open and does not fix this bug.
Suggested fix direction
- Gate on ancestry: defer the receive if any conflict exists on the send's account at or before the send's height (
GetConflictsForAccount(src.Account)+ height compare), not only at the send's ownprevious. - Or close the window: re-check
GetPendingSendfor every skipped destination inside the cascade apply (under the destination's lock), or acquire destination locks before planning.
Severity
High — "Races, replays & state transitions" tier (race condition / TOCTOU). Honest bounds: the per-event amount is bounded by the pending send's size, there is no direct theft, and exploitation requires a receive landing inside the conflict-resolution window (PoC hit rate 2% with a tight local loop; the window is real but narrow). The balance-inflation class is noted; I am not claiming the Critical tier because of the bounded amount and the concurrency precondition.
Affected version
master 9787859. PoCs are Go programs (go build && go run) against a local MemStore ledger — no network setup needed.
Researcher: oxcode
Thread
Thank you for the report. We have reviewed the behaviour you describe against the current tree and it is being handled; we will update this ticket as the work progresses.
Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0137.
Status note — not a new report. The desk marks XE-0137 patched, but the fix PR xeprotocol/xe#231 is still open (not merged), and both defects are still present verbatim in the public tree at testnet-0006 HEAD 8cc209d: (1) validateAndAddReceive (core/ledger.go:1159–1163) checks only GetConflict(src.Account, src.Previous) — the source send's own previous, no ancestry check; (2) planSwap (ledger.go:3303) skips a pending send when planning the unwind, and swapBlockLocked (:3200–3247) plans first and acquires the foreign locks after, never re-checking GetPendingSend under lock. Either the patch landed somewhere the public tree doesn't show, or the patched status is premature.