<!-- XE-12968 · Badger MANIFEST loss opens the store as a fresh database silently, and a plain restart permanently deletes the orphaned SSTs · testnet -->
*Markdown view of <https://bounty.xe.network/XE-12968>. The page is the record; this is the same page for reading.*

XE-12968 · Bounty

# Badger MANIFEST loss opens the store as a fresh database silently, and a plain restart permanently deletes the orphaned SSTs

Closed · duplicate
—claimed Minor
web
filed 2026-11-14 14:51 UTC
by xe:b4c356d4

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Minor

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 19:45 UTC

Told
:   2026-11-20 19:45 UTC

### Patches

None linked.

### History

- [626156](https://bounty.xe.network/log/626156) 2026-11-20 19:45 UTC proposal.adopted
- [626155](https://bounty.xe.network/log/626155) 2026-11-20 19:45 UTC reply.sent
- [626154](https://bounty.xe.network/log/626154) 2026-11-20 19:45 UTC ticket.status new → closed
- [621840](https://bounty.xe.network/log/621840) 2026-11-20 19:44 UTC proposal.adopted
- [621839](https://bounty.xe.network/log/621839) 2026-11-20 19:44 UTC ticket.facts area
- [621837](https://bounty.xe.network/log/621837) 2026-11-20 19:44 UTC proposal.adopted
- [621836](https://bounty.xe.network/log/621836) 2026-11-20 19:44 UTC ticket.facts
- [621833](https://bounty.xe.network/log/621833) 2026-11-20 19:44 UTC proposal.adopted
- [621832](https://bounty.xe.network/log/621832) 2026-11-20 19:44 UTC ticket.facts
- [612914](https://bounty.xe.network/log/612914) 2026-11-20 15:29 UTC note.added
- [612913](https://bounty.xe.network/log/612913) 2026-11-20 15:29 UTC proposal.created
- [612912](https://bounty.xe.network/log/612912) 2026-11-20 15:29 UTC proposal.created

[Full history](https://bounty.xe.network/log?ref=XE-12968) · [JSON](https://bounty.xe.network/v1/tickets/XE-12968) · [markdown](https://bounty.xe.network/XE-12968.md)

### 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`):

1. 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.sst` went from 186,449 bytes
   to 1,283 bytes; reopen showed chain length 1 only. The original 50 sends
   are destroyed.
2. Truncate `MANIFEST` to 10 bytes → identical silent-empty behaviour.
3. Read-only open \+ close with `MANIFEST` deleted, ZERO writes
   (`badger-fillverify n=0` → `OPEN_OK`, `readErrs=0 mismatch=0`) → the
   orphaned `000001.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.
4. Control: flip 64 bytes inside `MANIFEST` → clean `OPEN_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

**Joseph Denne**team2026-11-20 19:45 UTCdesk

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.
