Skip to content

DualStore: VSS mirror writes can land out of order (stale monitor/manager in the backup) #10

Open

Description

@kaloudis

Same bug class as ZeusLN/zeus-vls#266, fixed for lnrod in ZeusLN/zeus-vls#273. lnrod's DualStore was ported from this one.

Affects the tag ZEUS mobile ships (v0.7.0-zeus-rl-0.2.5, branch rl-0.2.5-security-bump), rl-0.2.7-security-bump, and zeus (32fc853). Every ZEUS mobile user's VSS backup is exposed, not only Route nodes.

Problem

src/io/dual_store.rs writes to SQLite and then spawns one thread per VSS write or remove (write ~397-441, remove ~443-488). VssStore orders writes to the same key with a version and skips stale ones (execute_locked_write), but three gaps remain:

  1. Same-key order can flip. The version is assigned in VssStore::write (get_new_version_and_lock_ref), which runs on the spawned thread, not when DualStore::write is called. Two writes of one key spawned back to back can reach VssStore in the opposite order. The older blob then gets the higher version and wins.
  2. The bulk sync can overwrite a newer write. bulk_sync_to_vss reads a key from SQLite and only later calls VssStore::write, which assigns the version at that point. A live write that lands between the read and the call gets the lower version, so the bulk sync's older blob wins.
  3. Nothing orders monitors before the manager. If a monitor upload fails after its 180 s of retries while a later manager upload succeeds, VSS holds a manager newer than a monitor it treats as persisted.

On restore, LDK 0.2 refuses a manager that is ahead of its monitors (DecodeError::DangerousValue, "A ChannelMonitor is stale compared to the current ChannelManager"), so the restore fails. A monitor ahead of the manager is LDK's ordinary crash case: the affected channel is force-closed from the monitor.

Fix

Port the design from ZeusLN/zeus-vls#273:

  • One background worker drains a set of dirty keys.
  • It reads the current SQLite value at upload time, so the newest value wins and superseded writes are never sent.
  • It reads the manager before taking each batch, uploads the monitors first, and uploads that manager last, only if every monitor in the batch went through.
  • The startup bulk sync becomes "mark every key dirty" on the same worker.
  • Failed keys stay dirty and are retried with backoff.

Two pieces are specific to this fork:

  • The push safety gate (vss_push_verdict) moves into the worker and is checked before each round. Disabled drops the batch; Undetermined keeps the keys dirty.
  • Restore mode still skips the startup sync.

Tests

  • A slow older upload never lands after a newer write.
  • Writes queued behind an in-flight upload are sent once, as the newest value.
  • The manager is held back while a monitor upload fails.
  • Within a round, the manager is uploaded after the monitors.
  • A local remove reaches VSS.
  • The push gate in the Disabled state still blocks every upload.

Tracking: ZeusLN/zeus-route#108 (P18), ZeusLN/zeus-route#110.

Activity

  1. added a commit that references this issue on Oct 3, 2026
    fd380c3
  2. added 2 commits that reference this issue on Oct 27, 2026
    dda8697
    8c58827
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions