Bounty
XE-0661 · Bounty

[Core/High] LeaseCancel balance overflow allows wrapped-balance double-spend — missing overflow check in validateAndAddLeaseCancel

Triaging claimed High web filed 2026-11-05 10:21 UTC by Ashev Ardiansyah

Report

Summary

validateAndAddLeaseCancel at ledger.go:1853 computes expectedBal := oldBal + leaseBlock.Amount without overflow protection. Every other XUSD-increasing operation in the ledger (LeaseSettle at 1970, LeaseForceSettle at 1970, Mint at 68) has an explicit if expectedBal < oldBal overflow check. LeaseCancel is the sole balance-increasing path missing this guard.

Affected Code

// ledger.go:1853
expectedBal := oldBal + leaseBlock.Amount  // overflow not checked
if expectedBal != b.Balance {
    return fmt.Errorf(...)
}

Impact

Block passes validation despite wrapping around uint64 max. The consumer account receives an incorrect (wrapped) balance instead of the correct oldBal + escrowAmount. This is a double-spend-equivalent: consumer gets both the escrow refund AND retains balance up to the wrap boundary.

Reproduction

  1. Create account with XUSD balance near MaxUint64
  2. Cancel a lease with non-trivial escrow Amount
  3. oldBal + leaseBlock.Amount overflows uint64 → small value
  4. Craft b.Balance to match the wrapped value
  5. Block is committed, consumer balance wraps

Severity

High — financial integrity bug, balance manipulation vector.

Fix

expectedBal := oldBal + leaseBlock.Amount
if expectedBal < oldBal {
    return fmt.Errorf("lease_cancel: balance overflow")
}

Thread

Joseph Denneteam2026-11-08 20:56 UTCdesk

Thanks for the report. We have confirmed the inconsistency you point out in the lease cancel validation and it is being handled. Note that the precondition is not reachable through accepted blocks today and the effect would not create funds, which is reflected in how we are treating it. We will update this ticket when a fix has shipped.