Badger MANIFEST loss opens the store as a fresh database silently, and a plain restart permanently deletes the orphaned SSTs
Report
Summary
NewBadgerStore (store/badger_store.go:47-54) opens Badger with bare
badger.DefaultOptions(dir) — no checks on directory contents. When the
MANIFEST file is missing (or truncated to a few bytes), Badger opens the
directory as a FRESH database: no error, no warning.
preflightDataDirGenesis (node/genesis.go:140) returns nil immediately when
IsEmpty() is true, so it cannot distinguish a genuinely fresh dir from a dir
holding orphaned SSTs but no MANIFEST. Genesis is re-applied and the node
proceeds with an empty ledger. Worse, Badger's open/close cycle DELETES the
orphaned SST files even when the opener performs zero writes — so merely
starting the node once with a lost MANIFEST permanently destroys the ledger
data on disk, silently. Only network resync could restore it afterwards.
Reproduction (local, on copies of a 50-send store, xe @ 89a542e)
Harness faultprobe badger-fillverify (real store.NewBadgerStore):
- Delete
MANIFEST→OPEN_OK, chain len 0, genesis re-applied ("Genesis block applied: 42000000000000 XE"). Reseed on the "empty" store succeeded; after reseed + clean close,000001.sstwent from 186,449 bytes to 1,283 bytes; reopen showed chain length 1 only. The original 50 sends are destroyed. - Truncate
MANIFESTto 10 bytes → identical silent-empty behaviour. - Read-only open + close with
MANIFESTdeleted, ZERO writes (badger-fillverify n=0→OPEN_OK,readErrs=0 mismatch=0) → the orphaned000001.sst(186,449 bytes) NO LONGER EXISTS afterwards (directory listing confirms: only vlogs, DISCARD, KEYREGISTRY, and a fresh 16-byte MANIFEST remain). Independently re-run with identical output. - Control: flip 64 bytes inside
MANIFEST→ cleanOPEN_ERR: manifest has checksum mismatch. Only delete/truncate-to-small are silent.
Impact (stated honestly)
Silent + irreversible local destruction of the node's entire ledger history on a plain restart, plus silent empty-state rejoin (no operator warning anywhere in the path). The distinctive harm vs. ordinary corruption is the DESTRUCTION: without the restart, the SST data is still on disk; after one start, it is gone. Trigger is local file loss/corruption (disk fault, bad/partial restore, operator error) — no remote trigger demonstrated. No cross-node or fund impact demonstrated: the node rejoins empty and would resync from peers. Minor.
Board precedent that this class is valued: XE-9241 (statechain replay brick from stored-state corruption, local crash trigger, "no funds at risk", Medium claim) and XE-1838 (silent identity swap on operator double-start, local-only, no funds, triaging at Minor).
Duplicate check (bodies read in full)
- XE-9241: statechain replay gap — corrupt stored VALUES brick startup.
Different code path (
statechain/chain.go:51-86) and opposite failure shape (brick vs silent reset+destroy). - XE-12805: SyncWrites power-loss durability — missing sync barrier, QEMU power-cut repro; process kill-9 / MANIFEST loss is a different mechanism.
- XE-8799: GetChain error-swallowing — different helper.
- XE-8742: restart rebuild trusts tampered blocks — tampered-but-valid content trusted; here genuine data is destroyed with no tampering.
- XE-1838: double-start identity swap — different files/mechanism.
- Queries:
MANIFEST(14, none about Badger MANIFEST),badger manifest(0),empty ledger(1, unrelated),fresh database(0),IsEmpty(1, unrelated),data loss(10, none store-related),orphaned(43, none Badger-manifest),corruption(74 titles scanned). No duplicate found.
Suggested fix
Refuse to open a non-empty directory without a valid MANIFEST (or warn loudly
and require an explicit --recover flag); make preflightDataDirGenesis
check directory contents (SST/vlog presence) before treating the dir as fresh.
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-12968 and says what differs; it is read like any other.