Bounty
XE-8012 · Bounty

[CLI] Two concurrent `xe send` from the same wallet sign the same previous — no inter-process lock, second submit stages a fork

Triaging claimed Medium web filed 2026-11-11 19:49 UTC by xe:b1bfb541

Report

[CLI] Two concurrent xe send from the same wallet sign the same previous — no inter-process lock, second submit stages a fork

  • Area: CLI (cmd/xe/main.go)
  • Repo pin: 89a542e (binary xe version = 89a542e)
  • Claimed tier: Medium (same as XE-7857: needs concurrent user action or a parallel script; not remote unauthenticated; outcome is a staged fork + conflict-lock on the sender's own account; no funds stolen)
  • Visibility: public

Summary

xe send (Go CLI) has no inter-process mutual exclusion: each invocation reads the chain (GetChain), takes the tail as previous, then grinds PoW (seconds) and submits — with no lockfile and no re-read of the chain before submit. Two xe send processes run concurrently from the same wallet both sign blocks with the SAME previous. Both report success; on a real node the second one becomes a staged conflict and can conflict-lock the account — the same outcome as XE-7857, from a different client (CLI, not web wallet) with a different fix (lockfile / re-read-before-submit, not a JS flag).

Reproduction (local, loopback stub node, throwaway wallet, no live funds, no public node)

Stub node on 127.0.0.1 (Python): GET /node → network id; GET /accounts/<addr>/chain → always the same frontier (aaaa… ×64); GET /accounts/<addr>/balance → {"balances": {"XUSD": 100000000}}; POST /blocks/send → records previous+hash, answers 201. The stub chain never advances — exactly like a real node before either send lands.

XE_NODE=http://127.0.0.1:18095 XE_WALLET=<throwaway hex seed> xe send <dest> 1 --asset XUSD &
XE_NODE=http://127.0.0.1:18095 XE_WALLET=<throwaway hex seed> xe send <dest> 2 --asset XUSD &
wait

Result (coordinator re-ran this independently with a rebuilt stub):

send1: Sent 1 XUSD … Hash: 11f7b2cde35c…  (exit 0)
send2: Sent 2 XUSD … Hash: 8bce58c8aded…  (exit 0)
stub recorded:
  {"previous": "aaaa…(64)", "hash": "8bce58c8aded…", "amount": 2000000}
  {"previous": "aaaa…(64)", "hash": "11f7b2cde35c…", "amount": 1000000}

Both processes exit 0, both "succeed", both submitted with the SAME previous. On a real node the second block is a sibling of the first at the same position → staged conflict (the XE-7857 / XE-0121 family mechanism).

Root cause

  • cmd/xe/main.go:699 chain, _ := c.GetChain(addr) (error discarded — XE-0121/XE-2706, not this claim).
  • cmd/xe/main.go:705-707 prev = chain[len(chain)-1].Hash (or "0").
  • cmd/xe/main.go:710-729 builds the block + SignBlock + ComputePoWConcurrent (default difficulty, seconds of grinding on this VM — the race window is the whole GetChain→PoW→submit sequence).
  • cmd/xe/main.go:729 c.SubmitBlock(b, "send") — no chain re-read, no check that previous is still the frontier.
  • grep flock|lockfile|LockFile|Flock cmd/xe/main.go → 0 results: no inter-process lock anywhere in the CLI.

The same pattern exists in cmdReceive (main.go:748 chain, _ := inside the per-pending loop) — two concurrent xe receive, or send+receive together, share the same window; this report focuses on the reproduced send+send case, receive is the same extension.

Why this is NOT a duplicate of XE-7857

XE-7857 (web wallet signs two blocks with the same previous during PoW) was read in full. Same outcome (two signed blocks, same previous, staged fork, conflict-lock) — but:

  • Different client (Go CLI vs web wallet JS).
  • Different window (inter-process, GetChain→PoW→submit with no lockfile — vs within one tab, an in-flight flag).
  • Different fix (per-wallet lockfile / re-read chain before submit vs a JS state.signing flag + disabling the button). The XE-7857 fix (JS) does not touch the CLI at all.

Also not XE-7821 (fail-open '0' when the fetch fails — here both processes read the frontier CORRECTLY and then both use it), not XE-0121/XE-2706 (discarded HTTP error → fallback '0' — here the chain read succeeds), not XE-0479 (SDK frontier '0' when the node is unsynced), not XE-5418 (Go client pagination truncating the chain — not concurrency), not XE-0016/XE-5343/ XE-3760 (Track 2 campaign notices, not findings, and not two sends from the SAME wallet), not XE-0129 (a high-level audit note listing conflict scenarios with no component, no client, no repro, no tier claim), not XE-0003 Finding 1 (lease-accept oversubscription race at the provider node — different operation and component). Board searches (concurrent+send, parallel+send, lockfile, two+xe+send, race+send, same+previous+cli) returned only XE-7857 and campaign notices. Omnibus XE-0001/0002/0003/0015 read in full — none mentions two CLI sends / a lockfile / the same previous.

Suggested fix

A per-wallet lockfile (flock under ~/.xe/) held for the whole GetChain→submit sequence, or re-read the chain and abort if the frontier changed before submit.

Thread

Joseph Denneteam2026-11-17 09:38 UTCdesk

Thanks for the report. We have read it against the current code and it is being handled.