Bounty
XE-9646 · Bounty

Staged Block Validation Bypass: ValidateStagedBlock omits MSKeyset validation on BlockMultisigUpdate allowing malformed keyset promotion

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

Report

Vulnerability Summary

In core/ledger.go:2732-2870, ValidateStagedBlock(b *Block, parentBalance uint64) error is called by the consensus engine (core/quorum.go:309) before promoting a staged BFT quorum winner block to the canonical chain.

While normal ingestion in validateAndAddMultisigUpdate(b *Block) (core/ledger.go:1308-1353) enforces rigorous checks on keyset integrity:

  1. if b.MSKeyset == nil { return fmt.Errorf("multisig_update must include a keyset") }
  2. if err := ValidateKeyset(b.MSKeyset); err != nil { return fmt.Errorf("multisig_update keyset: %w", err) }
  3. oldKs := l.getKeysetOverlay(b.Account); if oldKs == nil { return fmt.Errorf("multisig_update: account is not multisig") }

In sharp contrast, ValidateStagedBlock handles BlockMultisigUpdate with only a balance check (core/ledger.go:2835-2838):

	case BlockMultisigUpdate:
		if b.Balance != parentBalance {
			return fmt.Errorf("staged multisig_update: balance mismatch: expected %d, got %d", parentBalance, b.Balance)
		}

It completely omits:

  • Checking if b.MSKeyset == nil.
  • Validating the keyset structure via ValidateKeyset(b.MSKeyset) (threshold $\le$ total keys, duplicate public keys, threshold $> 0$, valid Ed25519 hex encodings).
  • Checking whether the account is actually an existing multisig account (l.getKeysetOverlay(b.Account) != nil).

Vulnerable Code Locations

In core/ledger.go:2835-2838:

	case BlockMultisigUpdate:
		if b.Balance != parentBalance {
			return fmt.Errorf("staged multisig_update: balance mismatch: expected %d, got %d", parentBalance, b.Balance)
		}
        // MISSING: check that b.MSKeyset != nil
        // MISSING: ValidateKeyset(b.MSKeyset)
        // MISSING: check that account is already multisig

Compare with core/ledger.go:1308-1320 (validateAndAddMultisigUpdate):

func (l *Ledger) validateAndAddMultisigUpdate(b *Block) error {
	if b.MSKeyset == nil {
		return fmt.Errorf("multisig_update must include a keyset")
	}
	if err := ValidateKeyset(b.MSKeyset); err != nil {
		return fmt.Errorf("multisig_update keyset: %w", err)
	}

	oldKs := l.getKeysetOverlay(b.Account)
	if oldKs == nil {
		return fmt.Errorf("multisig_update: account is not multisig")
	}
    ...

Attack & Failure Scenario

  1. A conflict arises on a multisig account, or an attacker creates a conflict between a legitimate multisig transaction and a competing BlockMultisigUpdate.
  2. The competing block contains an invalid or nil MSKeyset (for instance, Threshold: 0, empty keys list, duplicate keys, or MSKeyset: nil).
  3. If quorum votes converge on this competing candidate or during conflict resolution, confirmConflict invokes:
    if err := qm.ledger.ValidateStagedBlock(winnerBlock, parentBalance); err != nil {
        ...
    }
    
  4. ValidateStagedBlock only verifies b.Balance == parentBalance. Since balance is unchanged, ValidateStagedBlock returns nil (PASS)!
  5. confirmConflict proceeds to call swapBlockLocked:
    • It unrolls prior blocks and invokes prepareBlockWrite(newBlock).
    • In prepareBlockWrite: commit.PutKeyset = b.MSKeyset l.setKeyset(b.Account, b.MSKeyset)
    • The malformed or nil MSKeyset is committed to storage and written to the active ledger in-memory keyset cache!
  6. If b.MSKeyset was nil or had threshold 0, any subsequent transaction on this account attempting signature verification crashes with nil pointer dereference or permanently freezes all funds because VerifyMultisigAny cannot satisfy an invalid threshold.

Impact

  1. Permanent Account Hijacking / Fund Freezing via Malformed Staged Winners: A winning quorum block containing an unvalidated BlockMultisigUpdate can set an unspendable keyset (threshold 0 or empty keys), permanently locking all funds in the multisig treasury.
  2. Crash & State Corruption: If b.MSKeyset == nil, later operations calling l.GetKeyset(b.Account).Keys panic with nil pointer dereference, causing local and peer validator nodes to crash on block execution.
  3. Consensus Invariant Breakage: Different validation rules between live ingestion (validateAndAddMultisigUpdate) and consensus resolution (ValidateStagedBlock) allow blocks that would fail ingestion to be promoted through conflict resolution.

Remediation

In ValidateStagedBlock in core/ledger.go, update case BlockMultisigUpdate:

	case BlockMultisigUpdate:
		if b.Balance != parentBalance {
			return fmt.Errorf("staged multisig_update: balance mismatch: expected %d, got %d", parentBalance, b.Balance)
		}
		if b.MSKeyset == nil {
			return fmt.Errorf("staged multisig_update: missing keyset")
		}
		if err := ValidateKeyset(b.MSKeyset); err != nil {
			return fmt.Errorf("staged multisig_update: invalid keyset: %w", err)
		}
		if l.getKeysetOverlay(b.Account) == nil {
			return fmt.Errorf("staged multisig_update: account is not multisig")
		}

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