{"id":"XE-16757","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"656","source_url":"https://github.com/xeprotocol/xe/issues/656","reporter_id":2920,"title":"[Medium] VM managers hold the global lock during multi-minute provisioning, blocking SSH dialing and teardown for all tenants","area":"leasing-ledger","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0675","tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T05:47:03.684046+00:00","updated_at":"2026-11-22T23:26:16.714048+00:00","source_created_at":"2026-11-17T05:46:04+00:00","told_at":"2026-11-22T23:26:16.728183+00:00","status_changed_at":"2026-11-22T23:26:16.720377+00:00","url":"https://bounty.xe.network/XE-16757","body":"## Summary\n`LimaManager.Provision` and `QEMUManager.Provision` hold the manager-wide write lock for their entire duration -- up to ~9 min for Lima (2 min create + 5 min start + 2 min SSH wait) -- while running blocking subprocess calls. During that window every other VM operation blocks: `DialSSH` (tunnel handler -> SSH access for *all* tenants stalls), `Teardown` (settle/cancel cleanup stalls), `List`/`Get` (capacity checks, API `/vms` stall). Provisions serialize on the same lock, so chained leases sustain the blockage.\n\n## Root Cause\n- `vm/lima_manager.go:94-96`: `Provision` takes `m.mu.Lock()`, `defer m.mu.Unlock()` at the top, then runs `runLimactlWithTimeout(2min, \"create\")`, `runLimactlWithTimeout(5min, \"start\")`, `waitForSSHPort(name, 2min)`.\n- `vm/qemu_manager.go:144-146`: same pattern.\n- `vm/lima_manager.go:182-185` (`DialSSH` takes `RLock`), `:164-166` (`Teardown` takes `Lock`) -- both block while a provision holds the write lock.\n\n## Impact\n- Remote, cheap trigger: `provisionVM` (`node/vm.go:74`) <- `autoAcceptLease` <- gossiped `BlockLease` -- any user creating a lease to the provider triggers it. `MaxConcurrent` defaults to 0 = \"bounded only by resource capacity\" (`cmd/xe/main.go:1311`), so with minimum-size leases (1 vCPU/512 MB/5 GB) an attacker can queue many provisions; escrow is refundable via cancel.\n- All tenants' SSH access stalls (tunnel handler calls `DialSSH`), teardown stalls (settle/cancel cleanup), capacity checks stall.\n\n## Verification (executed PoC)\nFake `limactl` that sleeps 30 s in `create`:\n```\nList() BLOCKED for >15s while a provision is in flight (lock held)\nGet() BLOCKED for >10s while a provision is in flight (lock held)\nprovision finished, err: get ssh port: ssh port not ready after 2m0s\n```\nAudited at HEAD `8cc209d` (testnet-0006).\n\n## Suggested fix\nHold the lock only for map mutations; do the long subprocess work outside it (e.g. reserve the lease hash, release the lock, provision, re-lock to register). Add a provisioning-state entry so concurrent `Provision` for the same lease still dedups.","patch_refs":[],"thread":[{"id":18870,"source":"desk","source_ref":"reply:16547","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0675, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16757 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:16.714048+00:00"}]}