<!-- XE-5241 · Lease cancel refunds only base cost while deleting entire escrow — renewal top-up funds destroyed · testnet -->
*Markdown view of <https://bounty.xe.network/XE-5241>. The page is the record; this is the same page for reading.*

XE-5241 · Bounty

# Lease cancel refunds only base cost while deleting entire escrow — renewal top-up funds destroyed

Closed · duplicate
—claimed High
web
filed 2026-11-11 08:15 UTC
by xe:045b40a6

Verdict
:   Duplicate

Tier
:   —

Claimed
:   High

Area
:   Leasing / ledger

Duplicate of
:   [XE-0067](https://bounty.xe.network/XE-0067) accepted

Tracked
:   internally

Updated
:   2026-11-15 17:42 UTC

Told
:   2026-11-15 17:42 UTC

### Patches

None linked.

### History

- [284142](https://bounty.xe.network/log/284142) 2026-11-15 17:42 UTC proposal.adopted
- [284141](https://bounty.xe.network/log/284141) 2026-11-15 17:42 UTC reply.sent
- [284140](https://bounty.xe.network/log/284140) 2026-11-15 17:42 UTC ticket.status new → closed
- [283455](https://bounty.xe.network/log/283455) 2026-11-15 17:42 UTC proposal.adopted
- [283454](https://bounty.xe.network/log/283454) 2026-11-15 17:42 UTC ticket.facts area
- [283453](https://bounty.xe.network/log/283453) 2026-11-15 17:42 UTC proposal.adopted
- [283452](https://bounty.xe.network/log/283452) 2026-11-15 17:42 UTC ticket.facts
- [283451](https://bounty.xe.network/log/283451) 2026-11-15 17:42 UTC proposal.adopted
- [283450](https://bounty.xe.network/log/283450) 2026-11-15 17:42 UTC ticket.facts
- [283449](https://bounty.xe.network/log/283449) 2026-11-15 17:42 UTC proposal.adopted
- [283448](https://bounty.xe.network/log/283448) 2026-11-15 17:42 UTC ticket.facts
- [280804](https://bounty.xe.network/log/280804) 2026-11-15 16:13 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-5241) · [JSON](https://bounty.xe.network/v1/tickets/XE-5241) · [markdown](https://bounty.xe.network/XE-5241.md)

### 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

**Joseph Denne**team2026-11-15 17:42 UTCdesk

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.
