[Core/High] LeaseCancel balance overflow allows wrapped-balance double-spend — missing overflow check in validateAndAddLeaseCancel
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
- Create account with XUSD balance near MaxUint64
- Cancel a lease with non-trivial escrow Amount
oldBal + leaseBlock.Amountoverflows uint64 → small value- Craft
b.Balanceto match the wrapped value - 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
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.