Staged Block Validation Bypass: ValidateStagedBlock omits structural field constraints and memo restrictions on BlockMint and BlockBurn
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
core/ledger.go:2839-2851:case BlockBurnchecks only asset, amount > 0, parent balance, and balance equation. It omits checkingb.Destination == ""andb.Source == "", as well asValidateMemo(b.Memo).core/ledger.go:2852-2869:case BlockMintomits verifying thatb.Destination == ""andb.Source == "", and omits verifying thatb.Memo == "".
Attack & Failure Scenario
- An authorized minter (or an attacker generating a conflicting burn block on their account during a reorg/fork) constructs a
BlockMintorBlockBurnwith malicious, oversized, or smuggling fields:- For example, a
BlockMintpopulated withb.Destination = "xe_victim_account"and a non-emptyb.Memo. - Or a
BlockBurnpopulated with an unvalidated arbitrary-length memo (> 256 bytes or illegal UTF-8 / control characters) or a phantomb.Source/b.Destination.
- For example, a
- When injected into an active conflict or quorum vote election, peer nodes execute
ValidateStagedBlock(candidate, parentBalance). - Because
ValidateStagedBlockomits these checks, the malformed block passes validation and is accepted intostagedStoreviaPutStagedBlockand promoted viaconfirmConflict/swapBlockLocked. - When
swapBlockLockedcallscommitBlockWrite, the block is permanently appended to the canonical chain. - In downstream P2P sync and ledger verification:
- Nodes syncing the block through standard ingestion pipelines (
validateAndAddMintorvalidateAndAddBurn) reject the block due tob.Destination != ""orb.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!
- Nodes syncing the block through standard ingestion pipelines (
Impact
- 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.
- Protocol Smuggling & Storage Bloat:
Attackers can smuggle arbitrary metadata into
BlockMintand oversized unvalidated memos intoBlockBurnpast 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
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.