<!-- XE-9639 · Cascade Rollback Asymmetry: SwapBlock and planRollbackFrom omit BlockLease cascade unwinding · testnet -->
*Markdown view of <https://bounty.xe.network/XE-9639>. The page is the record; this is the same page for reading.*

XE-9639 · Bounty

# Cascade Rollback Asymmetry: SwapBlock and planRollbackFrom omit BlockLease cascade unwinding

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

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Consensus

Duplicate of
:   [XE-0022](https://bounty.xe.network/XE-0022) patched

Tracked
:   internally

Updated
:   2026-11-20 00:33 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552769](https://bounty.xe.network/log/552769) 2026-11-20 00:33 UTC proposal.adopted
- [552768](https://bounty.xe.network/log/552768) 2026-11-20 00:33 UTC reply.sent
- [552767](https://bounty.xe.network/log/552767) 2026-11-20 00:33 UTC ticket.status new → closed
- [552214](https://bounty.xe.network/log/552214) 2026-11-20 00:33 UTC proposal.adopted
- [552213](https://bounty.xe.network/log/552213) 2026-11-20 00:33 UTC ticket.facts area
- [552212](https://bounty.xe.network/log/552212) 2026-11-20 00:33 UTC proposal.adopted
- [552211](https://bounty.xe.network/log/552211) 2026-11-20 00:33 UTC ticket.facts
- [552210](https://bounty.xe.network/log/552210) 2026-11-20 00:33 UTC proposal.adopted
- [552209](https://bounty.xe.network/log/552209) 2026-11-20 00:33 UTC ticket.facts
- [552208](https://bounty.xe.network/log/552208) 2026-11-20 00:33 UTC proposal.adopted
- [552207](https://bounty.xe.network/log/552207) 2026-11-20 00:33 UTC ticket.facts
- [550576](https://bounty.xe.network/log/550576) 2026-11-20 00:30 UTC note.added

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

### Report

## Vulnerability Summary

In `core/rollback.go` and `core/ledger.go`, the ledger implements descendant cascade rollback (`planCascade`, `planRollbackOfSend`, `planRollbackFrom`, and `SwapBlock`) to unwind blocks across accounts when a conflict winner replaces a prior block.

While `buildBlockUndo` (`core/rollback.go:220-243`) implements undo logic for lease-related block types (`BlockLease`, `BlockLeaseAccept`, `BlockLeaseSettle`, `BlockLeaseCancel`, `BlockLeaseRenew`), the cascade planner functions `planRollbackFrom` and `SwapBlock` **completely omit `BlockLease` from cascade expansion and unwinding**:

1. In `core/rollback.go:68-73` (`planRollbackFrom`):

```
		switch b.Type {
		case BlockSend, BlockReceive, BlockBurn, BlockMint:

		default:
			return fmt.Errorf("cascade: unsupported block type %q (%s) on %s — reversing its lease/keyset/reputation side-effects is not yet implemented", b.Type, shortHash(b.Hash), shortAddr(account))
		}
```

If an unwound account has created a lease (`BlockLease`) after receiving funds from the contested send, the cascade plan aborts with `"unsupported block type 'lease' — reversing its lease/keyset/reputation side-effects is not yet implemented"`, completely breaking reorg finality.

2. In `core/ledger.go:2942-2949` (`SwapBlock`):

```
	if oldBlock.Type == BlockSend {
		oldPlan, perr := l.planCascade(oldBlock.Hash, planned)
		if perr != nil {
			return fmt.Errorf("SwapBlock: %w", perr)
		}
		plan = append(plan, oldPlan...)
	}

	plan = append(plan, cascadeStep{account: account, b: oldBlock})
```

When `oldBlock` is `BlockSend`, it triggers `planCascade(oldBlock.Hash)` to unwind receiver accounts that consumed the send.
However, if `oldBlock` is `BlockLease`, it only adds `oldBlock` itself to `plan`, and **never checks if any provider has already accepted the lease (`BlockLeaseAccept`)** or if escrow was consumed!
If a provider already accepted the lease on their own account chain, replacing or rolling back the consumer's `BlockLease` without unwinding the provider's `BlockLeaseAccept` leaves the provider's account chain referencing a non-existent / deleted lease hash!

---

## Vulnerable Code Locations

1. `core/rollback.go:68-73`:
   `planRollbackFrom` rejects descendant `BlockLease` blocks with an error rather than planning the unwinding of the created lease.
2. `core/rollback.go:25-35`:
   `planRollbackOfSend` only unwinds standard `BlockSend` destination accounts; there is no equivalent `planRollbackOfLease` to unwind provider accounts that processed `BlockLeaseAccept`.
3. `core/ledger.go:2942-2949`:
   `SwapBlock` only checks `if oldBlock.Type == BlockSend` to trigger `planCascade`. If a conflicting block replaces `BlockLease`, the provider's accepted state is not unwound.

---

## Attack \& Failure Scenario

### Scenario 1: Reorg Deadlock on Account Creating Leases

1. Alice receives 1,000 XUSD from Bob via `BlockReceive` (source \= Bob's `BlockSend`).
2. Alice subsequently creates a lease `BlockLease` locking 500 XUSD for compute work with Provider Charlie.
3. A network conflict occurs on Bob's account: a competing winner block replaces Bob's `BlockSend`.
4. The consensus engine initiates a cascade rollback to unwind Alice's receipt of Bob's send.
5. In `planRollbackFrom`, as it traverses Alice's blocks from frontier back to the receive index, it encounters Alice's `BlockLease`.
6. `planRollbackFrom` executes:

   ```
   default:
       return fmt.Errorf("cascade: unsupported block type %q (%s) on %s...", b.Type, shortHash(b.Hash), shortAddr(account))
   ```
7. The cascade rollback fails immediately! The entire BFT quorum resolution for Bob's account is permanently aborted, resulting in consensus deadlock and inability to promote the winner block.

### Scenario 2: Orphaned Provider State on Lease Replacement

1. Alice creates `BlockLease` (Hash $L$).
2. Charlie observes $L$ in pending state and publishes `BlockLeaseAccept` (referencing $L$).
3. A fork occurs on Alice's account, and quorum resolves in favor of a competing block replacing $L$.
4. `SwapBlock` replaces Alice's `BlockLease` $L$.
5. Because `SwapBlock` does not cascade to the lease provider (`Charlie`), Charlie's `BlockLeaseAccept` remains on Charlie's chain referencing $L$.
6. Charlie's account is permanently corrupted: $L$ no longer exists in Alice's chain or ledger storage, but Charlie's balance reflects locked stake and future settlement blocks will fail with `lease not found`.

---

## Impact

1. **Denial of Service / Consensus Quorum Freeze**:
   Any conflict on an upstream send cannot be resolved if a downstream recipient engaged in compute leasing (`BlockLease`). The error aborts `SwapBlock`, locking validator nodes in permanent conflict deadlock.
2. **State Inconsistency Across Chains**:
   Replacing an unfinalized `BlockLease` leaves provider chains in an invalid, un-settleable orphan state with locked stake that can never be returned or settled.

---

## Remediation

1. Implement `planRollbackOfLease(leaseHash string, planned map[string]bool, plan *[]cascadeStep)` that inspects whether a provider has accepted the lease via `BlockLeaseAccept`, and cascades rollback on the provider's account.
2. Support `BlockLease` in `planRollbackFrom`:

   ```
   case BlockSend, BlockReceive, BlockBurn, BlockMint, BlockLease:
   ```

   and if `b.Type == BlockLease`, trigger `planRollbackOfLease(b.Hash, planned, plan)`.
3. In `SwapBlock` (`core/ledger.go`):

   ```
   if oldBlock.Type == BlockSend {
       oldPlan, perr := l.planCascade(oldBlock.Hash, planned)
       ...
   } else if oldBlock.Type == BlockLease {
       oldPlan, perr := l.planCascadeLease(oldBlock.Hash, planned)
       ...
   }
   ```

### Thread

**Joseph Denne**team2026-11-20 00:33 UTCdesk

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