Staged Block Validation Bypass: ValidateStagedBlock omits MSKeyset validation on BlockMultisigUpdate allowing malformed keyset promotion
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:
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") }
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
- A conflict arises on a multisig account, or an attacker creates a conflict between a legitimate multisig transaction and a competing
BlockMultisigUpdate. - The competing block contains an invalid or nil
MSKeyset(for instance,Threshold: 0, empty keys list, duplicate keys, orMSKeyset: nil). - If quorum votes converge on this competing candidate or during conflict resolution,
confirmConflictinvokes:if err := qm.ledger.ValidateStagedBlock(winnerBlock, parentBalance); err != nil { ... } ValidateStagedBlockonly verifiesb.Balance == parentBalance. Since balance is unchanged,ValidateStagedBlockreturnsnil(PASS)!confirmConflictproceeds to callswapBlockLocked:- It unrolls prior blocks and invokes
prepareBlockWrite(newBlock). - In
prepareBlockWrite:commit.PutKeyset = b.MSKeysetl.setKeyset(b.Account, b.MSKeyset) - The malformed or nil
MSKeysetis committed to storage and written to the active ledger in-memory keyset cache!
- It unrolls prior blocks and invokes
- If
b.MSKeysetwas nil or had threshold 0, any subsequent transaction on this account attempting signature verification crashes with nil pointer dereference or permanently freezes all funds becauseVerifyMultisigAnycannot satisfy an invalid threshold.
Impact
- Permanent Account Hijacking / Fund Freezing via Malformed Staged Winners:
A winning quorum block containing an unvalidated
BlockMultisigUpdatecan set an unspendable keyset (threshold 0 or empty keys), permanently locking all funds in the multisig treasury. - Crash & State Corruption:
If
b.MSKeyset == nil, later operations callingl.GetKeyset(b.Account).Keyspanic with nil pointer dereference, causing local and peer validator nodes to crash on block execution. - 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
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.