{"id":"XE-0012","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"21","source_url":"https://github.com/xeprotocol/xe/issues/21","reporter_id":8,"title":"Escrow without service is uncostly: lease_settle verifies only elapsed time, returns the stake, and opens before force-settle","area":"leasing-ledger","claimed_tier":"critical","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:14.580124+00:00","updated_at":"2026-11-11T13:35:44.511268+00:00","source_created_at":"2026-10-23T21:12:33+00:00","told_at":"2026-11-10T00:15:53+00:00","status_changed_at":"2026-10-29T14:04:13.648921+00:00","url":"https://bounty.xe.network/XE-0012","body":"\n\n**Severity:** Critical — escrow theft (\"escrow taken without service\"). See \"Honest caveat\".\n**Area:** Compute leasing · `core/ledger.go`, `node/attestation.go`\n**Related:** distinct root cause from #20 (see \"Distinct from #20\").\n\n## Summary\n\n`lease_settle` verifies only that time has passed — a timekeeper attests\n`sha256(lease_hash || timestamp)`, never that the provider delivered compute. A provider can\ntherefore accept a lease, provision nothing, and at expiry settle with a timekeeper-signed\ntimestamp: the consumer's escrow is burned, the provider keeps their stake and mints XE. Because the\nprovider's settle window opens before the consumer's force-settle window, and because settlement\nreturns (rather than forfeits) the stake, this is uncostly and always winnable by the provider.\n\n## Root cause\n\n`validateAndAddLeaseSettle` (`core/ledger.go`) gates settlement exclusively on time:\n\n```go\n// gates: settleTime >= expiry  &&  settleTime <= expiry + LeaseSettleGrace\n// no check that a VM was provisioned, or that any compute was delivered\n```\n\nSettlement's side effects are then unconditional:\n\n- `DeletePendingID = lease hash` — the consumer's escrow pending send is deleted (burned),\n- `AssetCredit = {Account: provider, Asset: \"XUSD\", Amount: lease.Stake}` — the stake is returned,\n- the provider's XE balance is credited the emission (newly minted supply),\n- `reputation.Apply(EventLeaseSettled)` — a positive reputation event.\n\nThe only input a provider must produce is a timekeeper attestation. `canAttest`\n(`node/attestation.go`) returns `nil` for any lease in `Created`/`Accepted` state — it never checks\nthat a VM exists or that work was delivered. `AttestationPayload` is `sha256(leaseHash || timestamp)`:\nit binds a clock reading, not a delivery claim.\n\n## Why the incentives do not protect the consumer\n\nThree independent facts make this a theft, not a theoretical gap:\n\n1. **Stake is returned, not forfeited, on settle.** `lease_force_settle` forfeits the stake, but the\n   provider is the one who settles — and settle refunds `lease.Stake`. A provider loses their stake\n   only if the *consumer* force-settles, which the provider preempts (next point).\n2. **Settle precedes force-settle.** The provider may settle at `expiry`; the consumer's force-settle\n   is eligible only at `expiry + LeaseSettleGrace + LeaseForceSettleGap` (default +1h25m). By the time\n   the consumer can act, the escrow is already burned.\n3. **Reputation improves on settle.** Settling records `EventLeaseSettled` (positive); the\n   \"unfulfilled\" reputation path only fires on force-settle, which the provider avoids.\n\nNet: settle-without-delivery returns the stake, mints XE, raises the provider's reputation, and burns\nthe consumer's escrow — with no downside.\n\n## Impact\n\n- **Who:** every consumer leasing compute from a malicious provider.\n- **Worst case:** a provider accepts leases, delivers nothing, and settles each one at expiry —\n  draining the full escrowed XUSD of every consumer while minting XE and improving its own standing.\n  There is no dispute mechanism (dispute arbitration is \"design stage\" in the README), so consumers\n  have no recourse.\n- This is the programme's own Critical class: \"Leasing: escrow taken without service\".\n\n## Reproduce\n\nA checkout runs the end-to-end lifecycle with no VM provisioned anywhere:\n\n```\n$ go test ./core -run TestAuditZeroCollateralEmission -v\n    audit_e2e_test.go:103: provider BEFORE lease: XE=1 XUSD=0\n    audit_e2e_test.go:129: lease cost = 500 µXUSD\n    audit_e2e_test.go:156: required stake = LeaseStake(500) = 0\n    audit_e2e_test.go:184: provider AFTER accept:  XE=1 XUSD=0\n    audit_e2e_test.go:212: provider FINAL: XE=501 XUSD=0\n    audit_e2e_test.go:213: consumer FINAL: XE=999999 XUSD=999500   ← escrow burned\n    audit_e2e_test.go:221: provider minted 500 µXE emission with ZERO XUSD collateral at risk\n```\n\nThe full test source is pasted in issue #20. The same block sequence demonstrates this claim: the\nprovider provisions no VM, obtains an attestation (`SignAttestation`) that only signs a timestamp,\nand `AddBlock(settleBlock)` succeeds — minting XE and deleting the escrow pending send.\n\n## Distinct from #20\n\n#20 (`LeaseStakeDivisor = 0`) is the collapsed collateral constant. This finding holds even with the\ndivisor restored to `5`: settlement returns the stake (only force-settle forfeits it) and the settle\nwindow precedes force-settle, so a provider whose stake is `cost/5` still settles-without-delivery at\nno net loss. Fixing #20 does not close this.\n\n## Honest caveat (steelman + answer)\n\n- *Steelman:* settlement cannot prove delivery without a proof-of-uptime system, and the README marks\n  \"Proof of uptime 🚧 design stage\". So \"settlement trusts time, not work\" is a known, unfinished piece.\n- *Answer:* the report is not \"the feature is missing\" — it is that the *current ordering and\n  accounting make the gap uncostly and always-winnable*. The stake is returned (not forfeited) on the\n  path the attacker controls, settle opens before force-settle, and settle improves reputation. Those\n  are concrete, separable defects, not merely the absence of a not-yet-built feature.\n\n## Remediation\n\nAny of (in order of preference):\n\n1. Require a delivery/uptime attestation before the stake is returned, and forfeit the stake when it\n   is absent.\n2. Open the consumer's force-settle window at the same instant as the provider's settle window, so a\n   non-delivering provider cannot win the race.\n3. At minimum, do not return `lease.Stake` on settle without a delivery proof, and record a\n   *disputed/unfulfilled* reputation event (not `EventLeaseSettled`) when a settle carries no delivery\n   attestation.","patch_refs":[{"id":116,"repo":"xeprotocol/xe","kind":"pr","ref":"25","title":"fix(core,node): require delivery proof to refund lease stake on settle and open force-settle at expiry","url":"https://github.com/xeprotocol/xe/pull/25","note":"","state":"open","author":"ocakciomursel-pixel","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1580,"source":"github","source_ref":"6755095755","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0012.","created_at":"2026-11-10T00:15:53+00:00"}]}