{"id":"XE-9526","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Consensus State Corruption: confirmConflict premature finalization and conflict purge when winner block body is missing","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T05:27:16.727018+00:00","updated_at":"2026-11-20T00:33:22.099344+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:22.132178+00:00","status_changed_at":"2026-11-20T00:33:22.106330+00:00","url":"https://bounty.xe.network/XE-9526","body":"## Vulnerability Summary\n\nIn `core/quorum.go:268-375`, `confirmConflict(result *quorumResult)` is responsible for promoting and finalizing a BFT quorum winner block while demoting loser candidates.\n\nWhen retrieving the winner block from the staged block store:\n\n```go\n\twinnerBlock, err := qm.conflictMgr.GetStagedBlock(result.WinnerHash)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"confirmConflict: GetStagedBlock: %w\", err)\n\t}\n\n\tif winnerBlock != nil {\n\t\tif _, onChain := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash); onChain != nil {\n            // Validation, swap, or append logic\n            ...\n        }\n    }\n\n\tif height, herr := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash); herr == nil {\n\t\tif cur, _ := qm.store.GetFinalHeight(result.ConflictAccount); height > cur {\n\t\t\tif err := qm.store.SetFinalHeight(result.ConflictAccount, height); err != nil {\n\t\t\t\treturn fmt.Errorf(\"confirmConflict: SetFinalHeight: %w\", err)\n\t\t\t}\n\t\t\tqm.ledger.recordFinalityAdvance()\n\t\t\tobserveFinalityAdvance(height-cur, qm.ledger.GetBlockOrStaged(result.WinnerHash))\n\t\t}\n\t}\n\n\tif err := qm.finalizeBlock(result.WinnerHash); err != nil {\n\t\treturn err\n\t}\n\n\tqm.cleanupResolvedConflict(result)\n\treturn nil\n```\n\nConsider 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`):\n\n1. The entire `if winnerBlock != nil` block is skipped. Neither `swapBlockLocked` nor `appendStagedWinner` is ever called.\n2. `GetBlockHeight` returns an error (`herr != nil`), so `SetFinalHeight` is skipped.\n3. Execution proceeds directly to `qm.finalizeBlock(result.WinnerHash)`, calling `qm.store.SetBlockStatus(result.WinnerHash, StatusFinalized)`. The node permanently marks a **completely missing block** as `StatusFinalized`!\n4. Execution calls `qm.cleanupResolvedConflict(result)`:\n   - `qm.rejectBlocks(result.LoserHashes)` marks the current on-chain block as `StatusRejected`.\n   - `RemoveConflict` permanently deletes the conflict metadata from storage.\n   - `DeleteVotesForConflict` deletes all voting records.\n\nThe 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.\n\n---\n\n## Vulnerable Code Locations\n\nIn `core/quorum.go:280-375`:\n```go\n\twinnerBlock, err := qm.conflictMgr.GetStagedBlock(result.WinnerHash)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"confirmConflict: GetStagedBlock: %w\", err)\n\t}\n\n\tif winnerBlock != nil {\n        ...\n    }\n\n    // Execution continues even when winnerBlock == nil and WinnerHash is not on chain!\n\tif height, herr := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash); herr == nil {\n        ...\n    }\n\n\tif err := qm.finalizeBlock(result.WinnerHash); err != nil {\n\t\treturn err\n\t}\n\n\tqm.cleanupResolvedConflict(result)\n\treturn nil\n```\n\n---\n\n## Failure Scenario & Network Impact\n\n1. A conflict occurs between Block L (locally known and appended to chain) and Block W (submitted on a peer node).\n2. 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`).\n3. However, due to network latency, the local node has not yet pulled the body of Block W (`stagedBlock == nil`).\n4. `confirmConflict` fires:\n   - Since `winnerBlock == nil`, no swap occurs. Block L remains on the local account chain.\n   - `finalizeBlock(W)` marks the missing hash `W` as `StatusFinalized`.\n   - `cleanupResolvedConflict` runs: it marks Block L on the chain as `StatusRejected`, deletes all conflict records, and purges votes.\n5. Post-condition:\n   - The account chain contains a block marked `StatusRejected` at its frontier.\n   - The winning block `W` is nowhere in the chain.\n   - The conflict record has been deleted, so the conflict resolution routine will never trigger again for this position.\n   - Subsequent blocks built on Block W cannot be appended because Block W is absent from the local ledger chain.\n   - The account chain is permanently halted on the local node.\n\n---\n\n## Remediation\n\nIn `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:\n\n```go\n\twinnerBlock, err := qm.conflictMgr.GetStagedBlock(result.WinnerHash)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"confirmConflict: GetStagedBlock: %w\", err)\n\t}\n\n\t_, onChain := qm.ledger.GetBlockHeight(result.ConflictAccount, result.WinnerHash)\n\tif onChain != nil && winnerBlock == nil {\n\t\t// Winner block body is not yet available; trigger phantom block pull and defer resolution\n\t\tif qm.PhantomPullFn != nil {\n\t\t\tqm.PhantomPullFn(result.ConflictAccount, result.ConflictPrev, []string{result.WinnerHash})\n\t\t}\n\t\treturn fmt.Errorf(\"confirmConflict: winner block body %s not yet available: deferring finalization\", shortHash(result.WinnerHash))\n\t}\n```\n\nThis 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.","patch_refs":[],"thread":[{"id":13279,"source":"desk","source_ref":"reply:11301","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-9526 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:22.099344+00:00"}]}