{"id":"XE-4334","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Lease rollback desync: priorLease and escrowPendingOf bypass cascade overlay, creating phantom escrow amounts during multi-step lease reorgs","area":"leasing-ledger","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0135","tracked":true,"internal_ref":"#1064","internal_url":"https://github.com/xeprotocol/core/issues/1064","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-10T22:37:08.528539+00:00","updated_at":"2026-11-16T17:44:53.476388+00:00","source_created_at":null,"told_at":"2026-11-15T17:42:48.998689+00:00","status_changed_at":"2026-11-15T17:42:48.968722+00:00","url":"https://bounty.xe.network/XE-4334","body":"## Vulnerability Summary\n\nIn `core/rollback.go:87-144`, helper functions `priorLease`, `escrowPendingOf`, and `priorLeasePopRenewal` are responsible for restoring prior lease states and reconstructing in-flight pending escrow entries during chain reorgs and block unwinding (`swapBlockLocked` in `core/ledger.go:2976-2998`).\n\nHowever, all three functions directly query the underlying persistent store (`ls.GetLease`) without consulting active rollback overlays (`l.getLeaseOverlay`):\n1. `priorLease(leaseHash, target)` in `core/rollback.go:92` directly queries `ls.GetLease(leaseHash)`.\n2. `escrowPendingOf(leaseHash)` in `core/rollback.go:117` iterates through `lease.Renewals` directly retrieved from `ls.GetLease(leaseHash)` to compute `amount = lb.Amount + sum(Renewals.Cost)`.\n3. `priorLeasePopRenewal(leaseHash)` in `core/rollback.go:137` pops renewals from a lease fetched directly from `ls.GetLease(leaseHash)`.\n\nWhen an account undergoes a multi-step reorg involving consecutive lease operations (such as multiple `BlockLeaseRenew` blocks followed by `BlockLeaseSettle` or `BlockLeaseCancel`), `SwapBlock` constructs a `cascadeBuild` unwinding blocks in reverse chronological order. Because `escrowPendingOf` and `priorLease` ignore prior unwound steps in the cascade overlay, they read stale physical lease records from disk instead of the intermediate in-memory overlay.\n\nThis causes `escrowPendingOf` to compute inflated, phantom escrow balances by including renewal costs that were already unwound earlier in the cascade plan. When the reverted pending send is restored, it injects phantom XUSD into pending balances, violating supply conservation invariants and causing subsequent staged block validation or supply auditing to fail, rejecting legitimate consensus reorganizations.\n\n---\n\n## Vulnerable Code Location\n\nIn `core/rollback.go:87-144`:\n```go\nfunc (l *Ledger) priorLease(leaseHash string, target LeaseState) *Lease {\n\tls, ok := l.store.(LeaseStore)\n\tif !ok {\n\t\treturn nil\n\t}\n\tcur, err := ls.GetLease(leaseHash) // <-- Directly reads underlying store, ignoring cascade overlay!\n\tif err != nil || cur == nil {\n\t\treturn nil\n\t}\n\trestored := *cur\n\trestored.State = target\n\trestored.Settled = false\n\t...\n\treturn &restored\n}\n\nfunc (l *Ledger) escrowPendingOf(leaseHash string) *PendingSend {\n\tlb := l.GetBlock(leaseHash)\n\tif lb == nil || lb.Type != BlockLease {\n\t\treturn nil\n\t}\n\n\tamount := lb.Amount\n\tif ls, ok := l.store.(LeaseStore); ok {\n\t\tif lease, err := ls.GetLease(leaseHash); err == nil && lease != nil { // <-- Bypasses lease overlay!\n\t\t\tfor i := range lease.Renewals {\n\t\t\t\tamount += lease.Renewals[i].Cost\n\t\t\t}\n\t\t}\n\t}\n\treturn &PendingSend{\n\t\tSendHash:    lb.Hash,\n\t\tSource:      lb.Account,\n\t\tDestination: lb.Destination,\n\t\tAmount:      amount,\n\t\tAsset:       \"XUSD\",\n\t}\n}\n\nfunc (l *Ledger) priorLeasePopRenewal(leaseHash string) *Lease {\n\tls, ok := l.store.(LeaseStore)\n\tif !ok {\n\t\treturn nil\n\t}\n\tcur, err := ls.GetLease(leaseHash) // <-- Reads un-popped physical lease!\n\tif err != nil || cur == nil || len(cur.Renewals) == 0 {\n\t\treturn nil\n\t}\n\trestored := *cur\n\trestored.Renewals = append([]LeaseSegment(nil), cur.Renewals[:len(cur.Renewals)-1]...)\n\treturn &restored\n}\n```\n\n---\n\n## Failure Mechanism & Concrete Exploit Scenario\n\n1. **Multi-Step Lease Chain**: An account issues:\n   - Block 10: `BlockLease` ($100 XUSD escrow).\n   - Block 11: `BlockLeaseAccept`.\n   - Block 12: `BlockLeaseRenew` (adds $50 XUSD renewal).\n   - Block 13: `BlockLeaseSettle` (settles the lease).\n2. **Consensus Reorg**: A 67%+ BFT quorum winner causes a reorg unwinding back to Block 11.\n3. **Cascade Step Execution**:\n   - Step 1 unwinds Block 13 (`BlockLeaseSettle`): `escrowPendingOf` reads physical store and creates a restored `PendingSend` with $100 + $50 = $150 XUSD.\n   - Step 2 unwinds Block 12 (`BlockLeaseRenew`): `reducePendingAmount` is set to $50, and `priorLeasePopRenewal` attempts to restore lease state without the renewal.\n4. **State Desynchronization**:\n   - If multiple renewals exist and are unwound sequentially, each call to `priorLeasePopRenewal` reads the un-mutated persistent store state (`ls.GetLease`), failing to sequentially pop renewal segments across multiple rollback steps.\n   - If `escrowPendingOf` is invoked during reorg unwinding after a renewal rollback has already been staged in the cascade, it calculates the full cumulative cost from disk, resurrecting phantom escrow amounts.\n5. **Impact**:\n   - Staged blocks evaluating `getPendingSendOverlay` receive corrupted pending balances.\n   - Conservation checks fail or allow double-spend/inconsistent state transitions during consensus winner swaps, causing node consensus deadlocks or chain forks.\n\n---\n\n## Proposed Mitigation\n\nUpdate `core/rollback.go` so that `priorLease`, `escrowPendingOf`, and `priorLeasePopRenewal` check and respect `l.getLeaseOverlay(leaseHash)` (or accept the in-progress cascade snapshot) rather than directly querying `ls.GetLease`.","patch_refs":[],"thread":[{"id":6455,"source":"desk","source_ref":"reply:5095","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0135, 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-4334 and says what differs; it is read like any other.","created_at":"2026-11-15T17:42:16.598376+00:00"}]}