{"id":"XE-0101","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"158","source_url":"https://github.com/xeprotocol/xe/issues/158","reporter_id":32,"title":"Live lease cancel destroys renewal escrow","area":null,"claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0067","tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:26.773732+00:00","updated_at":"2026-11-10T00:11:32.070096+00:00","source_created_at":"2026-10-29T02:44:14+00:00","told_at":"2026-11-05T22:11:20+00:00","status_changed_at":"2026-11-05T22:11:11.276765+00:00","url":"https://bounty.xe.network/XE-0101","body":"# Live lease cancel destroys renewal escrow\n\n## Summary\n\nCancelling a renewed lease live refunds only the original lease cost while\ndeleting the entire pending escrow (original cost plus renewals). The renewal\nfunds are destroyed. Force-settle and staged cancel both refund the full\npending amount, so the protocol contradicts itself: the same escrow is worth\nits full value on two exit paths and only its original value on the third.\n\n## Impact\n\nAny consumer who cancels a renewed lease loses exactly the renewal sum. In\nthe proof of concept, a lease of 40,000 micro-XUSD renewed once (+40,000,\npending 80,000) cancels with a refund of 40,000 instead of 80,000 — 40,000\nmicro-XUSD destroyed through normal protocol use, with no attacker gain and\nno attacker required. A secondary consequence: a renewed-lease cancel can\nnever satisfy both the live path (which demands the original-only balance)\nand the staged path (which demands the full pending) at once.\n\nSuggested program tier: **High** (fund loss through normal use; not Critical\n— there is no theft and no attacker profit).\n\n## Root cause\n\n- `core/ledger.go` (live cancel): the expected balance is computed as the old\n  balance plus the original lease amount only, while the commit deletes the\n  whole pending entry for the lease source.\n- `core/ledger.go` (force-settle) and the staged-cancel path: refund the full\n  pending amount.\n- `core/lease_renew.go`: renewals top up the same pending entry, so the\n  original and renewal funds are indistinguishable by the time cancel runs.\n\n## Proof of concept\n\nTarget: `xeprotocol/xe` @ `978785929bc17a2f4ab30c383e5fc9cf4d634512`\n(2026-10-15). The harness runs against the real `core` and `store` packages\nvia a replace directive; the repository itself is not modified.\n\nAttached PoC: `pocs/harness-slice1-main.go.txt` (byte-identical copy of the\nrunnable harness; the cancel case is the `C2` section).\n\nRun (Go 1.25.14):\n\n```\nexport PATH=\"$HOME/.local/go/bin:$PATH\"\ncd harness-slice1\nGOPROXY=off go run .\n```\n\nObserved output (verbatim):\n\n```\noriginal cost=40000 renewal cost=40000 escrow pending=80000\ncancel with FULL pending refund err=balance mismatch: expected 9960000, got 10000000 (expect balance mismatch)\ncancel with ORIGINAL-only refund err=<nil>\nconsumer XUSD before=9920000 after=9960000 delta=40000 (pending refunded would be 80000)\nescrow pending after cancel: <nil> (nil = deleted)\nDESTROYED renewal escrow = 40000\n```\n\nA cancel claiming the full 80,000 pending is rejected by the balance check;\na cancel claiming only the original 40,000 succeeds, and the remaining\n40,000 vanishes with the deleted pending entry.\n\n## Reproduction steps\n\n1. Create and accept a lease (cost 40,000 micro-XUSD), then renew it once\n   (+40,000).\n2. Submit a live `lease_cancel` block with balance = old balance + 40,000.\n3. Observed: succeeds, renewal 40,000 gone. Submitting with old balance +\n   80,000 is rejected.\n\n## Recommended fix\n\nLive cancel must refund the full pending amount, like force-settle and staged\ncancel do, or the pending entry must be split so renewals survive a cancel.\n\n## Severity\n\n- CVSS 3.1: 7.5 — `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N`\n- CWE-682 (Incorrect Calculation)\n\n## Caveats\n\n- Related public report, distinct mechanism: public issue #4 (F3) covers\n  force-settle accounting, supply conservation, per-lease locking, and\n  conflict staging for renewals. It does not cover the live-cancel refund\n  path (different handler, different formula). This finding is the live-cancel\n  path only, and the distinction is stated here so triage can judge it.\n- This reproduction runs against the repository code at the stated HEAD. No\n  testnet transactions were sent as part of this report.\n\nPayout address (XE): eff2c51dd8457df740b919226cd9b37a2944e5abea7501094db80234f87f010e\n\nBest,\nChaplin\n\n[harness-slice1-main.go.txt](https://github.com/user-attachments/files/34109897/harness-slice1-main.go.txt)","patch_refs":[{"id":172,"repo":"xeprotocol/xe","kind":"pr","ref":"171","title":"core/ledger: refund full pending escrow on live lease cancel (#158)","url":"https://github.com/xeprotocol/xe/pull/171","note":"","state":"open","author":"fangjian-bit","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":47,"source":"github","source_ref":"6489164119","author":"fangjian-bit","team":false,"body":"Submitted fix and regression test in #171.\n\nRoot cause was `expectedBal := oldBal + leaseBlock.Amount` in `validateAndAddLeaseCancel`, which only refunded the initial lease amount while deleting the entire pending escrow (`DeletePendingID`), effectively destroying renewal top-ups. Fixed to refund `pending.Amount` and added end-to-end verification in `core/lease_cancel_test.go`.","created_at":"2026-10-29T05:54:33+00:00"},{"id":436,"source":"github","source_ref":"6670869135","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0067, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, reply with what differs and we will look again.","created_at":"2026-11-05T22:11:20+00:00"}]}