Bounty
XE-9608 · Bounty

Reorg State Desync: cascadeBuild omits accountKey overlay and verifyBlockCredential bypasses cascade state

Closed · duplicate — web filed 2026-11-12 05:54 UTC by xe:e4cd6974

Report

Vulnerability Summary

In core/rollback.go:297-333, when unwinding blocks during a chain reorganization / cascade rollback, the ledger tracks DeleteAccountKeyAccount:

	deleteAccountKeyAccount := ""
	if b.PubKey != "" {
		deleteAccountKeyAccount = b.Account
	}
...
	undo := &BlockUndo{
		...
		DeleteAccountKeyAccount: deleteAccountKeyAccount,
	}
...
	apply := func() {
		...
		if deleteAccountKeyAccount != "" {
			l.accountKeyMu.Lock()
			delete(l.accountKeys, deleteAccountKeyAccount)
			l.accountKeyMu.Unlock()
		}
	}

However, in core/cascade_commit.go, cascadeBuild completely omits support for DeleteAccountKeyAccount and account key tracking:

  1. cascadeBuild tracks chains, addPending, delPending, restoreLease, deleteLease, deleteKeyset, and delegation, but has zero fields for account keys (deleteAccountKey map[string]bool or accountKeys map[string]string).
  2. In addUndo(undo *BlockUndo, apply func()):
    • It records cb.deleteKeyset[undo.DeleteKeysetAccount] = true for keysets.
    • But it completely ignores undo.DeleteAccountKeyAccount!
  3. core/cascade_commit.go defines getKeysetOverlay, getLeaseOverlay, getPendingSendOverlay, and getAccountChainOverlay, but does not provide any getAccountKeyOverlay.
  4. In core/ledger.go:1416-1465, verifyBlockCredential(b *Block) verifies block signatures:
    • For multisig accounts, it calls l.GetKeyset(b.Account) directly instead of l.getKeysetOverlay(b.Account).
    • For standard accounts, when b.Previous != "0", it calls l.GetAccountKey(b.Account) directly, which queries l.accountKeys[account] and disk l.store.GetAccountChain(account), completely bypassing the active cascade overlay.

Vulnerable Code Locations

  1. core/cascade_commit.go:7-26: cascadeBuild struct definition omits deleteAccountKey map[string]bool.
  2. core/cascade_commit.go:42-73: addUndo fails to record undo.DeleteAccountKeyAccount into cb.
  3. core/cascade_commit.go:143-150: No getAccountKeyOverlay function is provided; getKeysetOverlay is implemented but unused in credential verification.
  4. core/ledger.go:1447-1460:
    if l.GetKeyset(b.Account) != nil { // BUG: does not use getKeysetOverlay(b.Account)
        return fmt.Errorf("multisig account requires signatures")
    }
    ...
    pubKey = l.GetAccountKey(b.Account) // BUG: does not check overlay chain or cascadeBuild deleted keys
    

Attack & Failure Scenario

Consider a scenario where an account's open block (which declared b.PubKey) is being rolled back in a cascade, or a competing winner block arrives that replaces an open block:

Case 1: Staged Block Validation During Cascade

  1. An open block is scheduled for rollback in an active cascade build (l.activeCascade).
  2. While the cascade build is active, ValidateStagedBlock is called on a candidate winner block.
  3. ValidateStagedBlock invokes verifyBlockCredential(b).
  4. Because verifyBlockCredential checks l.GetKeyset(b.Account) and l.GetAccountKey(b.Account) without inspecting l.activeCascade:
    • If an account was previously a multisig account whose multisig_open block is rolled back in the cascade, l.GetKeyset(b.Account) still returns the old in-memory keyset (since deleteKeyset in overlay is ignored by verifyBlockCredential).
    • Standard single-key candidate blocks for this account are falsely rejected with "multisig account requires signatures".
    • Conversely, if an account key should have been deleted or restored, GetAccountKey queries the disk chain which still holds the unrolled-back blocks, reading stale keys.

Case 2: Memory Leak and State Desynchronization on Cascade Abort

  1. During cascade construction, multiple undos are registered.
  2. If DeleteAccountKeyAccount is executed upon final application, but intermediate validation fails or crashes before commit, accountKeys in memory is inconsistent with disk state.
  3. More critically, while activeCascade is active, any concurrent read or validation seeing the intermediate state sees stale keysets and public keys.

Impact

  1. False Validation Failures of Quorum Winner Blocks: When resolving conflicts that involve rolled-back open blocks or multisig conversions, ValidateStagedBlock fails with "multisig account requires signatures" or signature verification errors, preventing legitimate BFT quorum winners from being promoted.
  2. Consensus Deadlock: Nodes attempting to promote a cascade-winner block reject valid winner blocks due to stale credential cache lookups, causing nodes to fork or halt progress on affected accounts.

Remediation

  1. Add deleteAccountKey map[string]bool to cascadeBuild in core/cascade_commit.go.
  2. In addUndo, record:
    if undo.DeleteAccountKeyAccount != "" {
        cb.deleteAccountKey[undo.DeleteAccountKeyAccount] = true
    }
    
  3. Implement getAccountKeyOverlay(account string) string:
    func (l *Ledger) getAccountKeyOverlay(account string) string {
        cb := l.activeCascadeFor()
        if cb != nil && cb.deleteAccountKey[account] {
            return ""
        }
        if ch, ok := l.overlayChain(account); ok {
            for _, b := range ch.Blocks {
                if b.PubKey != "" {
                    return b.PubKey
                }
            }
            return ""
        }
        return l.GetAccountKey(account)
    }
    
  4. In verifyBlockCredential(b *Block):
    • Use l.getKeysetOverlay(b.Account) instead of l.GetKeyset(b.Account).
    • Use l.getAccountKeyOverlay(b.Account) instead of l.GetAccountKey(b.Account).

Thread

Joseph Denneteam2026-11-20 00:33 UTCdesk

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