{"id":"XE-13363","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"372","source_url":"https://github.com/xeprotocol/xe/issues/372","reporter_id":2132,"title":"[Medium] Unbounded oracle R + TWAP=0 disables the lease payout cap (unbounded mint via oracle epoch)","area":"leasing-ledger","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1120","internal_url":"https://github.com/xeprotocol/core/issues/1120","status":"closed","closed_reason":"duplicate","github_state":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:11.799977+00:00","updated_at":"2026-11-20T00:06:59.158645+00:00","source_created_at":"2026-11-11T11:12:02+00:00","told_at":"2026-11-20T00:05:12+00:00","status_changed_at":"2026-11-20T00:04:40.985329+00:00","url":"https://bounty.xe.network/XE-13363","body":"### Summary\n\nThe 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.\n\n### Impact\n\nA 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.\n\nSeverity 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.\n\n### Root cause (repo `github.com/xeprotocol/xe`, commit `89a542ea51d38375299aee54c6c99102e9bfa666`, \"release: testnet-0005 quorum withhold fix\")\n\nTwo gaps in `statechain/kvstore.go` `validateEpochValue` (~line 333):\n\n1. 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.\n2. `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`:\n\n```go\nfunc CapR(r, payoutCap, twapMilliUSD uint64) uint64 {\n\tif payoutCap == 0 || twapMilliUSD == 0 {\n\t\treturn r\n\t}\n\t...\n}\n```\n\nTrust 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.\n\n### Reproduction\n\nPoC tests (assert the vulnerable behaviour; they fail once fixed):\n\n- `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).\n- `core/xe01_poc_test.go` — `CapR(1e9, 1502, 0) == 1e9`; `LeaseEmissionChecked(31000, 1e9) == 31,000,000,000 mXE = 31,000 XE`; same via `LeaseTotalEmission`.\n\nRun:\n\n```bash\ngit clone https://github.com/xeprotocol/xe && cd xe\n# add the two PoC test files above, then:\ngo test ./statechain/ -run XE01 -v   # 3/3 PASS (vulnerable behaviour reproduced)\ngo test ./core/ -run XE01 -v         # 3/3 PASS\n```\n\nMalicious epoch used by the PoC (`epoch.1`, JSON):\n\n```json\n{\"epoch\":1,\"start_ns\":0,\"end_ns\":1000000000,\"twap_milli_usd\":0,\n \"r_volume\":1000000000,\"r_price_floor\":100,\"r_collusion\":0,\n \"r_effective\":1000000000,\"r_source\":\"volume\",\"phase\":1,\"payout_cap\":1502}\n```\n\n### Suggested fix\n\n- 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.\n- Make `CapR` fail closed instead of returning uncapped `R` when TWAP is 0.\n- Consider raising the oracle threshold above 1.\n\n### Environment\n\n- Codebase: `github.com/xeprotocol/xe` @ `89a542e` (2026-11-10)\n- Go 1.25.0, `go test` as above, no testnet nodes involved (local reproduction only)","patch_refs":[{"id":728,"repo":"xeprotocol/xe","kind":"pr","ref":"877","title":"fix(xe): medium--unbounded-oracle-r (fixes #372)","url":"https://github.com/xeprotocol/xe/pull/877","note":"","state":"open","author":"tipprb","added_by":"desk","created_at":"2026-11-19T18:02:10.617626+00:00"}],"thread":[{"id":3138,"source":"github","source_ref":"6794479677","author":"akitaBugBounty","team":false,"body":"XE payout address: e3d3e4407fec5a846201c7ed8560484ffb881cc30068745a110dd8efb824500c","created_at":"2026-11-11T11:22:20+00:00"},{"id":12850,"source":"github","source_ref":"7025804765","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, 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-13363 and says what differs; it is read like any other.","created_at":"2026-11-20T00:05:12+00:00"}]}