VM manager holds its lock across the whole multi-minute boot: one lease request stalls the provider's entire VM plane
Report
Title: VM manager holds its lock across the whole multi-minute boot: one lease request stalls the provider's entire VM plane
Claim
LimaManager.Provision holds the manager-wide sync.RWMutex write lock for the entire duration of the VM boot — external process execution plus waits, up to ~9 minutes worst case — so while ANY provision is in flight, every other VM-plane operation on that provider blocks: DialSSH (the SSH-gateway backend dial, whose 30-second handshake deadline fails), Get/List (public API /vms and the auto-accept capacity check), Teardown (settle-loop cleanup), and any further Provision. The trigger is a signed lease request to an auto-accepting provider, issued before any lease_accept block or provider stake exists — provisioning runs BEFORE the accept is committed — and a failing provision holds the lock for the full multi-minute timeout while the requester's escrow is refundable, so one minimum escrow recycled through cancel-and-reopen sustains the stall indefinitely. We claim Medium: availability of a shipped provider component with a cheap remote trigger, hitting other tenants' SSH access — not a crash, not funds, not a leak.
Code (repos/xe, pinned HEAD 9787859)
vm/lima_manager.go:95-96(Provision):m.mu.Lock(); defer m.mu.Unlock()at entry, thenrunLimactlWithTimeout(2*time.Minute, "create", ...)(:120),runLimactlWithTimeout(5*time.Minute, "start", ...)(:126),waitForSSHPort(name, 2*time.Minute)(:133) — only thenm.vms[leaseHash] = ...(:145-151). Worst-case hold ≈ 9 minutes; failure paths add diagnostics +stop/deleteinside the same deferred unlock. A normal Lima start is tens of seconds.- Blocked operations, all on the same
mu:DialSSH(RLock, :183),Get(RLock, :200),List(RLock, :217),Teardown(Lock, :165). net/tunnel.go:22—tunnelHandshakeDeadline = 30 * time.Second; the tunnel handler callsvalidator.DialSSH(:89) afterValidateTunnelLease;node/node.go:2195(Node.DialSSH) forwards toVMManager.DialSSH. A tunnel-open attempt therefore fails its deadline while its handler goroutine stays stuck inDialSSHuntil the lock frees.node/vm.go:125,142(GetVMs,GetVM) feed publicGET /vms{,/lease}(api/handler.go:200-201) and the auto-accept capacity sum (node/node.go:1523,VMManager.List());node/vm.go:105(teardownVM) is called from the settle loop (node.go:2039).- Trigger path, no payment before the hold: a consumer's signed lease block →
handleIncomingspawnsautoAcceptLease(node.go:725-729, per-hashbeginAcceptguard) → policy + attestation gathering →provisionVM(node.go:1554) OUTSIDEblockCreateMu→VMManager.Provision. Thelease_acceptblock (and the provider's XUSD stake) is committed only AFTER provisioning succeeds (node.go:1578+). node/node.go:1460-1613(autoAcceptLease):beginAcceptdedupes the same hash only;acceptPolicy.AllowchecksactiveLeaseCount()=len(VMManager.List())— in-flight provisions do NOT count;acceptSchedmarks failed leases done (node.go:1726-1740), so there is no auto-retry of the same hash — each hold window needs a fresh distinct lease_open.core/ledger.go:1506-1600(validateAndAddLease): the lease_open requiresb.Amount == LeaseCost(...),b.Amount <= consumer XUSD balance,b.Balance == oldBal - b.Amount, and creates aPendingSendescrow.core/ledger.go:1807+(validateAndAddLeaseCancel): the consumer cancels aLeaseCreatedlease and the escrow is refunded in full (expectedBal = oldBal + leaseBlock.Amount).Provisionnever re-checks lease state mid-run (theGetcheck happens only afterprovisionVMreturns), so a cancel issued during provisioning does not stop the hold.- QEMU shape only, NOT a live path:
vm/qemu_manager.go:145-146has the identicalLock+defer Unlockstructure withwaitForQEMUPID(60s)+waitForSSHPort(2m), butNewQEMUManagerhas no callers in the shipped node — the provider path wiresLimaManager(node.go:534) orMockManager(XE_VM_MOCK=1, :523). Mock/Dev managers take the same lock but do in-memory-only work and return immediately (vm/mock.go:28,vm/dev_target.go:33).
Reproduced?
Yes — Lima leg, local only, executed 4 times by the finding lane plus 2 clean-scratch re-runs at independent gate review (all exit 0; gate runs logged in findings/_shared/gate-runs/sweep10/run1|run2/). Harness: real LimaManager + real sync.RWMutex, only limactl stubbed by a fake script (5 s sleep on create, 5 s on start, list reporting the VM with a live TCP listener as its SSH port). Overlay method, repo git-clean:
- Gate run 1:
Get(unrelated lease) blocked 9.008 s;DialSSH(provisioning lease) blocked 9.009 s, then succeeded;Provisionitself ~10 s;Listafterwards instant, 1 entry. - Gate run 2:
Getblocked 9.011 s;DialSSHblocked 9.012 s; same outcome. - Lane runs:
Get/DialSSHblocked ~9.09 s in both logged runs. - QEMU leg NOT executed (the manager is not wired by the node and needs KVM/QEMU/VFIO hardware) — proven by direct code proof of the identical structure. The full trigger pipeline (lease_open → autoAccept → provision → lock, cancel-recycle re-queue) is verified by first-hand code reading of the paths above, NOT executed end-to-end against a live node.
Impact Provider VM-plane denial of service, remotely triggerable by an XUSD-holding account against an auto-accepting provider:
- Existing tenants cannot open SSH tunnels to their running VMs while a provision is in flight — the gateway's
DialSSHblocks and the 30 s handshake deadline fails the attempt; a stream of lease requests keeps the plane down indefinitely. - API
/vmshangs; the auto-accept capacity check stalls (which serialises further accepts behind the same lock). - Settle-loop
Teardownstalls, so settled VMs keep running past settlement. - Each request costs the requester one minimum escrow — 17 µXUSD for a (0 vCPU, 0 MB, 1 GB, 60 s) lease, 584 µXUSD for (1 vCPU, 512 MB, 5 GB, 60 s), both at multiplier 1000 — and the escrow is refunded in full on
lease_cancel, so the same float recycles through create → slow/failing provision → cancel → refund → repeat. A failing provision (e.g.limactl start5-minute timeout) holds the lock for the full timeout on every attempt. - No crash, no fund movement, no data leak by itself; the effect is availability of a shipped component (provider VM hosting + SSH gateway backend).
Bounds (honest)
- Requires an auto-accepting provider running the Lima manager. A provider with auto-accept off, or Mock/Dev managers, is unaffected. The QEMU leg is latent code, not a live path.
- The trigger is NOT free for literally any account: the requester must hold XUSD ≥ the minimum lease escrow (17–584 µXUSD as above) and present a valid provider certificate hash (
validateAndAddLeaserequires a certificate belonging to the destination provider). XUSD is operator-minted, so the premise is an XUSD-holding account — any existing or potential customer — not an arbitrary new account. Timekeeper attestations are gathered before provisioning on a live provider (provider mode requiressys.timekeepers); they are a routine precondition, not a blocker. - A successful provision boots a real VM (the provider's normal business cost) and the requester then holds a real lease that settles later — the zero-net-cost, indefinitely-repeatable leg is the failing/slow provision, which still holds the lock for the full timeout.
- Normal Lima starts take tens of seconds, which still exceeds the 30 s tunnel deadline for concurrent tunnel attempts; the multi-minute hold needs a slow or failing boot (timeouts 2 + 5 + 2 minutes).
- The cancel-recycle + re-queue pipeline (cancel during provisioning, next lease parking at
List()until the lock frees) is code-verified, not executed end-to-end; the 5–9 minute timeout induction was not executed (proven hold = boot duration; 5–9 min is the code ceiling from the timeouts). Teardownlikewise holds the lock acrosslimactl stop/delete(lima_manager.go:165+) — shorter holds, same shape, noted as an amplifier, not separately claimed.- No gossip/sync transport run end-to-end; the defect is the lock scope in
Provision, which every ingress path funnels through viaautoAcceptLease→provisionVM.
Already known?
No match. Dedup 2026-11-05 (REGISTER §1/§2/§3, sweep ledgers, ticket/issue greps for lima, qemu, provision, DialSSH, manager.*lock, mutex; bodies read in full at gate):
- XE-0662 (reporter 242, claimed High, NEW):
LimaManager.vmNameslicesleaseHash[:12]without a length check → panic on short leaseHash. Input-validation panic at the same function; different defect, different fix, and its premise is weak (leaseHash comes from chain state, always 64 chars). Not the lock scope. - XE-0663 (reporter 242, claimed High, NEW): no maximum resource bounds (minimums only) → host exhaustion via huge requests. Resource-accounting claim; the lock is never mentioned; its fix (configurable caps) does not touch the critical section.
- XE-0664 (reporter 242, claimed High, NEW):
ProvisiontakesleaseHash/accessPubKeywith no cryptographic binding → "lease theft via key substitution". Premise-weak (Provision is an internal call; values come from the lease block) and a different mechanism entirely. - XE-0119 (hayokakoweda75, claimed Medium, NEW): declared-vs-clamped resource accounting — minimum leases priced/counted as ~nothing while guests are clamped to 1 vCPU/512 MB/5 GB (capacity/disk exhaustion). Its thread addendum separately claims the
MaxConcurrentcheck-then-act (the cap is evaluated before provisioning, in-flight provisions don't count, so a burst of distinct lease_create blocks all pass). The burst-admission fact is shared with this report's stream leg, BUT: this report's core effect — ONE provision blocking other tenants'DialSSHfor up to 9 minutes — appears nowhere in XE-0119, and the fixes are disjoint both directions (counting in-flight accepts inMaxConcurrentdoes not narrow theProvisioncritical section; narrowing it does not fix XE-0119's declared-vs-effective accounting). - XE-0048 (Accepted, High): pre-auth SSH-gateway slot exhaustion (100 silent TCP connections, no handshake deadline,
connSem). Different mechanism (gateway accept loop, no credential, no lease), different fix. - RD-3 = XE-0309 (ours, filed): post-auth unlimited
direct-tcpipchannels on one gateway connection (no channel counting). Different mechanism (gateway channel loop), different fix. - XE-0259 (hayokakoweda75, NEW): Teardown reports success while
stop/delete/killfailed, orphaning a live VM/GPU. Error-swallowing inTeardown, not lock scope. - Fold risk disclosed: triage may call this a performance / locking-design issue (Minor) rather than a security DoS, or note that provisioning is "expected to be serialised"; the standalone delta is the remotely-triggerable, sustained, multi-minute stall of the whole VM plane (including other tenants' SSH access) from minimum-escrow lease requests, which no existing claim covers.
- History: this lock-hold observation was logged below-bar by three earlier sweep runs (2026-11-03, 2026-11-04, 2026-11-05) on the premise the trigger was paid/quorum-gated and the effect provider-local liveness only. The promotion to a candidate rests on the pre-payment trigger verified above: provisioning runs before the lease_accept commit, and the failing-provision leg holds the lock for the full timeout while the escrow is refundable via cancel.
Fix (suggested)
Narrow the critical section: hold mu only around the map insert/lookup/delete. Do the slow external work (limactl exec, PID/SSH waits) OUTSIDE the lock, with an in-flight placeholder entry (e.g. a per-lease provisioning state, or a reserved entry marked "provisioning" that Get/List report and DialSSH/Teardown can observe or wait on with a timeout) so concurrent operations fail fast or observe status instead of blocking for minutes. Alternatively a per-lease lock plus a separate RWMutex for the map. Teardown should likewise not hold the lock across process kills / sleeps / GPU resets.
Thread
Run evidence — SWEEP-10 (lane + independent verification + hostile gate)
Harness: findings/sweep/poc/vm_lock/sweep_vm_lock_test.go (sha256 a687a18c988d58111ca7a060ce9f00f3d4d5851b63c1f2c7ded8ff6da0b4ee0f) + fake-limactl.sh (sha256 de447514021b146d5d6bad4ae11bf20598c395fe622b2e25cf08861b2b73578d). Real LimaManager + real sync.RWMutex; only limactl stubbed (5 s sleep on create, 5 s on start, list reporting the VM with a live TCP listener as its SSH port). Overlay method, repo xe @9787859 git-clean after every run. Go 1.25.0, GOPROXY=off, workspace GOCACHE/GOTMPDIR.
Lane runs (logged):
- Run 1 (findings/sweep/poc/vm_lock/run-1.log): Get blocked 9.097 s; DialSSH blocked 9.098 s, then succeeded; Provision ~10 s; List afterwards instant, 1 entry.
- Run 2 (run-2.log): Get blocked 9.087 s; DialSSH blocked 9.087 s; same outcome.
- Two further ad-hoc lane runs (unlogged): same timings.
Independent AiSOC verification (SWEEP10-AISOC-VERIFY.md):
- Harness re-run x2 from clean scratch: Get/DialSSH blocked 9.015 s / 9.037 s.
- Verdict: CONFIRMED WITH BOUNDS — mechanism real; candidate's "free / any chain account" framing corrected (lease_open requires XUSD >= LeaseCost, escrowed at open; attacker class = existing XUSD holders); cancel refunds in full so one minimal float recycles indefinitely; failed provisions not auto-retried (new lease hash needed per hold); cross-tenant leg real.
Hostile gate re-runs (GATE-SWEEP10.md), clean scratch findings/_shared/gate-runs/sweep10/run1|run2/:
- Gate run 1 (gate-run1.log): Get blocked 9.008 s; DialSSH blocked 9.009 s; PASS, exit 0.
- Gate run 2 (gate-run2.log): Get blocked 9.011 s; DialSSH blocked 9.012 s; PASS, exit 0.
- Gate code verification (all at pinned HEAD 9787859): lima_manager.go:95-96 lock + 2 m/5 m/2 m timeouts; qemu_manager.go:145-146 same shape — BUT NewQEMUManager has no callers in the shipped node; live provider path is Lima only (node.go:534), so the package claims Lima only; trigger path handleIncoming -> autoAcceptLease -> provisionVM (:1554, outside blockCreateMu) -> accept committed only after provisioning succeeds; validateAndAddLease escrow (17 uXUSD min disk-only / 584 uXUSD min 1vCPU leases at multiplier 1000); validateAndAddLeaseCancel full refund; acceptSched marks failed leases done (no auto-retry).
Load-bearing PASS lines (gate run 1): Get returned after 9.008101714s (err=vm not found for lease ffff...) DialSSH returned after 9.008642274s (err=<nil>) PASS: Get blocked ~10s behind Provision; DialSSH likewise; VM listed after --- PASS: TestSweepVMLockHold (10.02s)
Bounds carried into the package:
- Live path Lima only; QEMU unwired/latent.
- Trigger premise: XUSD-holding account (>=17 uXUSD escrow) + valid provider cert hash; escrow refundable via cancel.
- Cancel-recycle + re-queue pipeline code-verified, not executed end-to-end; 5-9 min timeout induction not executed (proven hold = boot duration).
- No crash, no funds, no leak; availability of one provider's VM plane.
Thanks for the report. We have read it against the code and it is being handled; we will update https://bounty.xe.network/XE-0675 when there is news.