<!-- XE-0137 · [Track 1 Bug Bounty] Descendant-receive race in conflict-resolution swap → supply inflation (plan→apply window skips pending-send destinations) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0137>. The page is the record; this is the same page for reading.*

XE-0137 · Bounty

# \[Track 1 Bug Bounty\] Descendant-receive race in conflict-resolution swap → supply inflation (plan→apply window skips pending-send destinations)

Patched
High
[xe#229](https://github.com/xeprotocol/xe/issues/229)
filed 2026-10-31 07:47 UTC
by ox-code

Verdict
:   Likely valid

Tier
:   High

Claimed
:   —

Area
:   Consensus

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-24 19:03 UTC

Told
:   2026-11-20 13:12 UTC

### Patches

- [xe#231](https://github.com/xeprotocol/xe/pull/231) open by arturbarszcz78
  fix(core): prevent supply inflation from descendant-receive race in conflict-resolution swap (fixes #229)

### History

- [857392](https://bounty.xe.network/log/857392) 2026-11-24 21:18 UTC note.added
- [855442](https://bounty.xe.network/log/855442) 2026-11-24 19:03 UTC github.labels
- [855436](https://bounty.xe.network/log/855436) 2026-11-24 19:03 UTC ticket.status accepted → patched
- [600594](https://bounty.xe.network/log/600594) 2026-11-20 13:12 UTC reply.mirrored
- [600591](https://bounty.xe.network/log/600591) 2026-11-20 13:12 UTC reply.sent
- [593817](https://bounty.xe.network/log/593817) 2026-11-20 12:58 UTC github.labels
- [593790](https://bounty.xe.network/log/593790) 2026-11-20 12:57 UTC ticket.status triaging → accepted
- [593789](https://bounty.xe.network/log/593789) 2026-11-20 12:57 UTC ticket.facts
- [24194](https://bounty.xe.network/log/24194) 2026-11-08 09:39 UTC github.labels
- [24193](https://bounty.xe.network/log/24193) 2026-11-08 09:39 UTC reply.mirrored
- [24190](https://bounty.xe.network/log/24190) 2026-11-08 09:39 UTC reply.sent
- [24188](https://bounty.xe.network/log/24188) 2026-11-08 09:39 UTC proposal.adopted

[Full history](https://bounty.xe.network/log?ref=XE-0137) · [JSON](https://bounty.xe.network/v1/tickets/XE-0137) · [markdown](https://bounty.xe.network/XE-0137.md)

### 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 send `S1` is accepted — `GetConflict(X, L.Hash) = nil` while `(X,P)` is open. The gate gap, demonstrated without any race.
- **poc6 (statistical)**: 300 iterations racing `SwapBlock` against 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**:
  1. *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).
  2. *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 own `previous`.
- Or close the window: re-check `GetPendingSend` for 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

**Joseph Denne**team2026-11-08 09:39 UTCgithub

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.

**XE desk**team2026-11-20 13:12 UTCgithub

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.

**ncgeja**2026-11-25 06:01 UTCgithub

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.
