<!-- XE-1787 · A dead guest VM is reported as running forever: neither VM manager ever checks guest liveness, so a powered-off VM keeps charging provider capacity until settle · testnet -->
*Markdown view of <https://bounty.xe.network/XE-1787>. The page is the record; this is the same page for reading.*

XE-1787 · Bounty

# A dead guest VM is reported as running forever: neither VM manager ever checks guest liveness, so a powered-off VM keeps charging provider capacity until settle

Triaging
claimed Medium
web
filed 2026-11-09 04:09 UTC
by xe:fc954dbe

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-09 10:32 UTC

Told
:   2026-11-09 10:20 UTC

### Patches

None linked.

### History

- [50631](https://bounty.xe.network/log/50631) 2026-11-09 10:32 UTC proposal.adopted
- [50630](https://bounty.xe.network/log/50630) 2026-11-09 10:32 UTC ticket.award
- [50079](https://bounty.xe.network/log/50079) 2026-11-09 10:20 UTC proposal.adopted
- [50078](https://bounty.xe.network/log/50078) 2026-11-09 10:20 UTC reply.sent
- [49816](https://bounty.xe.network/log/49816) 2026-11-09 10:20 UTC proposal.adopted
- [49815](https://bounty.xe.network/log/49815) 2026-11-09 10:20 UTC proposal.adopted
- [49814](https://bounty.xe.network/log/49814) 2026-11-09 10:20 UTC ticket.facts
- [49813](https://bounty.xe.network/log/49813) 2026-11-09 10:20 UTC proposal.adopted
- [49812](https://bounty.xe.network/log/49812) 2026-11-09 10:20 UTC ticket.facts
- [49811](https://bounty.xe.network/log/49811) 2026-11-09 10:20 UTC proposal.adopted
- [49810](https://bounty.xe.network/log/49810) 2026-11-09 10:20 UTC ticket.facts
- [49809](https://bounty.xe.network/log/49809) 2026-11-09 10:20 UTC proposal.adopted

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

### Report

# \[Medium\] A dead guest VM is reported as running forever: neither VM manager ever checks guest liveness, so a powered-off VM keeps charging provider capacity until settle

## Summary

Both production VM managers answer `Get` and `List` purely from an
in-memory map, and nothing in the process ever re-checks whether the guest
is still alive. The only liveness reaping in either manager is
`cleanOrphans()`, which runs exactly once, at manager construction. A guest
whose process dies mid-run, because the tenant powers it off from inside,
because the host OOM killer takes it, or because an admin kills the
instance, therefore leaves a phantom entry: `Get` keeps returning status
`running`, `List` keeps charging its full vCPU, memory and disk against
provider capacity, `activeLeaseCount` keeps counting it, and `DialSSH`
fails against a dead port. The phantom clears only when the lease settles
and `finishSettle` calls teardown, or when the process restarts. Until
then the provider cannot sell that capacity to anyone else, reports a VM
that does not exist, and cannot reach the guest it believes is running.

## Affected component and versions

- `xeprotocol/xe`, `master` @ `02e9641` (`Merge pull request #251 from xeprotocol/fix/dao-tool-timestamp`). No PR is required.
- `vm/lima_manager.go`: `Get` (`:199`), `List` (`:216`), `cleanOrphans` (`:325`, called only from `NewLimaManager` at `:85`).
- `vm/qemu_manager.go`: `Get` (`:312`), `List` (`:327`), `cleanOrphans` (`:361`, called only from `NewQEMUManager` at `:139`).
- `node/node.go`: the capacity loops that consume `List()` in
  `autoAcceptLease` (`:1520`), `handleMarketplace` (`:1332`), and
  `activeLeaseCount` (`:1429`); `cleanupOrphanedVMs` (`:1773`), which only
  tears down terminal leases; `trySettleExpiredLeases` (`:1796`).

## Mechanism

`LimaManager.Get` and `List` are map reads with a hardcoded status:

```
// vm/lima_manager.go:199-230
func (m *LimaManager) Get(leaseHash string) (*Info, error) {
    m.mu.RLock()
    defer m.mu.RUnlock()
    v, ok := m.vms[leaseHash]
    if !ok {
        return nil, fmt.Errorf("vm not found for lease %s", leaseHash)
    }
    return &Info{
        LeaseHash: leaseHash,
        Status:    "running",
        Resources: &v.resources,
        CreatedAt: v.createdAt,
    }, nil
}
```

`QEMUManager.Get` and `List` are identical in shape
(`vm/qemu_manager.go:312-340`), same hardcoded `"running"`, same map.
Entries enter the map only in `Provision` (`lima_manager.go:146`,
`qemu_manager.go:258`) and leave it only in `Teardown`. Nothing ever
queries the hypervisor again: `cleanOrphans` is called only from the two
constructors, and it does not even touch `m.vms`, it kills stray
processes directly. There is no periodic reaper, no health check on read,
and no pid liveness test anywhere in `vm/`.

Three node paths then treat the phantom as a live VM:

1. Capacity. `autoAcceptLease` sums `VMManager.List()` before deciding a
   new lease fits (`node/node.go:1520-1532`), and `handleMarketplace`
   does the same sum before offering capacity to a new request
   (`node/node.go:1332-1344`). A dead VM's resources stay subtracted
   from the provider's advertised capacity, so new leases are refused
   with `insufficient resources` and new requests get no offer.
2. Counts. `activeLeaseCount` is just `len(n.VMManager.List())`
   (`node/node.go:1429-1434`), so the provider's own active-lease
   number stays wrong for the whole window.
3. Reachability. `DialSSH` dials the recorded port
   (`lima_manager.go:182-195`, `qemu_manager.go:298-310`), which is
   closed, so tunnels and the SSH gateway fail for a VM the node
   reports as running. `GET /vms` reports it running too.

The node has no path that notices. `cleanupOrphanedVMs`
(`node/node.go:1773-1794`) only tears down a VM when its lease record
exists and is terminal; the lease here is `Accepted`, not terminal, so
the phantom is skipped every 10 seconds. Recovery happens only at
settle: `trySettleExpiredLeases` calls `settleLease`, `finishSettle`
calls `teardownVM`, and `Teardown` deletes the map entry even though
the process is already gone (its kill failure is logged and ignored).
If the provider misses the one hour settle grace window, the phantom
persists until consumer force-settle or archive, which at maximum lease
duration is 365 days plus 85 minutes.

The trigger needs no privilege beyond what the lease already grants.
The tenant has root inside the guest by design, and powering the guest
off (`poweroff`, `shutdown -h now`) is a routine tenant action, not an
exploit. A guest kernel panic, a host OOM kill, or an admin killing the
instance all produce the same phantom through the same missing check.
Renewal extends the window: `RenewLease` (`node/lease_renew.go:10-86`)
checks lease state, the provider certificate, and the consumer balance,
but never checks whether the VM is alive, so a dead lease can be
renewed and its phantom charge extended indefinitely (code read, not
exercised in the PoC).

## Proof of concept

PoC record: `~/workspace/xe-audit/poc-round11-deadvm/poc_round11_deadvm_test.go`.
One test, run twice against HEAD `02e9641` with Go 1.25.0
(`go test ./vm -run 'TestDeadVM' -count=1 -v`, 0.33s and 0.42s, PASS
both times). The test file was copied into `~/workspace/xe/vm/` for the
runs and deleted afterwards; the repo is clean.

The test drives the REAL `LimaManager` with a fake `limactl` shim (same
pattern as the Round 10 credential-mode PoC). The shim plays the ground
truth an operator sees: after the simulated guest poweroff it reports
the instance `Stopped` via `limactl list`.

1. Provision a VM through the real manager (fake `limactl` answering
   `--version`, `create`, `start`, and `list` with a real listening TCP
   port as the guest SSH port). Provision succeeds.
2. Control, guest alive: `Get` returns `running`, `List` has 1 entry,
   `DialSSH` succeeds.
3. Guest dies: close the listener (the guest SSH endpoint is gone) and
   flip the shim so `limactl list` reports the instance `Stopped`.
   Ground truth verified in-test: the shim output contains
   `"status":"Stopped"`.
4. Defect, all asserted: `Get` still returns status `running` with no
   error; `List` still returns 1 entry with the dead VM's full
   resources (1 vCPU, 1024 MB, 10 GB); the node capacity sum over
   `List()` still charges 1/1024/10; `DialSSH` fails with connection
   refused; repeated reads stay stale (no background reaper).
5. Recovery bound, asserted: `Teardown` on the dead entry succeeds and
   `List` becomes empty, confirming the phantom clears at settle time.

The QEMU path is established by code read, not execution: no GPU is
bound on this machine, and `QEMUManager.Get`/`List`/`cleanOrphans`
have the identical map-only shape (cited above). The Lima execution
proves the shared defect at the manager layer; the QEMU manager cannot
behave differently, because it never consults the qemu process either.

Reproduce:

```
cp ~/workspace/xe-audit/poc-round11-deadvm/poc_round11_deadvm_test.go ~/workspace/xe/vm/
cd ~/workspace/xe && go test ./vm -run 'TestDeadVM' -count=1 -v
rm ~/workspace/xe/vm/poc_round11_deadvm_test.go
```

## Impact

A tenant powering off their own VM, a routine action, wedges the
provider's capacity accounting until the lease settles. The concrete
harms, all proven in the PoC except where marked:

- Provider capacity denial. New leases are refused and new marketplace
  requests get no offer for the dead VM's share of capacity. The wedge
  is total when the dead lease took a large share of a small provider
  (for example a 1 vCPU provider whose only VM dies), and partial
  otherwise. Normal-case duration is the remaining lease term plus up
  to the 1 hour settle grace; renewal extends it (code read), and a
  missed settle window extends it to force-settle or archive.
- Phantom reporting. `GetVM` and `GET /vms` report a running VM that
  does not exist, and `activeLeaseCount` overstates live leases, so the
  operator's view of their own fleet is wrong for the whole window.
- Broken access. Tunnels and the SSH gateway dial a closed port for a
  lease the node believes is live, so the consumer gets connection
  refused with no signal that the guest is gone rather than the network
  being down.

This is bounded at Medium, not High. No funds are lost or stolen: settle
is time based, so the provider is still paid and the consumer escrow
still settles on schedule. The provider loses resale of idle capacity,
not the lease payment. The phantom self-heals at settle, and a process
restart clears the map (at the cost XE-0114 documents: restart destroys
live VMs, so restart is not a usable remedy in production). The QEMU
half is code-read only.

## Why this is not XE-0114

XE-0114 (triaging, Medium) is the opposite direction of the same map.
It reports that manager construction reaps LIVE VMs: `cleanOrphans`
runs at startup and destroys instances backing Accepted leases, and
nothing re-provisions them. R11-D1 reports that NOTHING reaps a DEAD
VM mid-run: `cleanOrphans` runs only at construction, and `Get`/`List`
never check liveness afterwards. Different trigger (routine provider
restart versus routine tenant poweroff), different function
(construction-time `cleanOrphans` versus read-time `Get`/`List`),
different symptom (live service destroyed versus dead VM counted
live), different fix (reconcile before reaping at startup versus check
liveness on read or reap periodically). XE-0114's full body (5,918
characters, read in full) contains zero mentions of `Get`, `List`,
liveness, poweroff, or a dead guest, and its proposed fix (reconcile
at construction) does not touch the mid-run staleness at all. Fixing
XE-0114 would not fix R11-D1, and fixing R11-D1 would not fix XE-0114.

## Why this is not XE-0615

XE-0615 (closed, Medium) reports that a VM whose lease record was
DELETED is never torn down: `cleanupOrphanedVMs` skips it because
`GetLease` returns nil, so a live guest runs forever and its capacity
is permanently charged. R11-D1 is the mirror image: the lease record
EXISTS and is `Accepted`, the guest is DEAD, and the map entry is kept.
Different trigger (branch unwind deleting the lease record versus
guest poweroff), different state (live VM with no lease versus dead VM
with a live lease), different fix (tear down VMs with missing leases
versus detect dead guests). XE-0615's fix would not change R11-D1 at
all: the lease record is present, so its `cleanupOrphanedVMs` path
still skips the phantom. XE-0615's full body (27,907 characters, read
in full) never mentions a dead guest, a poweroff, or `Get`/`List`
liveness; its capacity discussion is about a live orphan consuming
real capacity, not a phantom consuming accounted capacity.

## Why this is not XE-1053

XE-1053 (closed, High) covers three VM lifecycle gaps, and item 3 is
the closest: a VM orphaned when `BlockLeaseAccept` or `BlockLease` is
unwound by a branch swap, with `cleanupOrphanedVMs` skipping it and
`autoAcceptLease` refusing to re-accept it. R11-D1 shares no trigger
with that item: no swap, no unwind, no missing lease. The lease here
is `Accepted` throughout, the VM is dead, and the defect is in the
managers' read path, not in the node settle or accept paths. XE-1053's
proposed remediation (tear down VMs for missing, terminal, expired, or
`Created` leases) does not cover an `Accepted` lease whose guest died,
so it would leave R11-D1 exactly as it is. XE-1053's full body (5,933
characters, read in full) mentions `Get` and `List` once each, only in
the context of the unwind skip, never as a liveness defect. Items 1
and 2 (post-grace retention of a live VM, `finishSettle` early return)
are about live VMs that should have been torn down; R11-D1 is about a
dead VM that should have been noticed.

## Why this is not XE-1438

XE-1438 (triaging, High) reports four provisioning-time flaws,
including QEMU premature SLIRP readiness: `waitForSSHPort` checks only
TCP connectability, so `Provision` reports success while the guest is
still booting. That is a check that is too weak AT PROVISION TIME.
R11-D1 is the absence of any check AFTER provision time. Different
phase, different function (`waitForSSHPort` versus `Get`/`List`),
different fix (verify an SSH banner at provision versus verify the
guest is alive on read or on a reaper tick). XE-1438's full body (5,360
characters, read in full) mentions `Get`/`List` only in its item 4,
about the provisioning mutex blocking those calls, never about their
return values going stale. Its `DialSSH` mentions are about tunnel
freezing during provision, not about dialing a dead guest.

## Why this is not XE-0119

XE-0119 (triaging, Medium) reports that declared resources are clamped
up at provision time while capacity accounting only sees the declared
numbers, so a live guest consumes more host disk and RAM than it is
charged for. R11-D1 is about a guest consuming NOTHING while still
being charged its full declared resources. The accounting error points
the other way, the trigger is different (zero-dimension lease versus
guest poweroff), and the fix is different (record effective resources
versus detect dead guests). XE-0119's full body (5,920 characters, read
in full) never mentions a dead, stopped, or powered-off VM.

## Why this is not XE-0678

XE-0678 (closed, High) is the exact mirror image at the other end of
the lifecycle: `Teardown` deletes the map entry even when the kill
fails, so a LIVE VM becomes untracked and keeps running. R11-D1 is a
DEAD VM that stays tracked. The two defects are compatible and
independent: fixing XE-0678 (verify termination before removing from
the map) does not add any liveness check to `Get`/`List`, and fixing
R11-D1 (check liveness) does not change `Teardown` failure handling.
XE-0678's full body (658 characters, read in full) is entirely about
the teardown path.

## Gates (BountyForge, Al-Mizaan, triage)

TRIGGER: pass. Any tenant can trigger it with a routine action on their
own VM (poweroff from inside the guest), no privilege, no malformed
input, no victim action beyond the provider's ordinary operation, and
no key or funds beyond the lease itself. Host-side triggers (OOM kill,
admin kill, guest panic) produce the same phantom. IMPACT: pass with
bounds. The loss is quantified (the dead VM's full declared resources
charged until settle; new leases refused; `/vms` wrong; tunnels fail)
and demonstrated end to end in the PoC at the real manager layer; it
is bounded at Medium because no funds move, settle still pays the
provider, and the phantom self-heals at settle. Al-Mizaan G1 (code read
literally) pass, G2 (complete chain: guest death to stale `Get`/`List`
to capacity denial, proven in the PoC) pass, G3 (trigger is an ordinary
unprivileged tenant, not an admin) pass, G4 (invariant breached: a
manager reporting a VM `running` must have a live guest behind it, and
capacity accounting must reflect live guests) pass, G5 (design intent:
`cleanOrphans` exists precisely to reap dead instances, which shows
the design intends the registry to track live guests; it just only
runs at construction) pass, G6 (impact quantified, bounds stated,
recovery paths stated) pass, G7 (PoC reproduces twice, third-party
verifiable) pass. Triage Q1 pass (exact reproduction in the PoC), Q2
pass (desk precedent accepts Medium for VM lifecycle availability
defects of this shape; XE-0114 Medium and XE-0119 Medium are the
nearest precedents), Q3 pass (xe repo, `vm` plus `node` capacity
consumers), Q4 pass (no privilege needed), Q5 pass with the six
neighbours distinguished above (shared theme is VM lifecycle and
capacity accounting; each neighbour is a different mechanism, trigger,
and fix), Q6 pass (impact proven at the manager layer and traced to
the node capacity loops, not just a code path), Q7 pass (not a
never-submit class). Pre-severity gate for Medium: full chain validated
to attacker-attainable impact; the tenant walks away having wedged the
provider's capacity with a routine action; reproduced twice; no gating
check remains (no liveness check exists to gate on); desk precedent
accepts Medium for this class. Honest downside, recorded: a skeptical
triager could read this as Minor rather than Medium, because the full
wedge needs tight capacity or a large dead lease, the phantom
self-heals at settle, a restart clears it, and no funds are at risk.
The Medium claim rests on the trigger being a routine tenant action
combined with silent corruption of the provider's capacity, counts,
reporting, and tunnel reachability until settle.

## Suggested fix

Check liveness where the registry is read, or reap on a tick, for
example: `Get`/`List` verify the guest is alive (Lima: `limactl list`
status; QEMU: pid alive via `kill -0` plus SSH port reachable) and drop
or mark entries that fail; or run the existing `cleanOrphans` logic on
the settle loop tick and reconcile `m.vms` against it, so a dead guest
stops charging capacity within seconds instead of at settle. Either
fix must keep XE-0114's direction in mind: reconcile, do not blindly
reap, so live VMs are never destroyed by the new check.

## Duplicate check

Desk: 549 tickets at check time (9 Nov 2026). Title sweep over all 549
titles for zombie, liveness, dead vm, guest, poweroff, power off,
shutdown, process died, process exits, stopped, stale vm, phantom,
qemu exits, lima stop, reap, health check: no title names this defect.
Full bodies read via `GET https://bounty.xe.network/v1/tickets/<id>`:
XE-0114 (5,918 chars), XE-1438 (5,360 chars), XE-0678 (658 chars),
XE-0119 (5,920 chars), XE-0920 (4,781 chars), XE-0041 (7,747 chars),
XE-1053 (5,933 chars), XE-0615 (27,907 chars). Each is distinguished
in the sections above. No other ticket names `cleanOrphans` (XE-0114's
own duplicate check found zero matches for it, and this round's sweep
agrees), and no ticket names a dead guest still reported running.

### Thread

**Joseph Denne**team2026-11-09 10:20 UTCdesk

Thanks for the report. We have confirmed the reading against the current tree and it is being handled. The assessment and any award follow the fix.
