Bounty
XE-0114 · Bounty

[Node/VM] Provider restart destroys VMs backing live Accepted leases — both VM backends reap every instance at startup with no ledger reconciliation, and nothing re-provisions them

Triaging claimed Medium xe#191 filed 2026-10-29 10:52 UTC by zafrans

Report

Suggested severity: Medium (2,500 XE) Area: node / VM lifecycle (vm/lima_manager.go, vm/qemu_manager.go, node lease watch) Repo pin: 9787859 (testnet-0005)

Summary

A provider node's VM managers destroy the VMs of still-live Accepted leases at every startup, and nothing ever re-provisions them. Both backends reap unconditionally at manager construction, with no check against ledger lease state:

  • Lima: NewLimaManager calls cleanOrphans() (vm/lima_manager.go:85, defined :325), which lists instances via limactl and issues stop + delete --force for EVERY instance whose name has the prefix xe- — including instances backing leases that are Accepted and mid-term on-chain. The manager takes no ledger input at all.
  • QEMU: NewQEMUManager likewise calls cleanOrphans() (vm/qemu_manager.go, in the constructor), which SIGKILLs every qemu-system process matching the node's workRoot — again including VMs backing live Accepted leases.

The loss is permanent for the lease term: VM registries are in-memory only, and the node's lease loop never reconciles them against the ledger. leaseWatchTick (node/node.go:1670) only auto-accepts UNACCEPTED leases — Accepted leases are explicitly skipped (leaseAlreadyAccepted) — and provisionVM's only call site is the accept path (node/node.go:1554, inside autoAcceptLease). No startup or periodic path re-registers or re-provisions a VM for an already-Accepted lease.

