Consensus State Corruption: confirmConflict premature finalization and conflict purge when winner block body is missing
Report
Vulnerability Summary
In core/quorum.go:268-375, confirmConflict(result *quorumResult) is responsible for promoting and finalizing a BFT quorum winner block while demoting loser candidates.
When retrieving the winner block from the staged block store:
winnerBlock, err := qm.conflictMgr.GetStagedBlock(result.WinnerHash)
if err != nil {
return fmt.Errorf("confirmConflict: GetStagedBlock: %w", err)
}
if winnerBlock != nil {
if _, onChain := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash); onChain != nil {
// Validation, swap, or append logic
...
}
}
if height, herr := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash); herr == nil {
if cur, _ := qm.store.GetFinalHeight(result.ConflictAccount); height > cur {
if err := qm.store.SetFinalHeight(result.ConflictAccount, height); err != nil {
return fmt.Errorf("confirmConflict: SetFinalHeight: %w", err)
}
qm.ledger.recordFinalityAdvance()
observeFinalityAdvance(height-cur, qm.ledger.GetBlockOrStaged(result.WinnerHash))
}
}
if err := qm.finalizeBlock(result.WinnerHash); err != nil {
return err
}
qm.cleanupResolvedConflict(result)
return nil
Consider the case where the local node received quorum votes that converged on result.WinnerHash, but the node does not yet have the winner block body in stagedStore (winnerBlock == nil), nor is it on-chain (herr != nil):
- The entire
if winnerBlock != nilblock is skipped. NeitherswapBlockLockednorappendStagedWinneris ever called. GetBlockHeightreturns an error (herr != nil), soSetFinalHeightis skipped.- Execution proceeds directly to
qm.finalizeBlock(result.WinnerHash), callingqm.store.SetBlockStatus(result.WinnerHash, StatusFinalized). The node permanently marks a completely missing block asStatusFinalized! - Execution calls
qm.cleanupResolvedConflict(result):qm.rejectBlocks(result.LoserHashes)marks the current on-chain block asStatusRejected.RemoveConflictpermanently deletes the conflict metadata from storage.DeleteVotesForConflictdeletes all voting records.
The result is critical consensus state corruption: the local node deletes the conflict record and marks the on-chain block as rejected, while the winning block was never downloaded, never validated, and never inserted into the account chain.
Vulnerable Code Locations
In core/quorum.go:280-375:
winnerBlock, err := qm.conflictMgr.GetStagedBlock(result.WinnerHash)
if err != nil {
return fmt.Errorf("confirmConflict: GetStagedBlock: %w", err)
}
if winnerBlock != nil {
...
}
// Execution continues even when winnerBlock == nil and WinnerHash is not on chain!
if height, herr := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash); herr == nil {
...
}
if err := qm.finalizeBlock(result.WinnerHash); err != nil {
return err
}
qm.cleanupResolvedConflict(result)
return nil
Failure Scenario & Network Impact
- A conflict occurs between Block L (locally known and appended to chain) and Block W (submitted on a peer node).
- Network representatives vote for Block W. The local node receives quorum votes via GossipSub and converges on Block W as the BFT winner (
result.WinnerHash = W). - However, due to network latency, the local node has not yet pulled the body of Block W (
stagedBlock == nil). confirmConflictfires:- Since
winnerBlock == nil, no swap occurs. Block L remains on the local account chain. finalizeBlock(W)marks the missing hashWasStatusFinalized.cleanupResolvedConflictruns: it marks Block L on the chain asStatusRejected, deletes all conflict records, and purges votes.
- Since
- Post-condition:
- The account chain contains a block marked
StatusRejectedat its frontier. - The winning block
Wis nowhere in the chain. - The conflict record has been deleted, so the conflict resolution routine will never trigger again for this position.
- Subsequent blocks built on Block W cannot be appended because Block W is absent from the local ledger chain.
- The account chain is permanently halted on the local node.
- The account chain contains a block marked
Remediation
In core/quorum.go:280-285, if the winner block is not currently in the ledger chain and its body is not yet held in the staged store, confirmConflict must defer confirmation and trigger block retrieval rather than continuing to finalize and clean up:
winnerBlock, err := qm.conflictMgr.GetStagedBlock(result.WinnerHash)
if err != nil {
return fmt.Errorf("confirmConflict: GetStagedBlock: %w", err)
}
_, onChain := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash)
if onChain != nil && winnerBlock == nil {
// Winner block body is not yet available; trigger phantom block pull and defer resolution
if qm.PhantomPullFn != nil {
qm.PhantomPullFn(result.ConflictAccount, result.ConflictPrev, []string{result.WinnerHash})
}
return fmt.Errorf("confirmConflict: winner block body %s not yet available: deferring finalization", shortHash(result.WinnerHash))
}
This prevents the premature deletion of conflict records and ensures that a missing winner block is retrieved and applied to the chain before finality is declared.
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-9526 and says what differs; it is read like any other.