Bounty
XE-4323 · Bounty

Consensus ledger desync: GetAssetBalanceAtBlock bypasses cascade overlay during conflict reorgs, causing false balance mismatch and winner promotion rejection

Closed · invalid — web filed 2026-11-10 22:06 UTC by xe:e4cd6974

Report

Vulnerability Summary

In core/ledger.go:3014-3040, GetAssetBalanceAtBlock(account, asset, blockHash string) computes the historical asset balance of an account up to a specific block boundary. This function is called directly by the consensus engine in core/quorum.go:306-313 during confirmConflict:

if result.ConflictPrev != "0" {
    parentBalance = qm.ledger.GetAssetBalanceAtBlock(result.ConflictAccount, asset, result.ConflictPrev)
}
if err := qm.ledger.ValidateStagedBlock(winnerBlock, parentBalance); err != nil {
    log.Printf("confirmConflict: staged winner %s failed validation: %v — refusing promotion", shortHash(result.WinnerHash), err)
    return fmt.Errorf("confirmConflict: invalid staged winner: %w", err)
}

However, while xusdBalanceOnChain in core/rollback.go was patched to consult lease state during reorgs, GetAssetBalanceAtBlock in core/ledger.go:

  1. Reads directly from the underlying physical store via l.store.GetAccountChain(account) instead of l.getAccountChainOverlay(account).
  2. Resolves lease settlements via ls.GetLease(b.Source) directly from the physical store instead of l.getLeaseOverlay(b.Source).

When confirmConflict or SwapBlock executes a reorg unwinding across dependent blocks, an active cascadeCommit overlay is in place. Because GetAssetBalanceAtBlock completely ignores the active cascade overlay, it returns a stale/desynchronized parentBalance. Consequently, ValidateStagedBlock fails with a false balance mismatch, causing the node to refuse promotion of the legitimate BFT quorum winner and deadlocking consensus conflict resolution.


Vulnerable Code Location

In core/ledger.go:3014-3040:

func (l *Ledger) GetAssetBalanceAtBlock(account, asset, blockHash string) uint64 {
    chain, err := l.store.GetAccountChain(account) // <-- Bypasses account chain overlay!
    if err != nil || chain == nil {
        return 0
    }
    ls, hasLeases := l.store.(LeaseStore)
    xusd := asset == "XUSD"
    var bal uint64
    for _, b := range chain.Blocks {
        a := b.Asset
        if a == "" {
            a = "XE"
        }
        if a == asset {
            bal = b.Balance
        }
        if xusd && b.Type == BlockLeaseSettle && hasLeases {
            if lease, lerr := ls.GetLease(b.Source); lerr == nil && lease != nil { // <-- Bypasses lease overlay!
                bal += lease.Stake
            }
        }
        if b.Hash == blockHash {
            break
        }
    }
    return bal
}

Failure Mechanism

  1. Conflict Resolution During Reorg: A conflict winner (winnerBlock) is selected by 67%+ quorum on an account that has uncommitted/unwound blocks under an active cascade overlay.
  2. Historical Balance Calculation: confirmConflict invokes GetAssetBalanceAtBlock(account, asset, prev) to establish the parent balance baseline before validating the staged winner.
  3. Overlay Bypass:
    • GetAssetBalanceAtBlock reads blocks and lease states directly from the persistent store (l.store), completely oblivious to the unwound state in the active cascade overlay.
    • If previous blocks in the account chain or related lease settlements were modified/reverted in the cascade overlay, GetAssetBalanceAtBlock calculates an incorrect balance.
  4. Promotion Refusal:
    • ValidateStagedBlock verifies winnerBlock.Balance == parentBalance - amount (or + amount).
    • Due to the desynchronized parentBalance, ValidateStagedBlock returns balance mismatch: expected X, got Y.
    • confirmConflict logs refusing promotion and halts consensus resolution for the conflict.

Proposed Mitigation

Update GetAssetBalanceAtBlock in core/ledger.go to respect active cascade overlays:

  1. Use l.getAccountChainOverlay(account) instead of l.store.GetAccountChain(account).
  2. Use l.getLeaseOverlay(b.Source) instead of ls.GetLease(b.Source).

Thread

XE deskteam2026-11-15 17:58 UTCdesk

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links https://bounty.xe.network/XE-4323 and says what; it is read like any other.