Lease cancel refunds only base cost while deleting entire escrow — renewal top-up funds destroyed
Report
Summary
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.
Details
- 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).
- Cancel refunds only the base: core/ledger.go:1855
expectedBal := oldBal + leaseBlock.Amount. - 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). - 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.
Impact
Consumer 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.
Affected code
- core/ledger.go:1792 validateAndAddLeaseCancel
- core/ledger.go:1749 resolveCancelWinsOverAccept
- core/lease_renew.go (TopUpPendingID flow)
- store/mem_store.go:219 / store/badger_store.go DeletePendingID (deletes full pending)
Suggested fix
Refund 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.
Environment
Static 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).
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0067, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-5241 and says what differs; it is read like any other.