Mechanism

  1. Provider runs normally; one or more leases are Accepted; VMs are running (Lima instances named xe-<leasehash12>, or daemonized QEMU processes under the node's workRoot).
  2. The node process restarts — upgrade, crash recovery, host reboot, operator restart. This is a routine operational event, not an attack.
  3. Manager construction reaps every existing VM of both backends unconditionally (details above). No code compares the instance/process list against ledger lease state (Created/Accepted/Settled/Cancelled) before reaping.
  4. After startup, the ledger still shows the leases as Accepted (they are), but their VMs are gone. leaseWatchTick skips them as already-accepted; settle/teardown bookkeeping iterates the fresh (empty) registry and can no longer reach them either.
  5. The consumer's paid service is silently gone for the remainder of the lease term; escrow unwinds only at expiry/settle per the normal schedule.

Trigger

A single ordinary provider restart. No attacker action, no malformed input, no race. The defect is the absence of startup reconciliation between the VM layer and ledger lease state.

Proof of concept

Exercised in a scratch copy of the pinned tree (repo tree left clean); independently re-run and reproduced by the reporter:

  • Lima (load-bearing): TestSeg1DRun105LimaRestartDeletesLiveVMs stands up the REAL NewLimaManager against a fake limactl that reports a Running xe- instance and a non-xe instance. Construction issues stop + delete --force for the xe- instance (the manager log prints "Cleaning orphaned Lima VM: xe-abcdef123456 (status: Running)") and leaves the non-xe instance untouched (negative control). PASS.
  • Registry loss: TestSeg1DRun105RegistryLossAcrossRestart — a fresh manager over the same world lists 0 VMs and teardown of a pre-restart lease fails as not-found. PASS.
  • QEMU kill-at-construction is established by direct code read (cleanOrphans SIGKILLs workRoot-matching qemu processes from the constructor); it is not separately executed in the PoC.

Reproduce: go test ./vm -run TestSeg1DRun105 -count=1 -v

Impact

  • Consumers: a paid, Accepted lease loses its VM — and therefore the leased service — for the rest of its term after any provider restart, with no on-chain signal that anything is wrong (the lease remains Accepted).
  • Providers: honest providers silently break live service obligations on every routine restart (upgrades included), and lose teardown/reachability for those leases afterwards.
  • The defect fires on 100% of restarts for 100% of live leases on the affected provider; it is not a race or an edge case.

Honest limits

  • The trigger is the provider's own restart (a routine event), not a remote attacker action. The claim is an implementation correctness/availability defect in the node software, in the same family as other accepted node-behaviour reports (e.g. #60 shutdown handling, #161 vote-store growth).
  • Proven locally (real manager construction + fake limactl; code read for QEMU). No live provider was restarted and no live lease was harmed.
  • No claim is made that a provider can profit from this: any settle-after-destruction question belongs to the already-reported settle-validation reports (#90/#21) and is NOT relied on here.

Duplicate check

No match. Live searches on 2026-10-29: "cleanOrphans" 0 results; "reprovision" 0 results; "lima" 1 result (#154, tunnel access control — different mechanism); "orphan"/"restart" neighbours are #60 (SIGTERM during sync hangs shutdown — different), #161 (gossiped-vote store growth — different), #51 (DAO vote replay cache — different). Distinct from #90/#21 (ledger settle-validation gaps; this is node VM-lifecycle reconciliation — different deviation source, different remediation), from #4/#154/#104 (tunnel/SSH access control), and from #38/#43 (ledger conflict unwinds).

Suggested fix

At manager construction, reconcile before reaping: cross-check discovered instances/processes against ledger lease state and reap only those whose lease is terminal (Settled/Cancelled/expired) or unknown to the ledger; adopt or re-provision VMs backing Accepted leases (rebuild the registry from ledger state), so a restart is transparent to live leases.

Reporter

XE payout address: 24b1be6a99de922902aceccce2456abc3769e4ab1cac463ea86fb23496b868b3 Discovered: 2026-10-29, against the public testnet implementation at the pinned commit. Reproduction was local only; no other users' funds, keys or workloads were touched.

Thread

Joseph Denneteam2026-11-08 20:18 UTCgithub

Thank you for the report. We have confirmed the behaviour you describe in the provider's VM lifecycle and it is being handled; we will update this ticket as the fix progresses.

zafrans2026-11-11 04:49 UTCgithub

Payout address update

Hi team — a quick addition to this report.

This report did not list a payout address. For the record, my XE payout address for this report is:

5dc48847412ffe94e4f7097b81ee111b9e207b47c9c1f3bab988f08b63bcc7e3

Please use this address for any award for this report. I am posting the same update on my other reports (#175, #183, #184, #191). Thank you.

zafrans2026-11-11 04:50 UTCgithub

Small correction to my comment above: this report did list the previous payout address (24b1be6a99de922902aceccce2456abc3769e4ab1cac463ea86fb23496b868b3) in its Reporter section. That address is no longer accessible to me — please disregard it and use 5dc48847412ffe94e4f7097b81ee111b9e207b47c9c1f3bab988f08b63bcc7e3 for any award for this report, as stated above. Sorry for the confusion.

Reyzz952026-11-12 16:37 UTCgithub

Still reproduces at HEAD 89a542e (testnet-0005, 2026-11-10).

NewLimaManager still calls cleanOrphans() (deletes every xe--prefixed Lima instance) and NewQEMUManager likewise kills every qemu process under the work root. After a provider restart the in-memory VM map is empty, so every pre-restart VM is an orphan. Node.Stop() tears down nothing and re-provisions nothing on start — VMs backing live Accepted leases are destroyed.

kinoy-12026-11-24 03:37 UTCgithub

Additional trigger for the same root cause (settle pays on time alone; no VM-existence / liveness reconciliation) — found while re-auditing at HEAD 8cc209d (testnet-0006):

The VM can die without any provider restart, and nothing notices:

  • Lima Get()/List() (vm/lima_manager.go:199-229) and QEMU Get()/List() (vm/qemu_manager.go:312-340) return the stored "running" status with no process/instance liveness check, and no ticker ever re-checks VM health.
  • So a guest panic, an OOM-kill, or a manual limactl stop/kill of the guest leaves the lease Accepted with a dead VM, and settle still pays the full LeaseTotalEmission on time alone (node/node.go:2030-2040, core/ledger.go:2252+); cancel after a finalized accept is refused (core/ledger.go:1883-1924).

#191 proves the restart trigger; this is the same defect with a wider trigger set (any guest death, not just restart). No new issue filed — recording here as evidence for this report.

Payout address (reporter kinoy-1): 19f0b012f28b5954679765cad3c5795380fabec1f050f7a57e1f4dc34caf13c7