{"id":"XE-9818","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Provider Resource Oversubscription Race: autoAcceptLease checks acceptPolicy.Allow before blockCreateMu permitting concurrent VM capacity exhaustion","area":"leasing-ledger","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T07:28:47.335930+00:00","updated_at":"2026-11-20T00:33:20.906873+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:20.949232+00:00","status_changed_at":"2026-11-20T00:33:20.920012+00:00","url":"https://bounty.xe.network/XE-9818","body":"## Vulnerability Summary\n\nIn `node/node.go:1460-1535`, `autoAcceptLease(leaseBlock *core.Block)` handles automated acceptance of incoming compute lease blocks for provider nodes.\n\nTo prevent oversubscribing provider hardware (CPU cores, RAM, and disk space), the provider node relies on `n.acceptPolicy.Allow(leaseBlock, n.activeLeaseCount())`:\n```go\nfunc (n *Node) activeLeaseCount() uint64 {\n\tif n.VMManager == nil {\n\t\treturn 0\n\t}\n\treturn uint64(len(n.VMManager.List()))\n}\n```\nIn `node/node.go:1477`:\n```go\n\tif err := n.acceptPolicy.Allow(leaseBlock, n.activeLeaseCount()); err != nil {\n\t\tlog.Printf(\"Auto-accept policy rejected lease %s: %v\", shortHash(leaseBlock.Hash), err)\n\t\treturn\n\t}\n```\n\nNotice the critical concurrency race condition:\n1. `n.acceptPolicy.Allow` is checked **early outside of `n.blockCreateMu`** and before `n.acceptAttestations` (which performs network I/O across timekeeper peers taking hundreds of milliseconds to seconds).\n2. `n.activeLeaseCount()` counts only VMs currently returned by `n.VMManager.List()`.\n3. In-flight lease acceptances (which have passed policy check but have not yet completed block creation and VM provisioning in `n.VMManager.Provision`) are **completely invisible to `n.activeLeaseCount()` and `n.acceptPolicy.Allow`**!\n\n---\n\n## Vulnerable Code Locations\n\n- `node/node.go:1477-1510`:\n  `autoAcceptLease` evaluates `n.acceptPolicy.Allow` using `n.activeLeaseCount()` at line 1477. Then it performs network attestation gathering (`acceptAttestations`) without holding `blockCreateMu`. Multiple concurrent lease requests all read the same un-updated VM count.\n- `node/policy.go:33-45`:\n  `LeaseAcceptPolicy.Allow` enforces `p.MaxActiveLeases > 0 && activeCount >= p.MaxActiveLeases`. Because `activeCount` comes solely from `n.activeLeaseCount()`, concurrent leases bypass `MaxActiveLeases`.\n\n---\n\n## Attack & Failure Scenario\n\n1. A provider configures `MaxActiveLeases = 2` to safely fit within its hardware capacity (e.g. 16 vCPUs total, 8 vCPUs per lease).\n2. A consumer broadcasts 5 simultaneous `BlockLease` requests targeting this provider.\n3. The provider node receives all 5 blocks and spawns 5 concurrent goroutines running `autoAcceptLease`.\n4. All 5 goroutines call `n.activeLeaseCount()`. Since 0 VMs are provisioned yet, all 5 goroutines see `activeCount = 0` and **pass `n.acceptPolicy.Allow`**.\n5. All 5 goroutines gather attestations in parallel and acquire `n.blockCreateMu` sequentially.\n6. The provider commits 5 `BlockLeaseAccept` transactions on-chain, committing 5x XUSD stake.\n7. Subsequently, when the provider attempts to provision VMs for all 5 leases, the host physical server runs out of vCPUs / memory, leading to hypervisor OOM panics, VM launch failures, and subsequent slashing of the provider's reputation and staked XUSD deposits!\n\n---\n\n## Impact\n\n1. **Provider Slashing & Stake Loss**:\n   Providers accept more leases than their physical hardware can support, failing to provision VMs and forfeiting their XUSD stakes via `BlockLeaseForceSettle`.\n2. **Host Node Denial of Service / Crash**:\n   Hypervisors crash or enter kernel OOM states under severe CPU/RAM overcommitment.\n\n---\n\n## Remediation\n\nTrack pending in-flight accepts inside `activeLeaseCount()` or enforce `acceptPolicy.Allow` atomically under `blockCreateMu` accounting for in-flight accepted leases:\n```go\nfunc (n *Node) activeLeaseCount() uint64 {\n\tn.acceptInFlightMu.Lock()\n\tinFlight := uint64(len(n.acceptInFlight))\n\tn.acceptInFlightMu.Unlock()\n\n\tvar vmCount uint64\n\tif n.VMManager != nil {\n\t\tvmCount = uint64(len(n.VMManager.List()))\n\t}\n\treturn vmCount + inFlight\n}\n```","patch_refs":[],"thread":[{"id":13257,"source":"desk","source_ref":"reply:11279","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, 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-9818 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:20.906873+00:00"}]}