{"id":"XE-0104","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"162","source_url":"https://github.com/xeprotocol/xe/issues/162","reporter_id":35,"title":"node: `LeaseAcceptPolicy` is only consulted for `lease_open` — a unilateral `lease_renew` bypasses the provider's duration and cost caps","area":"leasing-ledger","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":null,"status":"triaging","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:27.510071+00:00","updated_at":"2026-11-10T00:11:53.117939+00:00","source_created_at":"2026-10-29T02:54:42+00:00","told_at":"2026-11-08T20:32:51+00:00","status_changed_at":"2026-11-08T20:32:31.757935+00:00","url":"https://bounty.xe.network/XE-0104","body":"**Suggested tier:** Medium (2,500 XE) — an accepted lease can be extended 8,760× past the\nprovider's own policy limits without the provider's consent.\n**Repo pin:** `978785929bc17a2f4ab30c383e5fc9cf4d634512` (testnet-0005)\n**Area:** `node/policy.go`, `node/node.go` (renewal path), `core/lease_renew.go`\n\n## Summary\n\nProviders configure `LeaseAcceptPolicy` — `MaxDurationSec`, `MaxCostXUSD`, resource ceilings —\nand the node applies it in exactly one place: `acceptPolicy.Allow` is called only from\n`autoAcceptLease` (`node/node.go:1477`), which only runs for a `BlockLease`\n(`node/node.go:721`). `lease_renew` never consults it: `validateAndAddLeaseRenew` caps the\ncumulative duration at `LeaseMaxDuration` (1 year) and recomputes the price, but knows nothing\nabout the provider's policy. The consumer signs renewals unilaterally; the provider's node has\nno say.\n\nSo a 1-hour lease accepted under a 1-hour policy can be walked to 31,536,000 s and past the\nprovider's `MaxCostXUSD` one renewal at a time, while the same commitment as a fresh\n`lease_open` would be refused outright.\n\n## Where\n\n`node/node.go:1477` — the only caller in the tree (`grep -rn 'acceptPolicy.Allow'` → one hit):\n\n```go\nif !n.acceptPolicy.Allow(leaseBlock, core.Now()) {\n    log.Printf(\"Auto-accept policy rejected lease %s: %v\", shortHash(leaseBlock.Hash), err)\n    return\n}\n```\n\n`core/lease_renew.go:39-52` — the renewal path only bounds duration against the protocol cap:\n\n```go\nnewEffective, ok := safeAdd(lease.EffectiveDurationSecs(), b.Duration)\nif !ok || newEffective > LeaseMaxDuration {\n    return fmt.Errorf(\"lease_renew: cumulative duration %d + %d exceeds max %d\",\n        lease.EffectiveDurationSecs(), b.Duration, LeaseMaxDuration)\n}\n```\n\nand `node/policy.go` is not referenced from it at all.\n\n## Reproduction\n\nFull lease lifecycle against the real ledger, with a provider policy of\n`MaxDurationSec = 3600`, `MaxCostXUSD = 500000000`:\n\n```bash\ncd /root/xe-audit/poc-D\nnice -n 15 taskset -c 0-1 go test ./auditpoc/ -run TestD3 -count=1 -v\n```\n\nObserved (`poc-D/observed-D.log`):\n\n```\nd3_policy_renew_test.go:49:  policy allows the 1h lease (cost 80000 micro-XUSD)\nd3_policy_renew_test.go:62:  control: the same policy rejects a lease_open for 31536000s (700800000 micro-XUSD): duration 31536000s > policy max 3600s\nd3_policy_renew_test.go:94:  renewal accepted: +31532400s for 700720000 micro-XUSD (701 XUSD) — over the policy by 8760× in duration and 1.40× in price\nd3_policy_renew_test.go:112: lease now expires 8759h0m0s after the point where the provider's policy would have ended it\nd3_policy_renew_test.go:115: RESULT: LeaseAcceptPolicy.MaxDurationSec=3600 and MaxCostXUSD=500000000 were enforced on lease_open and bypassed by a unilateral lease_renew to 31536000s / 700720000 micro-XUSD\n```\n\nThe control line is the point: the identical commitment is **rejected** as a `lease_open` by the\nprovider's own policy and **accepted** as a renewal.\n\n## Impact\n\n- The provider's advertised terms (`MaxDurationSec`, `MaxCostXUSD`, resource caps) are one-shot:\n  they bind the initial lease and then stop mattering. A provider that prices capacity hourly and\n  caps at one hour is committed for a year at that price.\n- The consumer needs no cooperation from the provider: `lease_renew` is consumer-signed, and the\n  renewal is admitted by the ledger as long as the attestations, certificate and price check out.\n- Practical consequence for providers: capacity sold on the assumption of hourly re-pricing is\n  rented for a year, and the price is pinned to the certificate multiplier in force at the\n  renewal — the same class of commitment risk #97 describes, but for *size* rather than *price*.\n\n## Why this is not a duplicate of #97 / #105 / #120 / #93\n\n- **#97 / #105 / #120** fix *which certificate* a renewal may use (the provider's *current* one)\n  and thus the price multiplier. They do not bound the duration or total cost a renewal may\n  commit to; even with the current certificate, the 1-year extension in the PoC passes.\n- **#93 / #110 / #152** are about the signature threshold on `lease_accept`.\n- **#21 / #90** are about settling without service.\n\nThe policy-compulsion gap is not covered by any of them.\n\n## Suggested fix\n\n1. Call `acceptPolicy.Allow` for renewals too, evaluating the *projected* lease\n   (`EffectiveDurationSecs()+b.Duration`, `Cost+ΣrenewalCost+b.Amount`) rather than the original\n   block.\n2. If the policy rejects a renewal, the provider's node should not attest it (the attestation is\n   the provider's consent point — `validateAndAddLeaseRenew` already requires timekeeper\n   attestations gathered by the provider's node).\n3. Surface `MaxDurationSec` / `MaxCostXUSD` in `GET /providers` so a renter can see the caps the\n   provider will actually enforce.\n\n## Notes\n\nSource-level only; no traffic to testnet-0005. PoC in `/root/xe-audit/poc-D/auditpoc/d3_policy_renew_test.go`.","patch_refs":[{"id":177,"repo":"xeprotocol/xe","kind":"pr","ref":"180","title":"core, node: enforce provider lease duration and cost caps on renewals via committed caps (#162)","url":"https://github.com/xeprotocol/xe/pull/180","note":"","state":"open","author":"fangjian-bit","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"},{"id":539,"repo":"xeprotocol/xe","kind":"pr","ref":"346","title":"fix(node): enforce LeaseAcceptPolicy duration and cost caps on renewals (#162)","url":"https://github.com/xeprotocol/xe/pull/346","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-11-10T22:05:53.697734+00:00"}],"thread":[{"id":49,"source":"github","source_ref":"6492383685","author":"fangjian-bit","team":false,"body":"Submitted architectural fix and comprehensive regression test suite in #180.\n\nResolves the unilateral renewal bypass by introducing consensus-level committed lease caps (`FeatureLeaseCaps`), binding provider duration/cost policies into `lease_accept` caps, enforcing immutable `WithinRenewalCaps` verification in `validateAndAddLeaseRenew`, and hardening VM orphan cleanup. Verified with full unit tests and builds in native Linux Go 1.27.3.","created_at":"2026-10-29T08:59:14+00:00"},{"id":1206,"source":"github","source_ref":"6726753273","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read it against the code and the behaviour you describe is as designed today; we are reviewing whether renewals should be bound by provider policy and will update this ticket when a decision is made.","created_at":"2026-11-08T20:32:51+00:00"}]}