{"id":"XE-0094","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"159","source_url":"https://github.com/xeprotocol/xe/issues/159","reporter_id":32,"title":"Final votes frozen at receipt-time weight, counted against a later snapshot total","area":null,"claimed_tier":"high","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0070","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-10-29T13:57:25.998544+00:00","updated_at":"2026-11-10T00:11:32.680748+00:00","source_created_at":"2026-10-29T02:45:15+00:00","told_at":"2026-11-05T22:12:02+00:00","status_changed_at":"2026-11-05T22:11:45.629053+00:00","url":"https://bounty.xe.network/XE-0094","body":"# Final votes frozen at receipt-time weight, counted against a later snapshot total\n\n## Summary\n\nA final vote that arrives before its conflict record exists takes the\nrepresentative's live weight at receipt time. The conflict's weight snapshot\nis created only when the second fork block arrives, and it is never used to\nre-weight stored votes. The final tally then sums stored (stale) weights\nagainst the snapshot total, so a fork can finalize on counted weight that no\nlonger exists — in the worked case, counted 70/100 while true current support\nis 30/100.\n\n## Impact\n\nWhoever holds the finalized block's transfers wins, so a finalization on\nstale weight decides who gets paid. With different conflict-detection times,\ntwo honest nodes (no equivocation — each representative voted once, finally)\ncan finalize different winners during ordinary delegation churn. That\ntwo-node divergence has now been executed (see below); it matches the\nprogram's Critical example (conflicting finalized histories), but the tier\nis kept at High by researcher decision 2026-10-29 (Critical option declined) — upgrading to Critical\nwould change the submission channel to email-first, and the program's\nsecurity@xe.network address has no MX records (see Caveats).\n\nSuggested program tier: **High** (finality safety; held below Critical for\nthe reason above).\n\n## Root cause\n\n- `core/vote.go` `receiveVoteInner`: with no conflict record yet, the vote's\n  counted weight is the current live delegated weight, and the row is stored.\n- `core/ledger.go` (conflict detection): the weight snapshot and total are\n  assigned only when the second fork block arrives and the conflict is new.\n  Nothing ever refreshes the snapshot afterwards, and nothing ever re-weights\n  stored votes.\n- `core/vote.go` `receiveVoteInner`: a stored row that is already final is\n  returned early — no weight recompute, no overwrite. Re-affirmed final votes\n  (re-emitted on a 15-second backoff) are therefore also discarded for\n  weight purposes, and the stale weight sticks.\n- `core/quorum.go` `finalTally`: sums the stored weights of final votes and\n  compares against the snapshot total (falling back to the live total only\n  when the snapshot total is zero). A pre-conflict final vote thus counts at\n  receipt-time weight against a detection-time total.\n\n## Proof of concept\n\nTarget: `xeprotocol/xe` @ `978785929bc17a2f4ab30c383e5fc9cf4d634512`\n(2026-10-15). The harness uses in-package fake stores plus the real\n`VoteManager` / `QuorumManager` / vote-signing code; the repository itself\nis not modified.\n\nAttached PoC: `pocs/presenter-slice2-test.go.txt` (byte-identical copy of\nthe runnable test; copy it to `core/zz_presenter_slice2_test.go` inside a\nscratch copy of the repository, never the real repo).\n\nRun (Go 1.25.14):\n\n```\nexport PATH=\"$HOME/.local/go/bin:$PATH\"\ncd <scratch copy of xe>\nGOPROXY=off go test ./core/ -run TestPresenterFrozenFinalWeightVsSnapshot -v -count=1\n```\n\nWorked shape: representatives R=50, S=30, T=20 (total 100). R and T\nfinal-vote fork X (70/100, genuine at lock time). A whale re-delegates 40\nfrom R to S before a slow node detects the conflict. That node's snapshot is\nR=10, S=70, T=20 (total still 100), but R's stored final vote still weighs\n50, so X finalizes at counted 70/100 while current support is 10+20=30/100.\n\nObserved output (verbatim):\n\n```\nR pre-conflict final vote stored weight=50\nR stored weight after re-affirm still=50 (snapshot says 10)\nFINALIZED winner on counted 70/100 while current-weight support is 30/100 (final height 2)\n```\n\nExpected if weights were consistent: no finalization (30 < 67), or R's\nstored weight re-based to the snapshot value 10, giving counted 30/100.\n\n### Two-node divergence (executed 2026-10-29)\n\nAttached PoC: `pocs/presenter-divergence-test.go.txt` (byte-identical copy\nof the runnable test; same scratch-copy setup as above).\n\nRun (Go 1.25.14):\n\n```\nexport PATH=\"$HOME/.local/go/bin:$PATH\"\ncd <scratch copy of xe>\nGOPROXY=off go test ./core/ -run TestPresenterTwoNodeDivergentFinalization -v -count=1\n```\n\nSetup: two ledgers, same conflict position, same final-vote set (R votes\nfork X, T votes fork X, S votes fork Y — each once, finally, no\nequivocation). Node A's chain holds X and its detection-time snapshot is\n50/30/20; node B's chain holds Y and its snapshot is 10/70/20 (whale\nre-delegated 40 from R to S before B detected the conflict).\n\nObserved output (verbatim):\n\n```\nDIVERGENCE: A finalized X, B finalized Y, same position (eaa22bb39270, aeebad4a796f...), no equivocation (R->X, T->X, S->Y once each); B stored R=10 S=70\n--- PASS: TestPresenterTwoNodeDivergentFinalization (0.01s)\n```\n\nSo node A finalized X on counted 70/100 while node B finalized Y on\ncounted 70/100, for the same conflict position, with no equivocation\nanywhere.\n\n## Reproduction steps\n\n1. R and T final-vote fork X (70/100 at lock time) on a slow node that has\n   not yet seen the conflicting fork.\n2. Re-delegate 40 weight from R to S before the slow node detects the\n   conflict.\n3. The slow node detects the conflict, snapshots R=10, S=70, T=20, and tallies\n   the stored votes — X finalizes at counted 70/100.\n\n## Recommended fix\n\nOn conflict creation, re-weight all stored votes for that position from the\nnew snapshot (including final rows); and/or re-weight stored final votes on\nevery receipt of a re-affirmed final vote; and/or include the snapshot (or\nits hash) in the conflict record that nodes agree on before counting.\n\n## Severity\n\n- CVSS 3.1: 5.9 — `CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N`\n- CWE-840 (Business Logic Errors)\n- AC:H: the flaw needs re-delegation timing plus a slow-node detection\n  window.\n\n## Caveats\n\n- The harness seeds weights and chains directly to isolate the tally logic;\n  it proves the accounting flaw, not a full-network reproduction. The\n  two-node divergence above is a two-ledger harness execution, not a live\n  two-node network run — that is why this is filed as High, not Critical.\n- Tier note: the executed divergence matches the program's Critical\n  example (conflicting finalized histories). Upgrading this report to\n  Critical would change the required channel to email-first to\n  security@xe.network, whose MX records were absent on two independent\n  resolvers at verification time (see the audit's program notes); that\n  channel question was decided by the researcher 2026-10-29: stays High,\n  Critical option declined.\n- No public prior report of the frozen-weight / snapshot-tally mechanism\n  was found (dedup queries recorded in the audit's DEDUP-BASELINE.md).\n- This reproduction runs against the repository code at the stated HEAD. No\n  testnet transactions were sent as part of this report.\n\nPayout address (XE): eff2c51dd8457df740b919226cd9b37a2944e5abea7501094db80234f87f010e\n\nBest,\nChaplin\n\n[presenter-slice2-test.go.txt](https://github.com/user-attachments/files/34109926/presenter-slice2-test.go.txt)\n[presenter-divergence-test.go.txt](https://github.com/user-attachments/files/34109925/presenter-divergence-test.go.txt)","patch_refs":[{"id":211,"repo":"xeprotocol/xe","kind":"pr","ref":"211","title":"fix(core): re-weight stored votes and dynamic tally against conflict snapshot (fixes #159)","url":"https://github.com/xeprotocol/xe/pull/211","note":"","state":"open","author":"NePreby","added_by":"desk","created_at":"2026-10-29T18:28:28.878648+00:00"}],"thread":[{"id":439,"source":"github","source_ref":"6670882990","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0070, 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, reply with what differs and we will look again.","created_at":"2026-11-05T22:12:02+00:00"}]}