{"id":"XE-1088","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"289","source_url":"https://github.com/xeprotocol/xe/issues/289","reporter_id":314,"title":"[HIGH] core: Cross-position vote candidate injection lets any positive-weight representative permanently lock FinalVoteStore on a foreign block hash and brick account finality","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":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-07T14:43:43.711711+00:00","updated_at":"2026-11-14T22:53:19.366288+00:00","source_created_at":"2026-11-07T14:42:51+00:00","told_at":"2026-11-14T22:52:57+00:00","status_changed_at":"2026-11-08T20:32:05.215677+00:00","url":"https://bounty.xe.network/XE-1088","body":"### Summary\n\n`QuorumManager.finalTally` (`core/quorum.go:120-123`) verifies that a `FINAL` vote's `BlockHash` belongs to the target conflict slot `(account, previous)` before counting its weight toward the 67% finality threshold:\n\n```go\nb := qm.ledger.GetBlockOrStaged(v.BlockHash)\nif b == nil || b.Account != account || b.Previous != previous {\n    continue\n}\n```\n\nHowever, `VoteManager` (`core/vote.go` and `core/finalization.go`) never checks that `v.BlockHash` (or any candidate hash `h` gathered for `(account, prev)`) actually belongs to `(account, prev)`. In addition, `QuorumManager.finalTally` (`core/quorum.go:112`) records `candidateSet[v.BlockHash] = true` *before* checking `b.Account != account || b.Previous != previous`.\n\nBecause of this mismatch between `VoteManager` and `QuorumManager`, any representative with positive vote weight (`> 0`, including a `1`-micro-XE self-delegated account under `RepModeOpen` or any minor representative under `RepModeAllowlist`) can broadcast a `CONVERGE` vote for a victim's unresolved position `(victimAccount, victimPrev)` whose `BlockHash` points to an already-finalized block from a different chain/position `B_foreign` with `B_foreign.Hash < B_victim.Hash` (for example, `genesis.Hash` or any low-hash block on the attacker's own chain).\n\nHonest representatives accept the cross-position vote, adopt `B_foreign.Hash` as their lowest-hash eligible candidate (`lowestHash(eligible)`), reach >=67% converge weight on `B_foreign.Hash`, and after the 3-second `lockStabilityWindow` permanently lock `(victimAccount, victimPrev) -> B_foreign.Hash` in the write-once `FinalVoteStore` (`PutFinalVoteIfAbsent`) and `VoteStore`. When `QuorumManager.finalTally` subsequently tallies `(victimAccount, victimPrev)`, it ignores all `FINAL` votes for `B_foreign.Hash` because `B_foreign.Account != victimAccount || B_foreign.Previous != victimPrev`. Because `FinalVoteStore` and `VoteStore` are write-once for `FINAL` votes per `(account, prev)`, honest representatives can never emit a `FINAL` vote for `B_victim.Hash`, permanently and irreversibly freezing `victimAccount`'s `FinalHeight` across node restarts.\n\n---\n\n### Root Cause\n\n1. **`ValidateVote` and `isConflictNotFound` (`core/vote.go:167-261`) do not check block position**:\n   `ValidateVote(v)` verifies the signature, checks `vm.ledger.GetVoteWeight(v.RepAccount()) > 0`, and checks the timestamp window, but never checks whether `b := vm.ledger.GetBlockOrStaged(v.BlockHash)` (when present) satisfies `b.Account == v.ConflictAccount && b.Previous == v.ConflictPrev`.\n\n2. **`gatherCandidates`, `noteHeldCandidatesLocked`, `castVoteLocked`, `convergeWeights`, and `emitFinalLocked` (`core/finalization.go`) only check `GetBlockOrStaged(h) != nil`**:\n   - `gatherCandidates(account, prev, seed...)` (`core/finalization.go:354-376`) collects every `v.BlockHash` from `vm.store.GetVotesByConflict(account, prev)` without checking the block's `(Account, Previous)`.\n   - `noteHeldCandidatesLocked(account, prev, candidates)` (`core/finalization.go:197-216`) checks only `if vm.ledger.GetBlockOrStaged(h) == nil { continue }`, allowing votes referencing arbitrary existing blocks on the lattice to reset `vm.lastNewCandidateNanos[key]` and stall the 3-second `lockStabilityWindow`.\n   - `castVoteLocked(account, prev, seed...)` (`core/finalization.go:128-146`) admits any candidate `h` with `vm.ledger.GetBlockOrStaged(h) != nil` into `eligible`, picks `pref := lowestHash(eligible)`, and checks `vm.ledger.depsFinalized(prefBlock)`. For any already-finalized foreign block `B_foreign` (such as `genesis` or a finalized block on the attacker's chain), `GetBlockOrStaged(B_foreign.Hash)` is non-nil and `depsFinalized(B_foreign)` is `true`.\n   - When `B_foreign.Hash < B_victim.Hash`, every honest representative switches its own `CONVERGE` vote for `(victimAccount, victimPrev)` to `B_foreign.Hash` with its full delegated weight.\n   - `maybeLockLocked` -> `emitFinalLocked(victimAccount, victimPrev, B_foreign.Hash)` (`core/finalization.go:265-306`) then calls `vm.ledger.finalVoteStore.PutFinalVoteIfAbsent(victimAccount, victimPrev, B_foreign.Hash)` and stores a `Final: true` vote in `VoteStore`. Both stores refuse to overwrite a locked/final vote for `(victimAccount, victimPrev)`.\n\n3. **Cross-conflict `LoserHashes` pollution in `QuorumManager.finalTally` (`core/quorum.go:111-123`)**:\n   In `finalTally(account, previous)`, `candidateSet[v.BlockHash] = true` is executed on line 112 *before* the `if b == nil || b.Account != account || b.Previous != previous` check on line 121. If a voter submits a cross-position vote on `(attackerAccount, attackerPrev)` naming a victim's staged block `B_victimStaged.Hash`, resolving `(attackerAccount, attackerPrev)` places `B_victimStaged.Hash` into `result.LoserHashes`, causing `cleanupResolvedConflict` (`core/quorum.go:399-405`) to mark `B_victimStaged.Hash` as `StatusRejected` in `QuorumStore` and delete it via `DeleteStagedBlock`.\n\n---\n\n### Impact\n\n- **Permanent, irreversible account finality freeze (DoS / funds lock)**: Any voter with `>= 1` micro-XE of weight can permanently freeze finality (`FinalHeight`) for any account block whose hash is lexicographically greater than any finalized block hash on the lattice (`genesis.Hash` alone is `038d0d04...`, which is smaller than ~98.6% of SHA-256 block hashes, and an attacker can also grind a single low-hash block on their own chain). Once honest representatives write `B_foreign.Hash` into `FinalVoteStore` (`prefixFinalVote` in BadgerDB), the lock persists across restarts and the victim account can never finalize that height or spend subsequent balances.\n- **Stability window stalling**: Even using foreign blocks with higher hashes, an attacker can repeatedly reset `lastNewCandidateNanos[key]` in `noteHeldCandidatesLocked` by referencing distinct blocks already on the lattice.\n- **Cross-conflict staged block deletion and `StatusRejected` poisoning**: A cross-position vote on an attacker-controlled slot causes `cleanupResolvedConflict` to delete a victim's staged block and mark its hash `StatusRejected`.\n\n---\n\n### Proposed Fix\n\n1. Add `blockMatchesPosition(b *Block, account, prev string) bool` and `(l *Ledger) blockForPosition(account, prev, hash string) *Block` in `core/finalization.go`.\n2. In `ValidateVote` and `isConflictNotFound` (`core/vote.go`), reject any vote whose `v.BlockHash` resolves via `GetBlockOrStaged` to a block that does not match `(v.ConflictAccount, v.ConflictPrev)`.\n3. In `gatherCandidates`, `noteHeldCandidatesLocked`, `castVoteLocked`, `convergeWeights`, and `emitFinalLocked` (`core/finalization.go`), require resolved candidate blocks to match `(account, prev)` via `blockMatchesPosition` / `blockForPosition` (including before `PutFinalVoteIfAbsent` in `emitFinalLocked`).\n4. In `QuorumManager.finalTally` (`core/quorum.go`), check `b != nil && !blockMatchesPosition(b, account, previous)` *before* inserting `v.BlockHash` into `candidateSet`.\n\n---\nPayout wallet (Base / XE): `0x45Ecf534fD00bb3179D34E6a3FDdE084cBfBc9Fb`","patch_refs":[{"id":322,"repo":"xeprotocol/xe","kind":"pr","ref":"290","title":"fix(core): reject cross-position block hashes in VoteManager and QuorumManager","url":"https://github.com/xeprotocol/xe/pull/290","note":"","state":"open","author":"pa-khan","added_by":"desk","created_at":"2026-11-07T14:43:44.746273+00:00"},{"id":324,"repo":"xeprotocol/xe","kind":"pr","ref":"293","title":"fix(core): reject cross-position block hashes in VoteManager and QuorumManager","url":"https://github.com/xeprotocol/xe/pull/293","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-07T19:28:33.865097+00:00"}],"thread":[{"id":738,"source":"web","source_ref":"reporter:314:fa793c8e6a4662a6","author":"pa-khan","team":false,"body":"Claimed Tier: High (10,000 XE) / Severe (25,000 XE). Updated GitHub issue #289 title with [HIGH] prefix. Companion fix PR with regression tests: https://github.com/xeprotocol/xe/pull/290 — Bound XE Payout Address: 975f2f37dda1568c766729d9f85ad01e37f0c71d469af19d0b2aaaef861d9574","created_at":"2026-11-07T19:50:05.257965+00:00"},{"id":3645,"source":"github","source_ref":"6885477490","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-1088 and says what differs; it is read like any other.","created_at":"2026-11-14T22:52:57+00:00"}]}