dao: vote replay cache is a process-local 50k FIFO; an evicted signature replays inside the 10 minute window (Medium)
Report
Summary
The DAO API's replay protection is a process-local OrderedDict of signature hexes capped at 50000 entries, evicted first-in-first-out, and it dies on restart. Vote signatures are published verbatim by the votes endpoint, so any seat holder's captured vote signature can be replayed once the cache has been flushed by a restart or flooded out by 50001 unique self-signed requests (the public inbox POST is a free eviction source).
Affected component
dao/auth.py, _Seen at lines 52 to 84 and the check_and_add call at line 83; dao/api/public.py, votes route returning the raw signature at lines 126 to 133; window is MAX_SKEW_NS, 10 minutes (auth.py), at dao commit c60cf81522e3eb9e258b353e77164a3f7634cd98. ## Scope note The dao service is the governance backend named in the program's "state chain and multisig governance" scope row; flagging that the dao repository itself is not separately named on the bounty page.
Impact
A replayed FOR vote inside the 10 minute window replaces an AGAINST ballot on an advisory portal vote. Portal votes are advisory (nothing executes automatically), so this is integrity of a replaceable ballot, not a treasury move. Max loss: one flipped advisory vote per captured signature per 10 minute window.
Suggested severity: Medium (validation gap). Confirmed by read-only source review with an in-process harness.
PoC
PoC
Script (clone the dao repository as a sibling checkout directory and adjust the path line inside the script if your layout differs):
#!/usr/bin/env python3
"""F14: DAO vote replay cache is a process-local FIFO of signature hexes."""
from __future__ import annotations
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "ws", "dao"))
from dao.auth import _Seen # noqa: E402
def main() -> int:
# Tiny cap so eviction is visible without 50_001 inbox posts.
seen = _Seen(cap=3)
vote_sig = "aa" * 32
first = seen.check_and_add(vote_sig)
replay_before = seen.check_and_add(vote_sig)
for i in range(3):
seen.check_and_add(f"{i:064x}")
replay_after_evict = seen.check_and_add(vote_sig)
print(
f"cap={seen.cap} first_add={first} immediate_replay={replay_before} "
f"replay_after_fifo_evict={replay_after_evict}"
)
if first is True and replay_before is False and replay_after_evict is True:
print("PASS: F14 _Seen is RAM FIFO; evicting the vote sig lets the same hex replay")
return 0
print("FAIL: F14 expected first=True, immediate replay=False, post-eviction replay=True")
return 0
if __name__ == "__main__":
raise SystemExit(main())
Run (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):
cap=3 first_add=True immediate_replay=False replay_after_fifo_evict=True
PASS: F14 _Seen is RAM FIFO; evicting the vote sig lets the same hex replay
Fix suggestion
Persist the replay cache (or key it by signature in the database with a unique index), and stop returning raw signatures on public vote reads.
Thread
Thanks, confirmed. The replay set is per process and bounded, and we also found that a replayed older vote overwrites a newer one because portal.vote does not compare timestamps. The fix is a monotonic timestamp rule on votes plus a persisted seen-signature table with a purge after the skew window. Vote signatures will stay public, since with those two changes they are safe to publish and they are what lets anyone check the tally. We will post the commit here when it lands.
Fix is on main: https://github.com/xeprotocol/dao/commit/fd2b0d5f0ed1a3dbf0a11a9b33ce3cb7a1741c8d. Deploying to dao.test.network next; this issue will be updated once it is live.
This fix is now live on dao.test.network.