Cascade Rollback Asymmetry: SwapBlock and planRollbackFrom omit BlockLease cascade unwinding
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:
- 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.
- 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
core/rollback.go:68-73:planRollbackFromrejects descendantBlockLeaseblocks with an error rather than planning the unwinding of the created lease.core/rollback.go:25-35:planRollbackOfSendonly unwinds standardBlockSenddestination accounts; there is no equivalentplanRollbackOfLeaseto unwind provider accounts that processedBlockLeaseAccept.core/ledger.go:2942-2949:SwapBlockonly checksif oldBlock.Type == BlockSendto triggerplanCascade. If a conflicting block replacesBlockLease, the provider's accepted state is not unwound.
Attack & Failure Scenario
Scenario 1: Reorg Deadlock on Account Creating Leases
- Alice receives 1,000 XUSD from Bob via
BlockReceive(source = Bob'sBlockSend). - Alice subsequently creates a lease
BlockLeaselocking 500 XUSD for compute work with Provider Charlie. - A network conflict occurs on Bob's account: a competing winner block replaces Bob's
BlockSend. - The consensus engine initiates a cascade rollback to unwind Alice's receipt of Bob's send.
- In
planRollbackFrom, as it traverses Alice's blocks from frontier back to the receive index, it encounters Alice'sBlockLease. planRollbackFromexecutes:default: return fmt.Errorf("cascade: unsupported block type %q (%s) on %s...", b.Type, shortHash(b.Hash), shortAddr(account))- 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
- Alice creates
BlockLease(Hash $L$). - Charlie observes $L$ in pending state and publishes
BlockLeaseAccept(referencing $L$). - A fork occurs on Alice's account, and quorum resolves in favor of a competing block replacing $L$.
SwapBlockreplaces Alice'sBlockLease$L$.- Because
SwapBlockdoes not cascade to the lease provider (Charlie), Charlie'sBlockLeaseAcceptremains on Charlie's chain referencing $L$. - 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
- 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 abortsSwapBlock, locking validator nodes in permanent conflict deadlock. - State Inconsistency Across Chains:
Replacing an unfinalized
BlockLeaseleaves provider chains in an invalid, un-settleable orphan state with locked stake that can never be returned or settled.
Remediation
- Implement
planRollbackOfLease(leaseHash string, planned map[string]bool, plan *[]cascadeStep)that inspects whether a provider has accepted the lease viaBlockLeaseAccept, and cascades rollback on the provider's account. - Support
BlockLeaseinplanRollbackFrom:
and ifcase BlockSend, BlockReceive, BlockBurn, BlockMint, BlockLease:b.Type == BlockLease, triggerplanRollbackOfLease(b.Hash, planned, plan). - 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
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.