[SECURITY][Minor] SDK - receiveAll aborts on a live lease escrow and strands every pending row behind it
Report
[SECURITY][Minor] SDK - receiveAll aborts on a live lease escrow and strands every pending row behind it
| Field | Value |
|---|---|
| Severity | Minor |
| Area | SDK — wallet / pending transfers |
| Component | src/xe.ts (receiveAll), src/client.ts (pending) |
| Version | xeprotocol/sdk @ 0dbc92ecff709bee79768e4e37788c682a0f4525 (master, 2026-10-23) · xeprotocol/xe @ 978785929bc1 |
| Status | Reproduced (unit, deterministic) |
| Date | 2026-11-02 |
| Reporter | Desk web account xe:64e3ca3f…0cd4 (reporter id 68) — the same person who filed XE-0077 / XE-0078 / XE-0080 under the GitHub login targammm (reporter id 30). Please merge the two records so the award history is attributed once. |
1. Summary
GET /pending/{address} returns every pending send addressed to that account. For a provider that list
also contains the escrow row of any lease it is currently serving: when a lease is opened, the node escrows
the consumer's XUSD as a pending send whose destination is the provider (core/ledger.go:1584-1590), and that
row stays in the destination index until the lease is settled or cancelled.
The node refuses to let that row be received while the lease is live:
// core/ledger.go:1072-1099
func (l *Ledger) isLiveLeaseEscrow(sendHash string) bool {
lease, ok, err := l.getLeaseOverlay(sendHash)
if !ok || err != nil || lease == nil { return false }
return lease.State == LeaseCreated || lease.State == LeaseAccepted
}
...
if l.isLiveLeaseEscrow(b.Source) {
return fmt.Errorf("cannot receive a live lease escrow: %s", shortHash(b.Source))
}
The SDK's receiveAll() claims every pending row in order and has no idea that one of them is an escrow:
// src/xe.ts:220-227
/** Claim every pending send, oldest first. Sequential: each commits to the previous frontier. */
async receiveAll(): Promise<SubmitResult[]> {
const results: SubmitResult[] = []
for (const p of await this.pending()) {
results.push(await this.receive(p))
}
return results
}
The escrow row is appended to the destination index when the lease opens, and the index is append-ordered,
so the escrow is normally earlier in the list than the transfers that arrived after it. receiveAll() builds
a receive block for the escrow, the node rejects it with HTTP 400, and the exception escapes the loop —
every pending row behind it is never claimed.
2. Affected code
| File | Line | Issue |
|---|---|---|
src/xe.ts |
221–227 | receiveAll — no per-row error handling; the first rejected row aborts the whole loop |
src/xe.ts |
199–218 | receive — builds the receive block without checking whether the source is a live escrow |
src/client.ts |
268–287 | pending() — maps every row the node returns, including escrow rows |
core/ledger.go |
1584–1590 | validateAndAddLease — AddPending{ Destination: b.Destination, Asset: "XUSD" } ⇒ the escrow is addressed to the provider |
core/ledger.go |
1097–1099 | validateAndAddReceive — rejects a live escrow: "cannot receive a live lease escrow" |
core/ledger.go |
2395–2403 | GetPendingForAccount → store.GetPendingByDest(account) |
store/badger_store.go |
291 | GetPendingByDest returns the destination index in append order (oldest first) |
store/badger_store.go |
778 | destHashes = append(destHashes, c.AddPending.SendHash) — the index is append-ordered |
3. Reproduction
Deterministic — the XeClient is stubbed with the exact node error, so no network is needed.
// repro-receiveall-lease-escrow.mjs
const rows = [
{ hash: 'a1a1a1a1', asset: 'XUSD', amount: 500000n }, // the live lease escrow
{ hash: 'b2b2b2b2', asset: 'XE', amount: 42n }, // an ordinary transfer behind it
]
const client = {
networkId: async () => 'testnet-0005',
balances: async () => ({ balances: { XUSD: 0n, XE: 0n } }),
frontier: async () => '00'.repeat(32),
pending: async () => rows,
submitBlock: async (b) => {
if (b.source === 'a1a1a1a1') throw new Error('HTTP 400: cannot receive a live lease escrow')
return { hash: 'submitted' }
},
}
const xe = new Xe({ client, address: ADDR, wallet: WALLET })
await xe.receiveAll()
Observed:
blocks the SDK built and submitted:
type=receive asset=XUSD source=a1a1a1a1a1a1... balance=500000
receiveAll() threw : HTTP 400: cannot receive a live lease escrow
rows claimed : 1 of 2
never claimed:
b2b2b2b2b2b2b2... XE 42
Full script: repro-receiveall-lease-escrow.mjs.
4. Impact
- A provider's ordinary incoming transfers stop being claimable for as long as it is serving a live lease.
Provider income arrives as XE emissions and direct transfers; both sit behind the escrow row in the
destination index, so
receiveAll()— the one-call "claim everything" helper the SDK offers — cannot claim them. - The failure is loud but the remedy is manual. The caller gets an exception naming the escrow row, and
has to call
receive(row)per remaining row. Nothing is lost — the rows stay pending — but a script that callsreceiveAll()on a timer will keep failing on every tick and keep claiming nothing. - The window is the lease's lifetime. The escrow row is deleted when the lease is settled or cancelled, so
the next
receiveAll()after the lease closes works. - Renewals do not add rows (a renewal tops up the existing pending), so one escrow row blocks the list for the whole engagement, not one row per renewal.
Honest boundary: no funds are lost and no consensus rule is bypassed — the node rejects the escrow receive exactly as it should. The defect is a missing filter and a missing per-row error path in the client's "claim everything" helper: the rows remain pending and are recoverable one by one. That is a robustness / accounting-hygiene issue, not a loss, hence Minor rather than Medium.
5. Why the test suite misses it
test/unit/lease.test.ts exercises the lease path against a mocked Xe; test/unit/client.test.ts
covers the wire mapping of pending(). Neither drives receiveAll() against a list that contains an escrow
row, and the mock submitBlock never rejects one row — so the loop's error path is never taken.
6. Suggested fix
- Skip rows the node will not accept. The cleanest signal is the node's own error text, but a better fix is
to filter before submitting: the escrow row is the one whose
sourceis a live lease, and the SDK already has the lease state for hashes it has seen. - At minimum, make
receiveAll()not abort on one rejected row: catch per-row errors, record them, and continue with the remaining rows; return the failures alongside the successes (or expose them on askippedfield) instead of throwing. - Add a regression test that drives
receiveAll()with a mock that rejects the first row and asserts that the second row is still claimed.
7. Duplicate check
xeprotocol/sdk: 0 issues, 14 PRs (fetched 2026-11-02). No PR or issue mentionsreceiveAll, the escrow, or pending sends. PR #4 (ci: run the leasing tutorials … claiming its refunds) exercises refunds throughreceive, but it does not touchreceiveAlland has no escrow row in the list.xeprotocol/xe: 236 issues + PRs, all fetched and searched 2026-11-02 — 0 hits forreceiveAll. The escrow-related entries are node-side and different: #68 / #136 (supply auditor does not count lease-renewal escrow), #171 / #39 (lease cancel must refund renewal escrow), #155 / XE-0102 (after a renewal the shipped client can never force-settle), #78 (/pendingand/accountssilently truncate to 100 items), #210 (PR: replace the monolithic pending-by-destination JSON array with indexed keys). None is the SDK'sreceiveAllloop.- XE bounty desk: all 113 published tickets searched 2026-11-02 — 0 hits for
receiveAllor "receive all"; the escrow hits are XE-0012, XE-0101 and XE-0102, all node-side.
8. Submission checklist (per programme "How to Report")
| Step | Requirement | Status |
|---|---|---|
| 1 | Reproduce against testnet; capture tx hashes / block heights | Reproduced locally and deterministically with the node's exact rejection string; the ordering (escrow before later transfers) follows the node's append-ordered destination index (store/badger_store.go:291,778). Not exercised live — it needs a provider holding a live lease, which costs a real lease on the testnet. |
| 2 | GitHub issue with suggested severity tier and area | Tier: Minor · Area: SDK — wallet / pending transfers |
| 3 | Clear PoC + impact analysis (who is affected, worst case) | Included — sections 3 and 4 |
| 4 | Critical/Severe goes to security@xe.network first |
Not applicable — Minor is below Severe, so a public issue is the correct channel |
| 5 | Triage by the core team | Awaiting |
| 6 | XE address for payout at genesis | 64e3ca3f6e9378cd549032de9f087b5496fd4100516c7bdb46c17b00d4220cd4 — XE native chain (block lattice, ed25519), derived from the reporter's recovery phrase via BIP39 → SLIP-0010 ed25519 m/44'/1'/account'; address = sha256("xe/account/v1" ‖ pubkey) |
Suggested tier: Minor (650 XE) — missing filter and missing per-row error path; pending rows stay pending and are recoverable, no permanent loss
Thread
Thanks for the report. We have confirmed the behaviour you describe in the SDK's claim helper and it is being handled; we will update https://bounty.xe.network/XE-0253 when there is a fix to point at.