Bounty
XE-9686 · Bounty

Staged Block Validation Bypass: ValidateStagedBlock omits structural field constraints and memo restrictions on BlockMint and BlockBurn

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

Report

Vulnerability Summary

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

Normal block ingestion via validateAndAddBurn (core/ledger.go:1026-1069) and validateAndAddMint (core/mint.go:28-80) strictly enforces protocol invariants regarding forbidden routing fields, non-zero values, and memo restrictions:

For BlockBurn:

  • if b.Destination != "" || b.Source != "" { return fmt.Errorf("burn: must not have source or destination") }
  • if err := ValidateMemo(b.Memo); err != nil { return fmt.Errorf("burn: %w", err) }

For BlockMint:

  • if b.Destination != "" || b.Source != "" { return fmt.Errorf("mint: must not have source or destination") }
  • if b.Memo != "" { return fmt.Errorf("mint: memo not allowed") }

However, in ValidateStagedBlock (core/ledger.go:2839-2869), these structural checks are completely omitted:

	case BlockBurn:
		if b.Asset != "XE" {
			return fmt.Errorf("staged burn: restricted to XE")
		}
		if b.Amount == 0 {
			return fmt.Errorf("staged burn: amount must be > 0")
		}
		if b.Amount > parentBalance {
			return fmt.Errorf("staged burn: insufficient balance: have %d XE, burning %d", parentBalance, b.Amount)
		}
		if b.Balance != parentBalance-b.Amount {
			return fmt.Errorf("staged burn: balance mismatch: expected %d, got %d", parentBalance-b.Amount, b.Balance)
		}
        // MISSING: check that Destination == "" and Source == ""
        // MISSING: ValidateMemo(b.Memo)

	case BlockMint:
		if b.Asset != "XUSD" {
			return fmt.Errorf("staged mint: restricted to XUSD")
		}
		if !l.isMinter(b.Account) {
			return fmt.Errorf("staged mint: account %s is not an authorized minter", shortAddr(b.Account))
		}
		if b.Amount == 0 {
			return fmt.Errorf("staged mint: amount must be > 0")
		}
		expectedBal := parentBalance + b.Amount
		if expectedBal < parentBalance {
			return fmt.Errorf("staged mint: balance would overflow uint64")
		}
		if b.Balance != expectedBal {
			return fmt.Errorf("staged mint: balance mismatch: expected %d, got %d", expectedBal, b.Balance)
		}
        // MISSING: check that Destination == "" and Source == ""
        // MISSING: check that b.Memo == ""

Vulnerable Code Locations

  1. core/ledger.go:2839-2851: case BlockBurn checks only asset, amount > 0, parent balance, and balance equation. It omits checking b.Destination == "" and b.Source == "", as well as ValidateMemo(b.Memo).
  2. core/ledger.go:2852-2869: case BlockMint omits verifying that b.Destination == "" and b.Source == "", and omits verifying that b.Memo == "".

Attack & Failure Scenario

  1. An authorized minter (or an attacker generating a conflicting burn block on their account during a reorg/fork) constructs a BlockMint or BlockBurn with malicious, oversized, or smuggling fields:
    • For example, a BlockMint populated with b.Destination = "xe_victim_account" and a non-empty b.Memo.
    • Or a BlockBurn populated with an unvalidated arbitrary-length memo (> 256 bytes or illegal UTF-8 / control characters) or a phantom b.Source / b.Destination.
  2. When injected into an active conflict or quorum vote election, peer nodes execute ValidateStagedBlock(candidate, parentBalance).
  3. Because ValidateStagedBlock omits these checks, the malformed block passes validation and is accepted into stagedStore via PutStagedBlock and promoted via confirmConflict / swapBlockLocked.
  4. When swapBlockLocked calls commitBlockWrite, the block is permanently appended to the canonical chain.
  5. In downstream P2P sync and ledger verification:
    • Nodes syncing the block through standard ingestion pipelines (validateAndAddMint or validateAndAddBurn) reject the block due to b.Destination != "" or b.Memo != "".
    • The network suffers an immediate consensus split / chain fork: nodes that staged the block via quorum consider it canonical, while nodes receiving the block via normal sync reject it as invalid!

Impact

  1. Permanent Network Fork / Consensus Split: Inconsistent validation invariants between live block ingestion and staged conflict resolution allow blocks with illegal routing fields or forbidden memos to enter the chain, causing peers syncing from scratch to reject the chain.
  2. Protocol Smuggling & Storage Bloat: Attackers can smuggle arbitrary metadata into BlockMint and oversized unvalidated memos into BlockBurn past the consensus validation layer.

Remediation

In core/ledger.go, update ValidateStagedBlock:

	case BlockBurn:
		if b.Asset != "XE" {
			return fmt.Errorf("staged burn: restricted to XE")
		}
		if b.Destination != "" || b.Source != "" {
			return fmt.Errorf("staged burn: must not have source or destination")
		}
		if b.Amount == 0 {
			return fmt.Errorf("staged burn: amount must be > 0")
		}
		if b.Amount > parentBalance {
			return fmt.Errorf("staged burn: insufficient balance: have %d XE, burning %d", parentBalance, b.Amount)
		}
		if b.Balance != parentBalance-b.Amount {
			return fmt.Errorf("staged burn: balance mismatch: expected %d, got %d", parentBalance-b.Amount, b.Balance)
		}
		if err := ValidateMemo(b.Memo); err != nil {
			return fmt.Errorf("staged burn: %w", err)
		}

	case BlockMint:
		if b.Asset != "XUSD" {
			return fmt.Errorf("staged mint: restricted to XUSD")
		}
		if !l.isMinter(b.Account) {
			return fmt.Errorf("staged mint: account %s is not an authorized minter", shortAddr(b.Account))
		}
		if b.Destination != "" || b.Source != "" {
			return fmt.Errorf("staged mint: must not have source or destination")
		}
		if b.Memo != "" {
			return fmt.Errorf("staged mint: memo not allowed")
		}
		if b.Amount == 0 {
			return fmt.Errorf("staged mint: amount must be > 0")
		}
		expectedBal := parentBalance + b.Amount
		if expectedBal < parentBalance {
			return fmt.Errorf("staged mint: balance would overflow uint64")
		}
		if b.Balance != expectedBal {
			return fmt.Errorf("staged mint: balance mismatch: expected %d, got %d", expectedBal, b.Balance)
		}

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-9686 and says what differs; it is read like any other.