{"id":"XE-10255","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Consensus State Inconsistency: confirmConflict demotes mainBlock to staged store before swapBlockLocked succeeds creating duplicate phantom staged blocks","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":"invalid","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"invalid","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T11:16:07.275144+00:00","updated_at":"2026-11-20T00:48:52.070092+00:00","source_created_at":null,"told_at":"2026-11-20T00:48:52.073138+00:00","status_changed_at":"2026-11-20T00:33:25.496942+00:00","url":"https://bounty.xe.network/XE-10255","body":"## Vulnerability Summary\n\nIn `core/quorum.go:320-340`, `confirmConflict` promotes a BFT quorum winner block by swapping out the demoted block (`mainBlock`):\n\n```go\n\t\t\tfor _, loserHash := range result.LoserHashes {\n\t\t\t\tif _, lerr := qm.ledger.GetBlockHeight(result.ConflictAccount, loserHash); lerr != nil {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tmainBlock := qm.ledger.GetBlock(loserHash)\n\t\t\t\tif mainBlock != nil {\n\t\t\t\t\t// Persist demoted block into staged store before swapping\n\t\t\t\t\tif err := qm.conflictMgr.SaveStagedBlock(mainBlock); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"confirmConflict: SaveStagedBlock (demoted): %w\", err)\n\t\t\t\t\t}\n\t\t\t\t\tif err := qm.ledger.swapBlockLocked(result.ConflictAccount, loserHash, result.WinnerHash, winnerBlock); err != nil {\n\t\t\t\t\t\tif errors.Is(err, ErrWinnerFullValidation) && !IsRetryableError(err) {\n\t\t\t\t\t\t\tqm.failedPromotions[failedPromotionKey(result.ConflictAccount, result.ConflictPrev, result.WinnerHash)] = Now()\n...\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn fmt.Errorf(\"confirmConflict: SwapBlock: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t\tswapped = true\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n```\n\nCritical ordering flaw:\n1. Non-Atomic Staging: `qm.conflictMgr.SaveStagedBlock(mainBlock)` writes `mainBlock` directly to the persistent staged store (`prefixStaged` in BadgerDB) *before* `swapBlockLocked` executes.\n2. Failure Mid-Operation: If `swapBlockLocked` fails (e.g. due to downstream validation errors, transient storage errors, or deterministic `ErrWinnerFullValidation`), the function aborts and returns an error.\n3. Invariant Breach: `mainBlock` was NOT removed from the active account chain in `ledger`, yet it now simultaneously exists in the staged block store.\n4. Duplicate Entity Corruption: If the node subsequently runs `GetBlockOrStaged(loserHash)`, or if subsequent conflict evaluation routines query the staged store, `mainBlock` appears in both committed and uncommitted states, corrupting conflict history and preventing clean re-arbitration.\n\n## Proposed Remediation\n\nPerform the staged demotion atomically within `swapBlockLocked` or revert the staged save on swap failure:\n```go\n\t\t\t\t\tif err := qm.ledger.swapBlockLocked(result.ConflictAccount, loserHash, result.WinnerHash, winnerBlock); err != nil {\n\t\t\t\t\t\t// Ensure mainBlock is not left orphaned in staged store\n\t\t\t\t\t\t_ = qm.conflictMgr.DeleteStagedBlock(loserHash)\n\t\t\t\t\t\treturn fmt.Errorf(\"confirmConflict: SwapBlock: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t\tif err := qm.conflictMgr.SaveStagedBlock(mainBlock); err != nil {\n\t\t\t\t\t\treturn fmt.Errorf(\"confirmConflict: SaveStagedBlock: %w\", err)\n\t\t\t\t\t}\n```","patch_refs":[],"thread":[{"id":13346,"source":"desk","source_ref":"reply:11368","author":"XE desk","team":true,"body":"Thanks for the report. We read it against the code and could not confirm a bug in what it describes.\n\nThis report is closed as invalid. If we have missed something, file a new report that links\nhttps://bounty.xe.network/XE-10255 and says what; it is read like any other.","created_at":"2026-11-20T00:48:52.070092+00:00"}]}