{"id":"XE-0067","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"92","source_url":"https://github.com/xeprotocol/xe/issues/92","reporter_id":2867,"title":"[Lease Accounting] LeaseCancel after LeaseRenew refunds only the base cost — renewal top-up funds vanish (supply conservation broken)","area":"leasing-ledger","claimed_tier":"medium","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:20.070833+00:00","updated_at":"2026-11-16T13:42:49.539255+00:00","source_created_at":"2026-10-26T21:52:55+00:00","told_at":"2026-11-05T22:11:41+00:00","status_changed_at":"2026-10-29T14:04:13.765932+00:00","url":"https://bounty.xe.network/XE-0067","body":"Suggested severity: Medium (2,500 XE).\n\n## Summary\n\nAfter a `lease_renew`, the pending escrow grows by the renewal top-up (`core/lease_renew.go:137-138`, applied as `pending += topUp` in `store/mem_store.go:338-343`). But `validateAndAddLeaseCancel` computes the refund as `expectedBal := oldBal + leaseBlock.Amount` (core/ledger.go:1853), where `leaseBlock.Amount` is only the BASE segment cost, and then deletes the entire pending escrow (`DeletePendingID` + `CancelLeaseHash`, core/ledger.go:1858-1867). The difference — the total renewal cost — is neither refunded to the consumer nor paid to the provider: it vanishes from circulation (a supply-conservation break, deflationary).\n\n## Impact\n\nA consumer who renews and then cancels loses exactly the renewal amount. This is provably a bug, not design: `validateAndAddLeaseForceSettle` (core/ledger.go:1879) correctly refunds `pending.Amount` (base + renewals) and settle burns the full pending. Only cancel uses the base figure.\n\n## Steps to Reproduce (local, no real funds)\n\n1. Consumer creates a lease (base cost C) and the provider accepts it.\n2. Consumer renews (top-up R); observe pending escrow becomes C + R.\n3. Consumer cancels (via the cancel-wins path if the accept is not yet finalized).\n4. Observed: consumer balance after cancel is initial - R (refund is only C); the R top-up is gone; the pending escrow is deleted in full; the lease ends Cancelled. Measured locally: initial 500,000,000,000 -> after renew 499,999,940,000 -> after cancel 499,999,970,000 (base 30,000 refunded, renewal 30,000 lost).\n\n## Recommendation\n\nCompute the cancel refund from `pending.Amount` (base + all renewal top-ups), exactly as force-settle does, and clear stale `Renewals` in the cancel-wins rollback path.\n\nHonest caveat: the victim here is the consumer cancelling their own lease (not theft by an attacker), which is why this is filed as Medium, not High/Critical. This is a different function and root cause from force-settle accounting: cancel refunds `leaseBlock.Amount` instead of `pending.Amount`.\n\nPayout address: to be provided on request.","patch_refs":[{"id":129,"repo":"xeprotocol/xe","kind":"pr","ref":"109","title":"fix(core,store): refund full pending escrow including renewals on lease_cancel (#92)","url":"https://github.com/xeprotocol/xe/pull/109","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":437,"source":"github","source_ref":"6670876031","author":"Joseph Denne","team":true,"body":"Thanks for the reports. To pay out we need an XE payout address in the report itself: please edit the issue body to add a line \"Payout address: xe_...\" and say here when it is done. The desk entry is https://bounty.xe.network/XE-0067.","created_at":"2026-11-05T22:11:41+00:00"},{"id":537,"source":"github","source_ref":"6672714850","author":"Ryanmahrez44","team":false,"body":"Done — I have added my payout address to the issue body: xe_a52c0b32eeAAf26015Fb27e2AfFDddA41ff9CE4c","created_at":"2026-11-05T23:56:19+00:00"},{"id":1901,"source":"github","source_ref":"6765007291","author":"Reyzz95","team":false,"body":"Still reproduces at HEAD `89a542e` (testnet-0005, 2026-11-10).\n\n`validateAndAddLeaseCancel` (`core/ledger.go:1852-1867`) refunds only the base cost (`expectedBal := oldBal + leaseBlock.Amount`) while deleting the whole pending escrow.\n\nPoC (local `go test`, `TestPOCAreaB_XE0067_CancelAfterRenew`): escrow 2,668 (base 1,334 + renewal 1,334); after cancel the consumer holds 9,998,666 vs 10,000,000 start — the 1,334 renewal top-up vanished.\n\nNote force-settle (`ledger.go:1970`) and the staged validator (`ledger.go:2817`) both use the full pending amount, so the codebase disagrees with itself here.","created_at":"2026-11-10T10:29:14+00:00"}]}