Bounty
XE-9772 · Bounty

Staged Block Validation Bypass: ValidateStagedBlock omits consumer authorization, lease state check, and asset verification on BlockLeaseCancel

Closed · duplicate — web filed 2026-11-12 07:02 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 staging or promotion to the canonical ledger.

When BlockLeaseCancel is ingested normally through validateAndAddLeaseCancel (core/ledger.go:1792-1877), the node strictly verifies:

  1. b.Asset == "XUSD" (core/ledger.go:1793-1795).
  2. leaseBlock.Account == b.Account ensuring only the original consumer can cancel their own lease (core/ledger.go:1809-1811).
  3. existing.State == LeaseCreated (or LeaseAccepted with resolve winner), explicitly forbidding cancelling settled, expired, or force-settled leases:
    if existing != nil && existing.State != LeaseCreated {
        return fmt.Errorf("cannot cancel lease in %s state", existing.State)
    }
    
  4. pending.Asset == "XUSD" matching the returned escrow balance.

However, in ValidateStagedBlock (core/ledger.go:2809-2820):

	case BlockLeaseCancel:
		pending, err := l.store.GetPendingSend(b.Source)
		if err != nil {
			return fmt.Errorf("staged lease_cancel: GetPendingSend: %w", err)
		}
		if pending == nil {
			return fmt.Errorf("staged lease_cancel: no pending send for lease")
		}
		expectedBal := parentBalance + pending.Amount
		if b.Balance != expectedBal {
			return fmt.Errorf("staged lease_cancel: balance mismatch: expected %d, got %d", expectedBal, b.Balance)
		}

Notice the critical omissions in ValidateStagedBlock for BlockLeaseCancel:

  1. Never checks b.Asset == "XUSD": It allows arbitrary asset tags (e.g. minting XE or cross-asset balance manipulation).
  2. Never checks consumer authorization (leaseBlock.Account == b.Account): Any third-party attacker account can stage a BlockLeaseCancel referencing another user's lease escrow (b.Source) and steal the escrow amount into their own balance!
  3. Never inspects lease state (l.store.GetLease): An active, settled, or force-settled lease escrow can be cancelled and double-refunded during staged conflict resolution!

Vulnerable Code Locations

  • core/ledger.go:2809-2820: ValidateStagedBlock for BlockLeaseCancel checks only that l.store.GetPendingSend(b.Source) exists and matches b.Balance == parentBalance + pending.Amount. It omits consumer ownership verification, lease state verification, and asset matching.

Attack & Failure Scenario

  1. Third-Party Escrow Theft / Unauthorized Refund:
    • Alice creates a lease escrow of 10,000 XUSD (b.Source).
    • Attacker Bob (competing in an open or contested block election on his account) creates a staged BlockLeaseCancel candidate referencing Alice's escrow hash b.Source.
    • When Bob's candidate is validated via ValidateStagedBlock(candidate, parentBalance), the node checks:
      • pending != nil (Alice's escrow exists in store).
      • b.Balance == parentBalance + 10,000.
    • Because ValidateStagedBlock does not check leaseBlock.Account == b.Account, Bob's block passes validation!
    • If Bob's block is promoted via quorum, Bob receives Alice's 10,000 XUSD escrow refund directly into his balance.
  2. Permanent Consensus Split / BFT Fork:
    • Nodes ingesting the promoted block via standard peer sync (validateAndAddLeaseCancel) check leaseBlock.Account == b.Account.
    • Syncing nodes reject the block with lease_cancel: only the consumer can cancel a lease.
    • The network fractures into a permanent consensus fork between quorum-staging nodes and standard synchronization nodes.

Impact

  1. Unauthorized Escrow Theft: Any network account can hijack and refund third-party lease escrows to their own account during staged conflict elections.
  2. Permanent Consensus Partition: Discrepancy between live block ingestion and staged block validation allows blocks violating protocol ownership to enter the ledger, causing follower nodes to permanently desynchronize.

Remediation

In core/ledger.go, update case BlockLeaseCancel in ValidateStagedBlock to verify asset type, source lease ownership, and lease state:

	case BlockLeaseCancel:
		if b.Asset != "XUSD" {
			return fmt.Errorf("staged lease_cancel: asset must be XUSD")
		}
		leaseBlock, err := l.store.GetBlock(b.Source)
		if err != nil || leaseBlock == nil {
			return fmt.Errorf("staged lease_cancel: source lease block not found")
		}
		if leaseBlock.Type != BlockLease {
			return fmt.Errorf("staged lease_cancel: source block is not a lease block")
		}
		if leaseBlock.Account != b.Account {
			return fmt.Errorf("staged lease_cancel: only consumer can cancel lease")
		}
		if existing, ok, err := l.getLeaseOverlay(b.Source); ok && existing != nil {
			if existing.State != LeaseCreated && existing.State != LeaseAccepted {
				return fmt.Errorf("staged lease_cancel: cannot cancel lease in %s state", existing.State)
			}
		}
		pending, err := l.store.GetPendingSend(b.Source)
		if err != nil || pending == nil {
			return fmt.Errorf("staged lease_cancel: no pending send for lease")
		}
		expectedBal := parentBalance + pending.Amount
		if b.Balance != expectedBal {
			return fmt.Errorf("staged lease_cancel: balance mismatch: expected %d, got %d", expectedBal, b.Balance)
		}

Thread

Joseph Denneteam2026-11-20 00:33 UTCdesk

Thanks. This is the same finding as https://bounty.xe.network/XE-0028, 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-9772 and says what differs; it is read like any other.