Bounty
XE-9701 · Bounty

Staged Block Validation Bypass: ValidateStagedBlock omits asset matching, destination validation, and memo validation on BlockReceive and BlockSend

Closed · duplicate — web filed 2026-11-12 06:31 UTC by xe:e4cd6974

Report

Vulnerability Summary

In core/ledger.go:2732-2870, ValidateStagedBlock(b *Block, parentBalance uint64) error performs consensus validation on candidate blocks competing in BFT quorum elections before they are promoted or staged.

Normal block ingestion pipelines enforce critical structural protocol invariants:

  1. In validateAndAddReceive (core/ledger.go:1107-1114):
    pendingAsset := pending.Asset
    if pendingAsset == "" {
        pendingAsset = "XE"
    }
    if b.Asset != pendingAsset {
        return fmt.Errorf("receive asset %q does not match pending send asset %q", b.Asset, pendingAsset)
    }
    
    And ValidateMemo(b.Memo) is enforced during block verification/parsing (core/encoding.go:79).
  2. In validateAndAddSend (core/ledger.go:999-1009):
    if err := ValidateMemo(b.Memo); err != nil {
        return fmt.Errorf("send: %w", err)
    }
    

However, inside ValidateStagedBlock (core/ledger.go:2740-2778):

	case BlockSend:
		if b.Amount == 0 {
			return fmt.Errorf("staged send: amount must be > 0")
		}
		if b.Amount > parentBalance {
			return fmt.Errorf("staged send: insufficient balance: have %d, sending %d", parentBalance, b.Amount)
		}
		if b.Balance != parentBalance-b.Amount {
			return fmt.Errorf("staged send: balance mismatch: expected %d, got %d", parentBalance-b.Amount, b.Balance)
		}
		if b.Destination == "" {
			return fmt.Errorf("staged send: must have a destination")
		}
		if b.Destination == b.Account {
			return fmt.Errorf("staged send: cannot send to self")
		}
        // MISSING: ValidateMemo(b.Memo)

	case BlockReceive:
		if b.Source == "" {
			return fmt.Errorf("staged receive: must reference a source send")
		}
		pending, err := l.store.GetPendingSend(b.Source)
		if err != nil {
			return fmt.Errorf("staged receive: GetPendingSend: %w", err)
		}
		if pending == nil {
			return fmt.Errorf("staged receive: source send not pending: %s", shortHash(b.Source))
		}
		if pending.Destination != b.Account {
			return fmt.Errorf("staged receive: send not addressed to this account")
		}

		if l.isLiveLeaseEscrow(b.Source) {
			return fmt.Errorf("staged receive: cannot receive a live lease escrow: %s", shortHash(b.Source))
		}
		expectedBal := parentBalance + pending.Amount
		if expectedBal < parentBalance {
			return fmt.Errorf("staged receive: balance would overflow uint64")
		}
		if b.Balance != expectedBal {
			return fmt.Errorf("staged receive: balance mismatch: expected %d, got %d", expectedBal, b.Balance)
		}
        // MISSING: b.Asset != pendingAsset check!
        // MISSING: Destination must be empty ("") check!
        // MISSING: ValidateMemo(b.Memo)

Notice that ValidateStagedBlock for BlockReceive completely omits checking that b.Asset matches pending.Asset! Furthermore, it does not check that b.Destination == "" on a receive block, nor does it enforce ValidateMemo(b.Memo) on staged sends and receives.


Vulnerable Code Locations

  • core/ledger.go:2752-2778: case BlockReceive compares b.Source, pending.Destination, isLiveLeaseEscrow, and updates b.Balance based on pending.Amount. However, it never compares b.Asset with pending.Asset!
  • core/ledger.go:2740-2751: case BlockSend omits memo validation ValidateMemo(b.Memo).

Attack & Failure Scenario

  1. Cross-Asset Balance Inflation / Stealing via Quorum Staging:
    • Alice has a pending send of 1,000 XE from Bob (pending.Asset = "XE", pending.Amount = 1000).
    • Alice creates a conflicting BlockReceive with b.Asset = "XUSD", referencing Bob's pending send hash b.Source.
    • In a quorum election on Alice's account, representative nodes execute ValidateStagedBlock(candidate, parentBalance).
    • ValidateStagedBlock checks pending.Amount == 1000, adds it to parentBalance, and verifies b.Balance. It never verifies that b.Asset == pending.Asset!
    • The candidate block wins the quorum vote, is promoted via confirmConflict / swapBlockLocked, and Alice's account now has 1,000 XUSD instead of 1,000 XE on the canonical chain!
  2. Permanent Consensus Split / Chain Fork:
    • Nodes performing standard block synchronization (validateAndAddReceive) verify:
      if b.Asset != pendingAsset {
          return fmt.Errorf("receive asset %q does not match pending send asset %q", b.Asset, pendingAsset)
      }
      
    • When peers syncing from scratch or from network gossip ingest this block, validateAndAddReceive throws an asset mismatch error and rejects the block.
    • The network fractures into a permanent consensus fork: nodes participating in the quorum conflict accepted the block, while standard sync nodes reject it as invalid!

Impact

  1. Cross-Asset Arbitrary Conversion / Balance Manipulation: Attackers can receive XE pending transfers as high-value XUSD balances by winning staged conflict elections, bypassing the protocol's currency division.
  2. Consensus Desynchronization / Chain Partition: Discrepancies between ValidateStagedBlock and validateAndAddReceive allow invalid cross-asset blocks into the staged/canonical state, causing follower nodes to permanently diverge from representative nodes.

Remediation

  1. In core/ledger.go, update ValidateStagedBlock for BlockReceive to strictly check asset parity:
    case BlockReceive:
        ...
        pendingAsset := pending.Asset
        if pendingAsset == "" {
            pendingAsset = "XE"
        }
        if b.Asset != pendingAsset {
            return fmt.Errorf("staged receive: asset %q does not match pending send asset %q", b.Asset, pendingAsset)
        }
        if b.Destination != "" {
            return fmt.Errorf("staged receive: must not have destination")
        }
        if err := ValidateMemo(b.Memo); err != nil {
            return fmt.Errorf("staged receive: %w", err)
        }
    
  2. For BlockSend, ensure memo validation is enforced:
    case BlockSend:
        ...
        if err := ValidateMemo(b.Memo); err != nil {
            return fmt.Errorf("staged send: %w", err)
        }
    

Thread

Joseph Denneteam2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as an earlier report that is not public, 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-9701 and says what differs; it is read like any other.