<!-- XE-13363 · [Medium] Unbounded oracle R + TWAP=0 disables the lease payout cap (unbounded mint via oracle epoch) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13363>. The page is the record; this is the same page for reading.*

XE-13363 · Bounty

# \[Medium\] Unbounded oracle R \+ TWAP\=0 disables the lease payout cap (unbounded mint via oracle epoch)

Closed · duplicate
—claimed Medium
[xe#372](https://github.com/xeprotocol/xe/issues/372)
filed 2026-11-11 11:12 UTC
by akitaBugBounty

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-20 00:06 UTC

Told
:   2026-11-20 00:05 UTC

### Patches

- [xe#877](https://github.com/xeprotocol/xe/pull/877) open by tipprb
  fix(xe): medium--unbounded-oracle-r (fixes #372)

### History

- [543799](https://bounty.xe.network/log/543799) 2026-11-20 00:05 UTC github.state\_pushed
- [543798](https://bounty.xe.network/log/543798) 2026-11-20 00:05 UTC github.labels
- [543771](https://bounty.xe.network/log/543771) 2026-11-20 00:05 UTC reply.mirrored
- [543633](https://bounty.xe.network/log/543633) 2026-11-20 00:04 UTC proposal.adopted
- [543632](https://bounty.xe.network/log/543632) 2026-11-20 00:04 UTC reply.sent
- [543631](https://bounty.xe.network/log/543631) 2026-11-20 00:04 UTC ticket.status new → closed
- [542302](https://bounty.xe.network/log/542302) 2026-11-20 00:04 UTC proposal.adopted
- [542301](https://bounty.xe.network/log/542301) 2026-11-20 00:04 UTC ticket.facts area
- [542300](https://bounty.xe.network/log/542300) 2026-11-20 00:04 UTC proposal.adopted
- [542299](https://bounty.xe.network/log/542299) 2026-11-20 00:04 UTC ticket.facts
- [542298](https://bounty.xe.network/log/542298) 2026-11-20 00:04 UTC proposal.adopted
- [542297](https://bounty.xe.network/log/542297) 2026-11-20 00:04 UTC ticket.facts

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

### Report

### Summary

The statechain oracle epoch validator (`validateEpochValue` in `statechain/kvstore.go`) puts no upper bound on the emission multiplier `R`, and treats `TWAP = 0` / `RCollusion = 0` as "feature disabled" instead of invalid. The ledger-side payout cap (`CapR` in `core/ledger.go`) also returns `R` uncapped whenever `twap == 0`. The production genesis configures `sys.oracle` as a single key with threshold 1, so a compromised, insider, or misconfigured oracle can publish an epoch with an arbitrarily large `R` and the cap switched off — and any lease settling against that epoch mints `cost * R / 1000` with no effective limit.

### Impact

A 1-of-1 oracle epoch with `R = 1,000,000,000` (1,000,000x the intended \~1–2x range) and `TWAP = 0` passes validation and is accepted by the statechain end-to-end. A **$31 lease (cost 31,000 mXUSD) settles for 31,000 XE**; a legitimate epoch (R \~2,000) would pay \~0.000062 XE. Emission is bounded only by uint64 overflow in `safeMul`, i.e. effectively unbounded for realistic leases.

Severity is Medium, not Critical: exploitation requires the trusted oracle key, so this is a single-point-of-failure / missing-validation issue, not a remotely exploitable bug. But the on-chain impact of a compromised or misconfigured oracle is unbounded mint.

### Root cause (repo `github.com/xeprotocol/xe`, commit `89a542ea51d38375299aee54c6c99102e9bfa666`, "release: testnet-0005 quorum withhold fix")

Two gaps in `statechain/kvstore.go` `validateEpochValue` (\~line 333):

1. No upper bound on `RVolume` / `RPriceFloor` / `REffective`. The checks only relate the three R values to each other, never to any sane range. Tokenomics defines `RInit = 2000` and `RFloor = 100`, but they are not enforced here.
2. `RCollusion = 0` and `TWAP = 0` are treated as "feature disabled", not invalid: `expectedRCollusion` returns 0 when TWAP is 0, the `RCollusion != 0` consistency checks are skipped, and `core.CapR` (`core/ledger.go:2037`) returns `R` uncapped when `twap == 0`:

```
func CapR(r, payoutCap, twapMilliUSD uint64) uint64 {
	if payoutCap == 0 || twapMilliUSD == 0 {
		return r
	}
	...
}
```

Trust context: production genesis sets `sys.oracle` to a single key (`ad674f8c1683db33f9c2b97daf91733123015e9c8b6e496f0301a9a78165f864`), threshold 1 (`statechain/genesis.json`). DAO is 2-of-3 and timekeepers 2-of-3, but the oracle is 1-of-1.

### Reproduction

PoC tests (assert the vulnerable behaviour; they fail once fixed):

- `statechain/xe01_poc_test.go` — `validateEpochValue` accepts `R=1e9, TWAP=0, RCollusion=0, RSource="volume"`; same with `TWAP=250, RCollusion=0`; and a full `Chain.AddBlock` accepts the malicious `epoch.1` block end-to-end (2-of-2 DAO genesis \+ 1-of-1 oracle).
- `core/xe01_poc_test.go` — `CapR(1e9, 1502, 0) == 1e9`; `LeaseEmissionChecked(31000, 1e9) == 31,000,000,000 mXE = 31,000 XE`; same via `LeaseTotalEmission`.

Run:

```
git clone https://github.com/xeprotocol/xe && cd xe
# add the two PoC test files above, then:
go test ./statechain/ -run XE01 -v   # 3/3 PASS (vulnerable behaviour reproduced)
go test ./core/ -run XE01 -v         # 3/3 PASS
```

Malicious epoch used by the PoC (`epoch.1`, JSON):

```
{"epoch":1,"start_ns":0,"end_ns":1000000000,"twap_milli_usd":0,
 "r_volume":1000000000,"r_price_floor":100,"r_collusion":0,
 "r_effective":1000000000,"r_source":"volume","phase":1,"payout_cap":1502}
```

### Suggested fix

- In `validateEpochValue`, reject `TWAP == 0` and reject `RCollusion == 0` (or require it to be \>\= the supportive R), and bound `REffective` (and its components) to a sane maximum, e.g. `R <= 100_000` milli (100x) or a tokenomics-derived ceiling.
- Make `CapR` fail closed instead of returning uncapped `R` when TWAP is 0\.
- Consider raising the oracle threshold above 1\.

### Environment

- Codebase: `github.com/xeprotocol/xe` @ `89a542e` (2026-11-10)
- Go 1.25.0, `go test` as above, no testnet nodes involved (local reproduction only)

### Thread

**akitaBugBounty**2026-11-11 11:22 UTCgithub

XE payout address: e3d3e4407fec5a846201c7ed8560484ffb881cc30068745a110dd8efb824500c

**Joseph Denne**team2026-11-20 00:05 UTCgithub

Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the
first verifiable submission, so this one closes as a duplicate. If you believe it is a different
bug, file a new report that links https://bounty.xe.network/XE-13363 and says what differs; it is read like any other.
