Committed ledger state is lost on power loss: BadgerStore never enables SyncWrites and no commit path calls Sync()
Report
Severity: Medium (XE tier ceiling 2,500 XE). CVSS 3.1: 4.8 (AV:P/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L) — see §7 for the scoring.
Target: github.com/xeprotocol/xe @ 89a542ea51d38375299aee54c6c99102e9bfa666 ("release: testnet-0005 quorum withhold fix", 2026-11-10). Go 1.25.0.
1. Impact (read this first)
A block whose CommitBlock has returned success — the ledger's own unit of committed state (block + chain + frontier + pending) — can be absent after a power loss, rolling the account chain back to an earlier height. In a QEMU true-power-loss simulation, killing the machine immediately after the last commit returned lost all 20 committed blocks in 10/10 cycles, and killing mid-write lost all 80–87 attempted commits in 6/6 cycles — including a commit ~1 s old. The same power cut lost nothing when store.Sync() followed every commit (3/3 cycles, 20/20 survived). Finalized blocks, settled leases, balances, delegations, and final heights all ride the same unsynced commit path, so the exposure is seconds of committed state per commit, not just uncommitted tail data.
The loss is bounded and honest: it is always a clean suffix truncation in commit order — the store reopens to an earlier consistent state (empty chain, empty frontier, torn=false, no link corruption, no GetAccountChain error in 24/24 VM cycles). No torn single transaction and no double-spend state was observed. The trigger is local power loss / host crash only; a remote process crash does not trigger it (host kill -9 lost nothing, 20/20). That is why this is Medium, not High.
2. Root cause
NewBadgerStore (store/badger_store.go:47-49) opens Badger with badger.DefaultOptions(dir).WithLogger(nil) and never enables SyncWrites. Badger's own docs draw the line exactly here (WithSyncWrites=false ⇒ writes survive process crashes; =true ⇒ "an additional msync after writes to flush mmap buffer over to disk to survive hard reboots"). CommitBlock (store/badger_store.go:667) is a single db.Update writing block + chain + frontier atomically — and returns success while the data is still only in the OS page cache.
Sync() exists (store/badger_store.go:58-60, return s.db.Sync()) but is called from exactly two sites in the whole repo, both on the final-vote path: core/finalization.go:98 (re-affirm, "durability sync failed, deferring final vote") and :295 (emitFinalLocked, same log message). Zero SyncWrites mentions exist anywhere in the repo. So the consensus-critical final-vote record is synced before emission, but every ordinary committed block — including the blocks that carry settled leases and balances — is not.
3. Scenario (how it happens)
- A node commits blocks via
CommitBlock(normal operation: gossip ingestion, sync, or local block creation). Each commit returns success. - The host loses power (or the machine crashes) within seconds of the last commit — before the OS page cache is flushed to disk (ext4 default journal commit interval is 5 s; the measured loss window on the test setup is >1 s and <10 s).
- The node restarts. The store reopens cleanly to an earlier consistent state: the committed blocks are gone, the account chain is shorter, the frontier points at an older hash. The node believes it never received them; peers must re-supply them via frontier sync + votesync (the self-heal path, code-level reasoning — not execution-proved here).
4. Proof of concept (QEMU true power loss)
PoC: hunt-v4-followup/f1/src/f1test/main.go (static Go binary, built from a worktree copy at 89a542e), driven by f1/vm/run_cycle.py. The test program commits a synthetic account chain f1acct through XE's real store API — one BadgerStore.CommitBlock per block, no mocks, no raw-Badger shortcut — inside a QEMU VM (Ubuntu 6.8 kernel, ext4 on a virtio disk, cache=writeback, fresh disk per cycle). The host kills the QEMU process with SIGKILL at the configured trigger: guest RAM (page cache) is gone; only bytes the guest had flushed to the virtual disk survive. That is a true power loss. The checker reopens the same data dir and reports per-block presence, longest surviving prefix, link integrity, chain length, and frontier agreement.
Results (24 VM cycles + host controls; full serial logs + machine-readable records in hunt-v4-followup/f1/logs/, 106 files):
| Variant | Trigger | Committed | Survived | Cycles |
|---|---|---|---|---|
| V-a | kill ~0.1 s after last commit returns (N=20) | 20 | 0 | 10/10 |
| V-b | kill mid-write, ~1 s after commit #5 (N=200) | 80–87 | 0 | 6/6 |
| V-c | same cut, store.Sync() after every commit (N=20) |
20 | 20 | 3/3 |
| V-a-delay | kill 10 s after last commit (N=20) | 20 | 20 | 3/3 |
| V-grace | graceful Close(), no kill (N=20) |
20 | 20 | 1/1 |
| C1 (host) | kill -9 on the host (N=20) |
20 | 20 | 1 run |
| C0 (host) | strace + dirty pages | 0 sync syscalls in commit window; 20 kB dirty in page cache after commits returned | 1 run |
In every loss cycle the store reopened cleanly to the empty state (chain_len == prefix == 0, frontier "", torn=false, GetAccountChain never errored, no link corruption). The loss is of committed state — every lost block's CommitBlock had returned success and its COMMITTED line had been printed before the kill. It is not uncommitted tail data. The synced control (V-c) proves the causal link to the missing barrier: the only difference from V-a is the Sync() call.
5. Attacker prerequisites
- None — this is not an attacker-triggered finding. The trigger is local power loss / host crash within seconds of a commit. There is no remote step, no privilege on the victim node, and no crafted input. That is a bound on the severity, stated plainly: the finding is a durability defect in the store layer, not an exploit.
6. Independent validation and false-positive assessment
- Mechanism nailed down three independent ways: (1) strace: zero sync syscalls on the commit path (the only 4 fsyncs in the run are Badger Open-time, before the first commit); (2) dirty pages: the entire committed chain state (20 kB: value log 4 kB, DISCARD 4 kB, memtable WAL 12 kB) was still only in the page cache when
CommitBlockhad already returned success; (3) the sync control: the identical power cut loses nothing whenSync()follows each commit. - Disproof attempts that failed: (a) "kill -9 shows no loss, so commits are durable" — false: host kill -9 preserves the OS page cache, so it tests process crash only (re-confirmed: C1 loses nothing); a power-loss test needs the page cache gone, which is why the QEMU model was built; (b) "the loss is only uncommitted tail data" — false: every lost block was acknowledged before the kill; (c) "Badger flushes on its own quickly enough" — false on the measured setup: a commit ~1 s old was lost in 6/6 mid-write cycles.
- Not a false positive: the loss is measured final state (blocks absent after reopen) across 16/16 unsynced power-loss cycles, with a passing synced control. The 7-Question Gate passes with Q1 capped at Medium (no remote trigger).
- Duplicate check (fresh, DB 2,421 entries as of 2026-11-14 ~17:00 WIB): full-DB durability searches return 0 hits for
syncwrite|fsync|msync|power loss|hard reboot|durab; the only "data loss" hits are gossip message-handling reports (xe#427, xe#469 — different mechanism). Closest filed items distinguished on function/trigger/scope: xe#246/XE-0275 (genesis two-txn tear — fixed by open PR #249, which makes the genesis commit atomic but adds no sync), XE-0041/xe#60 (SIGTERM sync hang, no durability loss), xe#381/XE-6110 (archive stale-snapshot overwrite, different function). Open PR #536 (final-vote lock clear on lease-cancel rollback) touches vote-lock lifecycle, not durability. Classification: NOVEL on public data (private Critical/Severe reports may exist; uniqueness is not guaranteed). Full analysis:duplicate-intel/reports/v4f-f1-durability-duplicate-analysis.md.
7. Severity justification (Medium, ceiling 2,500 XE)
CVSS 3.1: 4.8 (AV:P/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L). Attack vector is physical (power loss / host crash requires physical access to the host); complexity is High (the cut must land within seconds of a commit); no privileges or user interaction; integrity impact is Low in CVSS terms (committed state rolls back to an earlier consistent state — suffix truncation only, no torn transaction, no double-spend) and availability Low (the node restarts at an earlier height; service continues and self-heals from peers).
Why not High: (a) no remote trigger — a remote process crash does not cause it; (b) no attacker step at all; (c) the loss is a clean suffix rollback, not corruption; (d) the consensus-critical record (final votes) is synced before emission; (e) a replicated network self-heals via frontier sync + votesync. If the committee weighs the settled-lease / balance rollback more heavily, the honest alternative framing is still Medium — the trigger remains local-only.
8. Fix suggestion
Enable WithSyncWrites(true) in NewBadgerStore (store/badger_store.go:47-49), or call Sync() after each CommitBlock (the Syncer interface and store.Sync() already exist; the final-vote path shows the pattern). Either direction is confirmed effective at the store layer by the V-c control (3/3 cycles, zero loss under the identical power cut). Note the performance trade-off: syncing every commit costs an fsync/msync per block; a cheaper variant is syncing on finality boundaries only — but then unfinalized committed blocks remain exposed, and that residual exposure should be stated in the fix, not silently kept.
9. Caveats (kept in the report)
- Store-layer proof only (
BadgerStore.CommitBlockon a synthetic chain), single node, no gossip, no votes, no leases, no statechain, no multi-node sync. A full-node reproduction (realxenode as sole rep, blocks submitted via the API, power cut, restart, API-acknowledged blocks shown absent) is recommended strengthening and is what the committee will ask for first. - The self-heal mitigation (frontier sync + votesync restoring a truncated node) was not executed here; it remains code-level reasoning.
- Final-vote durability in a live node (a final vote surviving a power cut after emission, beside a later unsynced block being lost) was not proven in a live node; V-c is the store-level analogue only.
- The statechain wedge (V4-F5: a power-loss truncation gap bricking restart via
statechain/chain.goreplay) was NOT tested; no wedge appeared at the store layer at this data volume, which says nothing about F5 either way. F5 is folded into this finding as its worst-case manifestation, not filed separately. - Loss window (>1 s, <10 s) is filesystem/setup-dependent (ext4
ordered, defaultcommit=5on this setup); the qualitative result (unsynced committed state is lost) is not. Data volume was small (20–87 blocks, a few kB, memtable WAL only — no SSTable flush / compaction / value-log GC exercised). - NOVEL means no matching public finding as of the 2026-11-14 ~17:00 WIB check (DB 2,421 entries); private reports may exist.
10. Reproduction (for the committee)
Local only, worktree copy at 89a542e, isolated temp data dirs; needs QEMU + a guest kernel (see F1_VALIDATION.md §8 for the full commands):
export PATH=~/workspace/go/go/bin:~/go/bin:$PATH
export TMPDIR=~/workspace/xe-bounty/.tmp
F1=<worktree>/hunt-v4-followup/f1
cd $F1/src/f1test && CGO_ENABLED=0 go build -trimpath -o ../../bin/f1test .
cd $F1 && python3 host_controls.py # strace + dirty pages + kill -9
cd $F1 && python3 vm/run_cycle.py --variant V-a --cycles 1 --n 20 \
--kill-mode after-done --kill-delay 0 # one power-loss cycle
PoC: hunt-v4-followup/f1/src/f1test/main.go; VM driver: hunt-v4-followup/f1/vm/run_cycle.py; logs: hunt-v4-followup/f1/logs/ (106 files). Full analysis: hunt-v4-followup/f1/F1_VALIDATION.md; duplicate analysis: duplicate-intel/reports/v4f-f1-durability-duplicate-analysis.md.
Thread
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-13395 and says what differs; it is read like any other.