<!-- XE-16810 · [BugBounty][High] Oracle epoch with TWAP above $950 collapses all lease emissions to 1 µXE — validateEpochValue has no TWAP upper bound and no R floor · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16810>. The page is the record; this is the same page for reading.*

XE-16810 · Bounty

# \[BugBounty\]\[High\] Oracle epoch with TWAP above $950 collapses all lease emissions to 1 µXE — validateEpochValue has no TWAP upper bound and no R floor

Closed · duplicate
—claimed High
[xe#660](https://github.com/xeprotocol/xe/issues/660)
filed 2026-11-17 06:17 UTC
by brikzeni

Verdict
:   Duplicate

Tier
:   —

Claimed
:   High

Area
:   Leasing / ledger

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-22 23:27 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770304](https://bounty.xe.network/log/770304) 2026-11-22 23:27 UTC github.state\_pushed
- [770303](https://bounty.xe.network/log/770303) 2026-11-22 23:27 UTC github.labels
- [769942](https://bounty.xe.network/log/769942) 2026-11-22 23:26 UTC reply.mirrored
- [769518](https://bounty.xe.network/log/769518) 2026-11-22 23:26 UTC proposal.adopted
- [769517](https://bounty.xe.network/log/769517) 2026-11-22 23:26 UTC reply.sent
- [769516](https://bounty.xe.network/log/769516) 2026-11-22 23:26 UTC ticket.status new → closed
- [768159](https://bounty.xe.network/log/768159) 2026-11-22 23:25 UTC proposal.adopted
- [768158](https://bounty.xe.network/log/768158) 2026-11-22 23:25 UTC ticket.facts area
- [768157](https://bounty.xe.network/log/768157) 2026-11-22 23:25 UTC proposal.adopted
- [768156](https://bounty.xe.network/log/768156) 2026-11-22 23:25 UTC ticket.facts
- [768155](https://bounty.xe.network/log/768155) 2026-11-22 23:25 UTC proposal.adopted
- [768154](https://bounty.xe.network/log/768154) 2026-11-22 23:25 UTC ticket.facts

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

### Report

**Target:** `github.com/xeprotocol/xe` @ `8cc209d` ("release: testnet-0006 build")
**Severity: High — CVSS 3.1: 6.5** (`AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:H`)
**Reporter:** brikzeni / lolopapa3491@gmail.com — payout XE address `1522be0b3fd8bd46da1021c3e090b7a4b9cdbe8e3eed2c55e66a4440aab07b0e`
**Program area:** LEASING / LEDGER, CONSENSUS

### Summary

`validateEpochValue` (`statechain/kvstore.go:350`) has **no upper bound on `TWAPMilliUSD`** and **no floor on any R value**. The collusion factor is computed by integer division — `expectedRCollusion(twap, s, factor) = factor*(1000-s)/twap` — so once TWAP exceeds $950 (phase 1), the expected collusion R floors to **0**, and an epoch carrying `RVolume = RPriceFloor = RCollusion = REffective = 0` passes every check. `CapR(0, cap, twap)` is 0, so `LeaseEmissionChecked` returns its **1 µXE minimum** for every lease, regardless of cost. A single 1-of-1 oracle key can publish four such epochs, evicting every sane epoch from the `EpochLockTolerance+1 = 4` candidate window in `epochAtFn`, after which **every lease accepted network-wide locks 1 µXE emissions permanently** — a 99.9% cut (1,034 µXE → 1 µXE for a standard 517-cost lease) that no later sane epoch can repair for those leases.

### Relationship to #372 — disclosed up front

This is the same *class* as open #372 ("Unbounded oracle R \+ TWAP\=0 disables the lease payout cap"), but a **distinct vector with a distinct fix**, and it survives the testnet-0006 fix for #372:

- #372's vectors were **R unbounded upward** (R\=1e9) and **TWAP\=0** (cap disabled). Both are fixed in 0006: `RVolume`/`RPriceFloor`/`REffective` are capped at `RInit = 2000`, and `TWAP == 0` is rejected. Verified by the controls in this PoC (RVolume\=2001 rejected, TWAP\=0 rejected).
- This vector is the **opposite direction**: TWAP unbounded **upward** (never mentioned in #372 — its PoC used TWAP\=0) and R with **no floor**. The fix #372 suggested ("bound R to a sane maximum, reject TWAP\=\=0") does not cover it; the fix here is a **TWAP ceiling** (or requiring `expectedRCollusion > 0`) plus an **R floor** (`REffective`/`RVolume`/`RPriceFloor ≥ RFloor = 100`).
- It is also distinct from #646 (duplicate Epoch numbers — nondeterministic split; #646's suggested fix, uniqueness/strictly-greater Epoch, does **not** stop this: the poisoned epochs have distinct, increasing Epoch numbers) and from #377/#175 (locking a *past* epoch's higher R — this publishes a *new* poisoned epoch).

### Root cause

`statechain/kvstore.go:350-460`, `validateEpochValue`:

1. `TWAPMilliUSD == 0` is rejected (line 359\) — but there is **no upper bound**. Any TWAP is accepted.
2. `expectedRCollusion` (`kvstore.go:455`) is `factor*(1000-s)/twap` in integer arithmetic. Phase 1 (`s = 0`, `factor = 950`): `950000/twap`. At TWAP \= 950,001 milli-USD ($950.001) this is **0**. The check requires `RCollusion == expectedRCollusion` exactly — so at TWAP \> $950, `RCollusion` **must be 0** to pass. (Phase 2, `s = 300`: threshold is $665.)
3. `REffective` must equal `supportive = max(RVolume, RPriceFloor)` unless `RCollusion` is non-zero and smaller. With `RVolume = RPriceFloor = RCollusion = 0`, `expectedR = 0`, so `REffective = 0` passes.
4. No check anywhere requires any R value to be \> 0 (tokenomics defines `RFloor = 100`, but it is never enforced in `validateEpochValue`).
5. `RSource = "tied"` passes trivially (`0 == 0`; its `RCollusion < supportive` guard is skipped when `RCollusion == 0`).
   Net: the validator *forces* R\=0 at high TWAP instead of rejecting it.

Downstream (`core/ledger.go:2168-2242`): `CapR(0, payoutCap, twap) = min(0, ceil(cap*1000/twap)) = 0`; `LeaseEmissionChecked(cost, 0)` returns the **1 µXE floor**. `epochAtFn` (`node/node.go:429-457`) takes the 4 most recent epochs (`EpochLockTolerance+1`); four sequential poisoned epochs evict all sane epochs from the window, so `validateLockedEmissionAt` can only lock poisoned params. `latestEpoch` (`node/node.go:391-405`) likewise returns the poisoned epoch. Leases lock their params at accept time and there is no re-lock path, so leases accepted during the poisoned window are **permanently** underpaid.

### Proof (local, real code — no live testnet)

Standalone Go module (module `xer6oracle`, `replace` to the xe checkout @ `8cc209d`). It builds a local in-memory statechain from a self-authored genesis (own throwaway oracle key, threshold 1 — the validation rules under test do not depend on which key signs, only that `verifyOracleMultisig` passes for the configured keyset), then calls the real `statechain.Chain.AddBlock` and the real `core.CapR` / `core.LeaseEmissionChecked`. Run `go test -v .` — **5/5 PASS**:

- `TestPoisonedEpochAccepted`: Poisoned epoch.2 (TWAP\=1e9, R\=0) **ACCEPTED**; epochs 3–5 accepted; `latestEpoch` \= poisoned epoch 5 (R\=0, TWAP\=1e9); all 4 `epochAtFn` candidates poisoned; sane emission **1,034 µXE** → poisoned emission **1 µXE** for a 517-cost lease.
- `TestAbsurdEpochNumberAccepted`: A single epoch with `Epoch = 2^64-1` **ACCEPTED** and permanently wins `latestEpoch` (no uniqueness/monotonicity/sequence check; #646's suggested fix would not prevent it — 2^64-1 *is* strictly greater and unique).
- `TestZeroRWithSaneTWAPAccepted`: R\=0 **rejected** at TWAP\=250 (`r_collusion (0) != expected 3800`) and at TWAP\=950,000 (`!= expected 1`); R\=0 **ACCEPTED** at TWAP\=950,001 — the exact threshold is pinned (TWAP \> $950 phase 1, $665 phase 2).
- `TestEpochValidationControls`: TWAP\=0 rejected; RVolume\=2001 rejected; duplicate key `epoch.1` rejected (write-once); non-oracle signer rejected — the harness discriminates.
- `TestForgedAttestationRejected`: 2 forged sigs (trusted pubkeys, random sigs) rejected; non-trusted signer rejected; 1 valid \+ 1 forged rejected (below 2-of-3 threshold); stale (1h) attestations rejected on the live path, accepted on the sync path (known #19 behaviour).

Poisoned epoch value used (JSON): `{"epoch":2,"start_ns":0,"end_ns":1099511627776,"twap_milli_usd":1000000000, "r_volume":0,"r_price_floor":0,"r_collusion":0,"r_effective":0, "r_source":"tied","phase":1,"s_milli":0,"payout_cap":1120}`

### Impact

- **Every provider, network-wide.** Four poisoned epochs (one oracle key, four blocks) collapse the emission of every lease accepted afterwards to 1 µXE — a 99.9% pay cut (1,034 → 1 µXE on a standard lease). Providers earn \~nothing while still delivering the VM.
- **Permanent for leases in the window.** Locked params are fixed at accept; no re-lock exists. A lease accepted while the window is poisoned settles for 1 µXE even after the oracle is rotated and sane epochs resume.
- **Slow, DAO-only recovery.** The DAO (2-of-3) can rotate `sys.oracle` (DAO blocks may write `sys.oracle`; only the `epoch.*` prefix is DAO-forbidden, `chain.go:210`) and the new oracle must publish 4 sane epochs with higher Epoch numbers before the window heals. Until then the network's provider economy is halted.
- **Deterministic, not probabilistic.** Unlike #646's nondeterministic split, every node computes the same poisoned params — the damage is uniform and total.

Honest limits, stated up front:

- Exploitation requires the **1-of-1 oracle private key** (compromise, insider, or misconfiguration) — the same precondition as #372 and #646, both accepted as in-scope findings. Without the key, nothing here is reachable. This is a single-point-of-failure / missing-validation issue, not a remotely exploitable bug — which is why it is High, not Critical.
- The live testnet's `sys.oracle` is 1-of-1 by genesis design (one key, threshold 1). No new key material is claimed; the live oracle key was never touched.
- The absurd-`Epoch` observation is only harmful combined with poisoned R values (with sane R it merely pins `latestEpoch`); it is reported as a supporting observation, not a separate finding.

### Suggested fix

In `validateEpochValue` (`statechain/kvstore.go`):

1. **TWAP ceiling:** reject `TWAPMilliUSD` above a sane maximum (e.g. a tokenomics-derived cap), or equivalently require `expectedRCollusion > 0` — a TWAP so high that the collusion factor floors to zero is not a price.
2. **R floor:** require `RVolume`, `RPriceFloor`, and `REffective` to be ≥ `RFloor` (tokenomics already defines `RFloor = 100`; enforce it here), and require `RCollusion > 0` whenever `expectedRCollusion > 0` (already implied by the equality check at sane TWAPs — the ceiling in (1) makes it hold everywhere).
3. **(Defence in depth)** Consider an `Epoch` sanity bound (e.g. reject `Epoch` values wildly ahead of the current tip) and raising the oracle threshold above 1 — the same 1-of-1 key underlies #372, #646, and this report.

### Thread

**brikzeni**2026-11-18 11:24 UTCgithub

Correction to the CVSS score stated in this report: it should be **5.9, not 6.5**.

Re-checking my own scoring, the stated vector is `AV:N/AC:H/PR:H/UI:N/S:U/C:N/I:H/A:H`. With the CVSS 3.1 FIRST formula:

- Impact: ISC \= 1 − (1−0) × (1−0.56) × (1−0.56) \= 0.8064, so 6.42 × 0.8064 \= 5.18
- Exploitability: 8.22 × 0.85 (AV:N) × 0.44 (AC:H) × 0.27 (PR:H) × 0.85 (UI:N) \= 0.71
- Base score: roundup(5.18 \+ 0.71) \= **5.9**

The 6.5 figure corresponds to AC:L (0.77), not the AC:H (0.44) in the stated vector. The vector itself is unchanged, and nothing else in the report changes: the finding, the reproduction steps, and the PoC (5/5 passing) stand as submitted. I leave the severity tier to triage.

Note: the related issue #802 uses AC:L in its vector, and its 6.5 is computed correctly — this correction does not affect #802. Apologies for the error.

**kinoy-1**2026-11-21 17:21 UTCgithub

Additional evidence for #660 (same root cause — `validateEpochValue` has no TWAP upper bound). #660's poisoned epoch zeroes R. The same missing bound collapses emissions to the 1 micro-XE floor even when R is left at the sane maximum — no R-zeroing is needed at all. The crush comes from the other side of the same formula: `CapR` divides the payout cap by the absurd TWAP, so `R_capped` floors to 1 while `R = 2000`. Not a new issue.

Repo: github.com/xeprotocol/xe @ `8cc209d` (testnet-0006). Comment by kinoy-1 (XE payout address `19f0b012f28b5954679765cad3c5795380fabec1f050f7a57e1f4dc34caf13c7` — for reference only; this is evidence on #660, not a new claim).

## PoC (local only, real code, no live testnet contact, no funds)

Epoch accepted by the real `validateEpochValue` (`statechain/kvstore.go:350`):

```
{"epoch":2,"start_ns":0,"end_ns":1000000000,"twap_milli_usd":1000000000,
 "r_volume":2000,"r_price_floor":2000,"r_collusion":0,
 "r_effective":2000,"r_source":"tied","phase":1,"s_milli":0,"payout_cap":1527}
```

Why it passes every check in `validateEpochValue`:

- `TWAP == 0` is rejected but there is no upper bound — `TWAP = 1e9` passes.
- `expectedRCollusion = 950*(1000-0)/1e9 = 0` (integer floor), so `RCollusion = 0` matches exactly.
- `RCollusion == 0` skips the `RCollusion < supportive` guards; `REffective = supportive = max(2000, 2000) = 2000` passes.
- `RSource = "tied"`: `RVolume == RPriceFloor` (2000 \=\= 2000); its collusion guard is skipped when `RCollusion == 0`.
- `RVolume (2000) <= RInit (2000)`, `RPriceFloor (2000) <= tier1 (2000)`, `PayoutCap (1527)` in `[1120, 1550]`, `SMilli (0)` matches phase 1\.

Downstream (`core/ledger.go:2168` `CapR`, `:2184` `LeaseEmissionChecked`), standard 60s 1-vCPU lease, cost 517 mXCU:

- `CapR(2000, 1527, 1000000000) = ceil(1527*1000/1e9) = 1`
- `LeaseEmissionChecked(517, 1) = ceil(517*1/1000) = 1` micro-XE
- Control at the live sane TWAP: `CapR(2000, 1527, 250) = 2000`, emission `1034` micro-XE.

So a lease locking this epoch settles for 1 micro-XE instead of 1034 — a 99.9% pay cut — with R at its full sane value. (At TWAP \= $1,000 the same payload gives `CapR = 2`, emission 2 micro-XE; the collapse scales with TWAP.)

Reproduction: `git checkout 8cc209d`, add the test below as `statechain/poc_d_test.go`, `go test ./statechain/ -run TestPOC_D_HighTWAPNonzeroR -v -count=1` — PASS (2026-11-22): epoch ACCEPTED, CapR\=1, emission\=1 (sane: 1034).

```
package statechain

import (
	"encoding/json"
	"testing"

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

func TestPOC_D_HighTWAPNonzeroR(t *testing.T) {
	ev := EpochValue{
		Epoch: 2, StartNS: 0, EndNS: 1000000000,
		TWAPMilliUSD: 1000000000, // $1,000,000
		RVolume: 2000, RPriceFloor: 2000, RCollusion: 0, REffective: 2000,
		RSource: "tied", Phase: 1, SMilli: 0, PayoutCap: 1527,
	}
	raw, _ := json.Marshal(ev)
	if err := validateEpochValue(raw, nil); err != nil {
		t.Fatalf("high-TWAP sane-R epoch REJECTED (fix present?): %v", err)
	}
	capped := core.CapR(2000, 1527, 1000000000)
	em, _ := core.LeaseEmissionChecked(517, capped)
	if em != 1 {
		t.Fatalf("expected 1 uXE floor, got %d", em)
	}
	if c2 := core.CapR(2000, 1527, 250); c2 != 2000 {
		t.Fatalf("control CapR at TWAP 250 = %d, want 2000", c2)
	}
}
```

Same root cause as #660, same suggested fix (a TWAP ceiling, or requiring `expectedRCollusion > 0`), same 1-of-1 oracle precondition, same permanent lock-in for leases accepted in the window. Live sane reference (2026-11-22, `ldn.core.test.network/statechain/kv`): `epoch.1`: `twap_milli_usd 250, r_effective 2000, r_collusion 3800, payout_cap 1527` — the control values above match the live network.

**Joseph Denne**team2026-11-22 23:26 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-16810 and says what differs; it is read like any other.
