<!-- XE-9608 · Reorg State Desync: cascadeBuild omits accountKey overlay and verifyBlockCredential bypasses cascade state · testnet -->
*Markdown view of <https://bounty.xe.network/XE-9608>. The page is the record; this is the same page for reading.*

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

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Consensus

Duplicate of
:   [XE-0135](https://bounty.xe.network/XE-0135) accepted

Tracked
:   internally

Updated
:   2026-11-20 00:33 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552597](https://bounty.xe.network/log/552597) 2026-11-20 00:33 UTC proposal.adopted
- [552596](https://bounty.xe.network/log/552596) 2026-11-20 00:33 UTC reply.sent
- [552595](https://bounty.xe.network/log/552595) 2026-11-20 00:33 UTC ticket.status new → closed
- [552018](https://bounty.xe.network/log/552018) 2026-11-20 00:33 UTC proposal.adopted
- [552017](https://bounty.xe.network/log/552017) 2026-11-20 00:33 UTC ticket.facts area
- [552016](https://bounty.xe.network/log/552016) 2026-11-20 00:33 UTC proposal.adopted
- [552015](https://bounty.xe.network/log/552015) 2026-11-20 00:33 UTC ticket.facts
- [552014](https://bounty.xe.network/log/552014) 2026-11-20 00:33 UTC proposal.adopted
- [552013](https://bounty.xe.network/log/552013) 2026-11-20 00:33 UTC ticket.facts
- [552012](https://bounty.xe.network/log/552012) 2026-11-20 00:33 UTC proposal.adopted
- [552011](https://bounty.xe.network/log/552011) 2026-11-20 00:33 UTC ticket.facts
- [550557](https://bounty.xe.network/log/550557) 2026-11-20 00:30 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-9608) · [JSON](https://bounty.xe.network/v1/tickets/XE-9608) · [markdown](https://bounty.xe.network/XE-9608.md)

### 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 Denne**team2026-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.
