{"id":"XE-5241","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":1168,"title":"Lease cancel refunds only base cost while deleting entire escrow — renewal top-up funds destroyed","area":"leasing-ledger","claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0067","tracked":true,"internal_ref":"#1097","internal_url":"https://github.com/xeprotocol/core/issues/1097","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-11T08:15:46.135971+00:00","updated_at":"2026-11-15T17:42:16.598376+00:00","source_created_at":null,"told_at":"2026-11-15T17:42:44.545722+00:00","status_changed_at":"2026-11-15T17:42:44.520845+00:00","url":"https://bounty.xe.network/XE-5241","body":"## Summary\n\n`validateAndAddLeaseCancel` refunds the consumer only the ORIGINAL lease cost (`leaseBlock.Amount`), but then deletes the ENTIRE escrow pending-send for that lease via `DeletePendingID`. When a lease has been renewed, the escrow contains base cost + all renewal top-ups (see TopUpPendingID handling: `ps.Amount += c.TopUpPendingAmount`). Renewal funds paid by the consumer are therefore DESTROYED — not refunded, not paid out.\n\n## Details\n\n- Escrow is topped up on every renewal: core/ledger.go validateAndAddLeaseRenew sets commit.TopUpPendingID / TopUpPendingAmount; store applies pending.Amount += TopUpPendingAmount (store/mem_store.go:338).\n- Cancel refunds only the base: core/ledger.go:1855 `expectedBal := oldBal + leaseBlock.Amount`.\n- Cancel then deletes the whole pending: core/ledger.go:1862 `commit.DeletePendingID = b.Source`; store deletes the full pending entry regardless of amount (store/mem_store.go:219).\n- The cancel-wins-over-accept race path (core/ledger.go:1749 resolveCancelWinsOverAccept) explicitly allows cancelling a lease in LeaseAccepted state while the provider's accept is not yet finalized — with NO check on len(lease.Renewals). A consumer who renews immediately after the provider accepts, then submits a cancel inside the race window, gets back only the base cost; every renewal top-up is deleted from the escrow with no beneficiary.\n\n## Impact\n\nConsumer XUSD paid in renewals is permanently destroyed (no refund to consumer, no payout to provider). Fund-loss accounting bug; can also be triggered deliberately inside the accept-finalization race window to void a renewal the provider counted on.\n\n## Affected code\n\n- core/ledger.go:1792 validateAndAddLeaseCancel\n- core/ledger.go:1749 resolveCancelWinsOverAccept\n- core/lease_renew.go (TopUpPendingID flow)\n- store/mem_store.go:219 / store/badger_store.go DeletePendingID (deletes full pending)\n\n## Suggested fix\n\nRefund `pending.Amount` (base + renewals) instead of `leaseBlock.Amount`, or reject cancel when len(lease.Renewals) > 0 in the cancel-wins path; alternatively route top-ups back to the consumer explicitly.\n\n## Environment\n\nStatic analysis of github.com/xeprotocol/xe @ v89a542e; reproducible in mem_store and badger_store backends. Runnable PoC available on request (testnet lease lifecycle: lease -> accept -> renew -> race cancel).","patch_refs":[],"thread":[{"id":6406,"source":"desk","source_ref":"reply:5046","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, file a new report that links https://bounty.xe.network/XE-5241 and says what differs; it is read like any other.","created_at":"2026-11-15T17:42:16.598376+00:00"}]}