{"id":"XE-8012","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":606,"title":"[CLI] Two concurrent `xe send` from the same wallet sign the same previous — no inter-process lock, second submit stages a fork","area":"sdk-docs-web","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-11T19:49:55.608844+00:00","updated_at":"2026-11-17T09:41:59.211360+00:00","source_created_at":null,"told_at":"2026-11-17T09:38:21.321362+00:00","status_changed_at":"2026-11-17T09:37:25.325879+00:00","url":"https://bounty.xe.network/XE-8012","body":"# [CLI] Two concurrent `xe send` from the same wallet sign the same previous — no inter-process lock, second submit stages a fork\r\n\r\n- Area: CLI (`cmd/xe/main.go`)\r\n- Repo pin: 89a542e (binary `xe version` = 89a542e)\r\n- 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)\r\n- Visibility: public\r\n\r\n## Summary\r\n\r\n`xe send` (Go CLI) has no inter-process mutual exclusion: each invocation reads\r\nthe chain (`GetChain`), takes the tail as `previous`, then grinds PoW (seconds)\r\nand submits — with no lockfile and no re-read of the chain before submit. Two\r\n`xe send` processes run concurrently from the same wallet both sign blocks with\r\nthe SAME `previous`. Both report success; on a real node the second one becomes\r\na staged conflict and can conflict-lock the account — the same outcome as\r\nXE-7857, from a different client (CLI, not web wallet) with a different fix\r\n(lockfile / re-read-before-submit, not a JS flag).\r\n\r\n## Reproduction (local, loopback stub node, throwaway wallet, no live funds, no public node)\r\n\r\nStub node on `127.0.0.1` (Python): `GET /node` → network id;\r\n`GET /accounts/<addr>/chain` → always the same frontier (`aaaa…` ×64);\r\n`GET /accounts/<addr>/balance` → `{\"balances\": {\"XUSD\": 100000000}}`;\r\n`POST /blocks/send` → records `previous`+`hash`, answers 201. The stub chain\r\nnever advances — exactly like a real node before either send lands.\r\n\r\n```sh\r\nXE_NODE=http://127.0.0.1:18095 XE_WALLET=<throwaway hex seed> xe send <dest> 1 --asset XUSD &\r\nXE_NODE=http://127.0.0.1:18095 XE_WALLET=<throwaway hex seed> xe send <dest> 2 --asset XUSD &\r\nwait\r\n```\r\n\r\nResult (coordinator re-ran this independently with a rebuilt stub):\r\n\r\n```\r\nsend1: Sent 1 XUSD … Hash: 11f7b2cde35c…  (exit 0)\r\nsend2: Sent 2 XUSD … Hash: 8bce58c8aded…  (exit 0)\r\nstub recorded:\r\n  {\"previous\": \"aaaa…(64)\", \"hash\": \"8bce58c8aded…\", \"amount\": 2000000}\r\n  {\"previous\": \"aaaa…(64)\", \"hash\": \"11f7b2cde35c…\", \"amount\": 1000000}\r\n```\r\n\r\nBoth processes exit 0, both \"succeed\", both submitted with the SAME `previous`.\r\nOn a real node the second block is a sibling of the first at the same position\r\n→ staged conflict (the XE-7857 / XE-0121 family mechanism).\r\n\r\n## Root cause\r\n\r\n- `cmd/xe/main.go:699` `chain, _ := c.GetChain(addr)` (error discarded —\r\n  XE-0121/XE-2706, not this claim).\r\n- `cmd/xe/main.go:705-707` `prev = chain[len(chain)-1].Hash` (or `\"0\"`).\r\n- `cmd/xe/main.go:710-729` builds the block + `SignBlock` +\r\n  `ComputePoWConcurrent` (default difficulty, seconds of grinding on this VM —\r\n  the race window is the whole GetChain→PoW→submit sequence).\r\n- `cmd/xe/main.go:729` `c.SubmitBlock(b, \"send\")` — no chain re-read, no check\r\n  that `previous` is still the frontier.\r\n- `grep flock|lockfile|LockFile|Flock cmd/xe/main.go` → 0 results: no\r\n  inter-process lock anywhere in the CLI.\r\n\r\nThe same pattern exists in `cmdReceive` (`main.go:748` `chain, _ :=` inside the\r\nper-pending loop) — two concurrent `xe receive`, or `send`+`receive` together,\r\nshare the same window; this report focuses on the reproduced `send`+`send`\r\ncase, receive is the same extension.\r\n\r\n## Why this is NOT a duplicate of XE-7857\r\n\r\nXE-7857 (web wallet signs two blocks with the same previous during PoW) was\r\nread in full. Same outcome (two signed blocks, same previous, staged fork,\r\nconflict-lock) — but:\r\n\r\n- Different client (Go CLI vs web wallet JS).\r\n- Different window (inter-process, GetChain→PoW→submit with no lockfile — vs\r\n  within one tab, an in-flight flag).\r\n- Different fix (per-wallet lockfile / re-read chain before submit vs a JS\r\n  `state.signing` flag + disabling the button). The XE-7857 fix (JS) does not\r\n  touch the CLI at all.\r\n\r\nAlso not XE-7821 (fail-open `'0'` when the fetch fails — here both processes\r\nread the frontier CORRECTLY and then both use it), not XE-0121/XE-2706\r\n(discarded HTTP error → fallback `'0'` — here the chain read succeeds),\r\nnot XE-0479 (SDK frontier `'0'` when the node is unsynced), not XE-5418 (Go\r\nclient pagination truncating the chain — not concurrency), not XE-0016/XE-5343/\r\nXE-3760 (Track 2 campaign notices, not findings, and not two sends from the\r\nSAME wallet), not XE-0129 (a high-level audit note listing conflict scenarios\r\nwith no component, no client, no repro, no tier claim), not XE-0003 Finding 1\r\n(lease-accept oversubscription race at the provider node — different operation\r\nand component). Board searches (`concurrent+send`, `parallel+send`,\r\n`lockfile`, `two+xe+send`, `race+send`, `same+previous+cli`) returned only\r\nXE-7857 and campaign notices. Omnibus XE-0001/0002/0003/0015 read in full —\r\nnone mentions two CLI sends / a lockfile / the same previous.\r\n\r\n## Suggested fix\r\n\r\nA per-wallet lockfile (`flock` under `~/.xe/`) held for the whole\r\nGetChain→submit sequence, or re-read the chain and abort if the frontier\r\nchanged before submit.","patch_refs":[],"thread":[{"id":9785,"source":"desk","source_ref":"reply:8223","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read it against the current code and it is being handled.","created_at":"2026-11-17T09:38:21.313093+00:00"}]}