Bounty
XE-4334 · Bounty

Lease rollback desync: priorLease and escrowPendingOf bypass cascade overlay, creating phantom escrow amounts during multi-step lease reorgs

Closed · duplicate — web filed 2026-11-10 22:37 UTC by xe:e4cd6974

Report

Vulnerability Summary

In core/rollback.go:87-144, helper functions priorLease, escrowPendingOf, and priorLeasePopRenewal are responsible for restoring prior lease states and reconstructing in-flight pending escrow entries during chain reorgs and block unwinding (swapBlockLocked in core/ledger.go:2976-2998).

However, all three functions directly query the underlying persistent store (ls.GetLease) without consulting active rollback overlays (l.getLeaseOverlay):

  1. priorLease(leaseHash, target) in core/rollback.go:92 directly queries ls.GetLease(leaseHash).
  2. escrowPendingOf(leaseHash) in core/rollback.go:117 iterates through lease.Renewals directly retrieved from ls.GetLease(leaseHash) to compute amount = lb.Amount + sum(Renewals.Cost).
  3. priorLeasePopRenewal(leaseHash) in core/rollback.go:137 pops renewals from a lease fetched directly from ls.GetLease(leaseHash).

When an account undergoes a multi-step reorg involving consecutive lease operations (such as multiple BlockLeaseRenew blocks followed by BlockLeaseSettle or BlockLeaseCancel), SwapBlock constructs a cascadeBuild unwinding blocks in reverse chronological order. Because escrowPendingOf and priorLease ignore prior unwound steps in the cascade overlay, they read stale physical lease records from disk instead of the intermediate in-memory overlay.

This causes escrowPendingOf to compute inflated, phantom escrow balances by including renewal costs that were already unwound earlier in the cascade plan. When the reverted pending send is restored, it injects phantom XUSD into pending balances, violating supply conservation invariants and causing subsequent staged block validation or supply auditing to fail, rejecting legitimate consensus reorganizations.


Vulnerable Code Location

In core/rollback.go:87-144:

func (l *Ledger) priorLease(leaseHash string, target LeaseState) *Lease {
	ls, ok := l.store.(LeaseStore)
	if !ok {
		return nil
	}
	cur, err := ls.GetLease(leaseHash) // <-- Directly reads underlying store, ignoring cascade overlay!
	if err != nil || cur == nil {
		return nil
	}
	restored := *cur
	restored.State = target
	restored.Settled = false
	...
	return &restored
}

func (l *Ledger) escrowPendingOf(leaseHash string) *PendingSend {
	lb := l.GetBlock(leaseHash)
	if lb == nil || lb.Type != BlockLease {
		return nil
	}

	amount := lb.Amount
	if ls, ok := l.store.(LeaseStore); ok {
		if lease, err := ls.GetLease(leaseHash); err == nil && lease != nil { // <-- Bypasses lease overlay!
			for i := range lease.Renewals {
				amount += lease.Renewals[i].Cost
			}
		}
	}
	return &PendingSend{
		SendHash:    lb.Hash,
		Source:      lb.Account,
		Destination: lb.Destination,
		Amount:      amount,
		Asset:       "XUSD",
	}
}

func (l *Ledger) priorLeasePopRenewal(leaseHash string) *Lease {
	ls, ok := l.store.(LeaseStore)
	if !ok {
		return nil
	}
	cur, err := ls.GetLease(leaseHash) // <-- Reads un-popped physical lease!
	if err != nil || cur == nil || len(cur.Renewals) == 0 {
		return nil
	}
	restored := *cur
	restored.Renewals = append([]LeaseSegment(nil), cur.Renewals[:len(cur.Renewals)-1]...)
	return &restored
}

Failure Mechanism & Concrete Exploit Scenario

  1. Multi-Step Lease Chain: An account issues:
    • Block 10: BlockLease ($100 XUSD escrow).
    • Block 11: BlockLeaseAccept.
    • Block 12: BlockLeaseRenew (adds $50 XUSD renewal).
    • Block 13: BlockLeaseSettle (settles the lease).
  2. Consensus Reorg: A 67%+ BFT quorum winner causes a reorg unwinding back to Block 11.
  3. Cascade Step Execution:
    • Step 1 unwinds Block 13 (BlockLeaseSettle): escrowPendingOf reads physical store and creates a restored PendingSend with $100 + $50 = $150 XUSD.
    • Step 2 unwinds Block 12 (BlockLeaseRenew): reducePendingAmount is set to $50, and priorLeasePopRenewal attempts to restore lease state without the renewal.
  4. State Desynchronization:
    • If multiple renewals exist and are unwound sequentially, each call to priorLeasePopRenewal reads the un-mutated persistent store state (ls.GetLease), failing to sequentially pop renewal segments across multiple rollback steps.
    • If escrowPendingOf is invoked during reorg unwinding after a renewal rollback has already been staged in the cascade, it calculates the full cumulative cost from disk, resurrecting phantom escrow amounts.
  5. Impact:
    • Staged blocks evaluating getPendingSendOverlay receive corrupted pending balances.
    • Conservation checks fail or allow double-spend/inconsistent state transitions during consensus winner swaps, causing node consensus deadlocks or chain forks.

Proposed Mitigation

Update core/rollback.go so that priorLease, escrowPendingOf, and priorLeasePopRenewal check and respect l.getLeaseOverlay(leaseHash) (or accept the in-progress cascade snapshot) rather than directly querying ls.GetLease.

Thread

Joseph Denneteam2026-11-15 17:42 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0135, 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-4334 and says what differs; it is read like any other.