Staged Block Validation Bypass: ValidateStagedBlock omits asset matching, destination validation, and memo validation on BlockReceive and BlockSend
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:
- In
validateAndAddReceive(core/ledger.go:1107-1114):
AndpendingAsset := 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) }ValidateMemo(b.Memo)is enforced during block verification/parsing (core/encoding.go:79). - 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 BlockReceivecomparesb.Source,pending.Destination,isLiveLeaseEscrow, and updatesb.Balancebased onpending.Amount. However, it never comparesb.Assetwithpending.Asset!core/ledger.go:2740-2751:case BlockSendomits memo validationValidateMemo(b.Memo).
Attack & Failure Scenario
- 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
BlockReceivewithb.Asset = "XUSD", referencing Bob's pending send hashb.Source. - In a quorum election on Alice's account, representative nodes execute
ValidateStagedBlock(candidate, parentBalance). ValidateStagedBlockcheckspending.Amount == 1000, adds it toparentBalance, and verifiesb.Balance. It never verifies thatb.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!
- Alice has a pending send of 1,000 XE from Bob (
- 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,
validateAndAddReceivethrows 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!
- Nodes performing standard block synchronization (
Impact
- 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.
- Consensus Desynchronization / Chain Partition:
Discrepancies between
ValidateStagedBlockandvalidateAndAddReceiveallow invalid cross-asset blocks into the staged/canonical state, causing follower nodes to permanently diverge from representative nodes.
Remediation
- In
core/ledger.go, updateValidateStagedBlockforBlockReceiveto 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) } - For
BlockSend, ensure memo validation is enforced:case BlockSend: ... if err := ValidateMemo(b.Memo); err != nil { return fmt.Errorf("staged send: %w", err) }
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-9701 and says what differs; it is read like any other.