{"id":"XE-2530","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":464,"title":"Conflict-winner promotion (SwapBlock) skips the timekeeper attestation freshness check — a stale lease_settle past the grace window commits and mints emission","area":"leasing-ledger","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1099","internal_url":"https://github.com/xeprotocol/core/issues/1099","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-10T03:36:32.748194+00:00","updated_at":"2026-11-15T11:08:46.745488+00:00","source_created_at":null,"told_at":"2026-11-15T11:08:50.274706+00:00","status_changed_at":"2026-11-15T11:08:50.253364+00:00","url":"https://bounty.xe.network/XE-2530","body":"## Summary\r\n\r\n`SwapBlock` (conflict-winner promotion) validates the winning block with the\r\nattestation freshness check disabled, so a `lease_settle` carrying stale\r\ntimekeeper attestations commits through the conflict path even though the live\r\nPOST path rejects the identical block. In a local harness I settled a lease\r\n~72 hours past its grace window using attestations ~3 days old (median still\r\ninside the grace window): the live path rejected the block with \"only 0 valid\r\nattestations from trusted timekeepers, need 2\", while the conflict path\r\ncommitted it, burned the escrow, and minted 667 µXE of emission. The grace\r\nwindow — the mechanism that is supposed to make a late settle impossible — is\r\nbypassed entirely on this path.\r\n\r\n## What I did\r\n\r\nAll testing in a local Go harness against the public repo (HEAD 02e9641).\r\n**testnet-0005 was not touched, no live XUSD was used, no local testnet was\r\nrun, and no other user's funds, keys, or workloads were involved.**\r\n\r\nHarness: `poc-n1/main.go` (package `main` inside a clone of the repo, same\r\nmodule). Go 1.27.3. Simulated clock via `core.Now`. Genesis overridden with a\r\nlocal keypair whose representative holds 100% of the delegated weight;\r\n`Difficulty=0`; local timekeeper threshold 2. XUSD/XE balances seeded via the\r\ntest helpers `MintForTesting` / `SeedAssetForTesting`.\r\n\r\nScenario:\r\n1. T0: consumer opens a lease (60 s duration, cost 667 µXUSD); provider\r\n   accepts with attestations @T0, `LockedR=1000` → emission 667 µXE. Expiry\r\n   T0+60 s, grace until T0+3660 s. Lease + accept finalized.\r\n2. T0+3 days: the lease is ~71 h 59 min past its grace window.\r\n3. Control: the same stale `lease_settle` (attestations @T0+30 min, median\r\n   inside the grace window) submitted via `AddBlock` with no sibling.\r\n4. Exploit: provider first commits a `send` sibling on the same `Previous`\r\n   (the accept hash), then submits the stale `lease_settle` ground (via\r\n   `Timestamp`, 1 ns steps, 3 tries) to the lowest hash so the rep prefers\r\n   it. Rep final-votes it; `confirmConflict` → `SwapBlock` → commit.\r\n\r\nThe harness was run **5 times in a row; all 5 runs were identical** (same\r\nhashes, same control rejection, same exploit outcome, same balances, exit 0,\r\n`N-1 REPRODUCED`).\r\n\r\n## What happened\r\n\r\n**Control — live path (AddBlock, no sibling): REJECTED**\r\n- Settle hash\r\n  `fc05c86525ac421d66c6539387eedf761484b76b6dcde7b618e97f6b25f91319`\r\n- `AddBlock rejected as expected: lease_settle attestation: only 0 valid attestations from trusted timekeepers, need 2`\r\n\r\n**Exploit — conflict path (SwapBlock): COMMITTED**\r\n- Send sibling committed first:\r\n  `49316a2498f685ac103e58b7d0b293a32e85e902256d4a8474e07bd029116cc6`\r\n- Stale settle (attestations @T0+30 min) ground to the lowest hash:\r\n  `0ddba5d60182d53105406f077c493b49d9dc399f81a56373d3dd3e4a559f3b12`\r\n  (3 tries)\r\n- Conflict recorded (`totalWeight=42000000000000`); rep final-voted the\r\n  settle (weight 42000000000000 = 100%); `confirmConflict` → `SwapBlock` →\r\n  commit.\r\n- Verified outcome: settle on-chain and at the frontier; the send is removed\r\n  from the canonical chain (status Rejected); escrow pending is gone; lease\r\n  state = `settled`; provider XE balance 1,000,000 → **1,000,667** (667 µXE\r\n  of emission minted).\r\n\r\n## Impact\r\n\r\n- The settle grace window is bypassed on the conflict path: a provider can\r\n  settle a lease long after expiry+grace, burning the escrow and minting\r\n  emission the protocol says should not be minted after grace.\r\n- The same bypass applies to the sibling block types validated through the\r\n  same path: `lease_accept` locks stale-epoch emission parameters\r\n  (`validateLockedEmissionAt` reads the stale time) and `lease_force_settle`\r\n  refunds at a stale `forceTime`.\r\n- Cheap to attempt in principle: it needs one lease, one conflicting send,\r\n  and the stale block ground to the lowest hash (the rep auto-votes the\r\n  lowest hash among candidates it knows).\r\n- This is Medium, not High: on a live network the attacker must win a race —\r\n  both siblings must be visible to the rep within the ~3 second stability\r\n  window, and the stale block must be the lowest hash among the candidates\r\n  the rep knows. The harness also simplifies the network (see Notes).\r\n\r\n## Expected behavior\r\n\r\nConflict promotion should apply the same attestation freshness check as the\r\nlive path, or stale-attestation blocks should be rejected at staging /\r\n`promotable` time. A block that the live path rejects for stale attestations\r\nshould not become committable by being wrapped in a conflict.\r\n\r\n## Root cause (code, public repo HEAD 02e9641)\r\n\r\n- `core/ledger.go:3003` (`SwapBlock`): calls\r\n  `dispatchValidateAndAdd(newBlock, true)` — the `true` is `skipTimestamp`,\r\n  which `lease_settle` treats as `skipSkew=true`. In\r\n  `validateAndAddLeaseSettle` (`core/ledger.go:2117-2250`) this reaches\r\n  `ValidateAttestations(..., skipSkew=true)`, skipping the ±10 minute\r\n  attestation freshness check; the median-time gate\r\n  (`settleTime >= expiry && settleTime <= expiry+Grace`,\r\n  `core/ledger.go:2161-2175`) then reads the stale median and passes.\r\n- `core/quorum.go:236-266` (`promotable`): only runs `ValidateStagedBlock`,\r\n  which for `lease_settle` / `lease_accept` / `lease_force_settle` only\r\n  checks balance + pending escrow — no attestation check\r\n  (`core/ledger.go:2732-2862`).\r\n- `core/finalization.go:139` (`castVoteLocked`) → `lowestHash`\r\n  (`core/vote.go:271`): the rep automatically votes the lowest-hash sibling,\r\n  so a ground stale block wins the vote.\r\n\r\n## Relation to XE-0010 (not a duplicate)\r\n\r\nXE-0010 (Accepted) is about the same *kind* of gap on a different path: sync\r\ningestion (`AddSyncedBlock`) skips the freshness check. This report is a\r\ndifferent code path (`SwapBlock`, conflict-winner promotion), a different\r\nentry point, and a sharper impact (grace-window bypass + emission minted,\r\nversus a lapsed renewal committing as history). A fix that only touches the\r\nsync path does not close this path. XE-0010 itself states its scope is\r\n\"the /xe/sync path\" and does not mention `SwapBlock` or promotion.\r\n\r\n## Reproduction steps\r\n\r\n1. Clone the public repo at HEAD 02e9641; Go ≥ 1.25.\r\n2. Place the harness at `poc-n1/main.go` (package `main`, same module) and\r\n   run from the repo root: `go run ./poc-n1`\r\n3. Observe the control: the stale settle is rejected on the live path\r\n   (\"only 0 valid attestations from trusted timekeepers, need 2\").\r\n4. Observe the exploit: the send sibling commits, the stale settle is ground\r\n   to the lowest hash, the rep final-votes it, `confirmConflict` →\r\n   `SwapBlock` commits it, and the provider balance goes 1,000,000 →\r\n   1,000,667 µXE.\r\n5. Re-run 5 times — the harness is deterministic (identical hashes and\r\n   verdicts in all 5 runs).\r\n\r\n## Evidence\r\n\r\n- Harness: `poc-n1/main.go` (attached).\r\n- Full logs of the 5 verification runs: `rerun-20261110-1.log` …\r\n  `rerun-20261110-5.log` (all exit 0, `N-1 REPRODUCED`; identical except\r\n  for the wall-clock second in the genesis log line).\r\n- Earlier full log + result summary: `run-20261110-3.log`, `RESULT.md`.\r\n- Key hashes (identical in all 5 runs): control settle\r\n  `fc05c86525ac421d66c6539387eedf761484b76b6dcde7b618e97f6b25f91319`; send\r\n  sibling\r\n  `49316a2498f685ac103e58b7d0b293a32e85e902256d4a8474e07bd029116cc6`;\r\n  exploit settle\r\n  `0ddba5d60182d53105406f077c493b49d9dc399f81a56373d3dd3e4a559f3b12`.\r\n\r\n## Notes\r\n\r\n- The harness simplifies the network: one rep holds 100% of the delegated\r\n  weight (similar to the public ldn node's dominance on testnet-0005, but\r\n  still a simplification) and `Difficulty=0`. On a live network there is a\r\n  race: the rep has a ~3 second stability window, so the attacker must make\r\n  both siblings visible to the rep within that window, since `castVoteLocked`\r\n  picks the lowest hash among the candidates it already knows.\r\n- Side finding while building the harness: `PoWNonce` is NOT part of the\r\n  block-hash preimage (`HashBlock` = canonical + aux; the nonce only appears\r\n  in the binary wire format `MarshalBlock`). Hash grinding must therefore go\r\n  through a hashed field — in this PoC, `Timestamp` in 1 ns steps, staying\r\n  inside the ±1 hour window. \"Grind the nonce to the lowest hash\" does not\r\n  work as-is on the live network.\r\n- `lease_renew` cannot be a conflict candidate on this path:\r\n  `ValidateStagedBlock` has no `case BlockLeaseRenew` → \"staged block:\r\n  unknown type: lease_renew\" (`core/ledger.go:2867`; = GitHub #4 F3.3). So\r\n  this report is specifically about settle / accept / force-settle.\r\n- No testnet-0005 interaction, no live XUSD, no local testnet, no other\r\n  user's funds, keys, or workloads were touched.","patch_refs":[],"thread":[{"id":5585,"source":"desk","source_ref":"reply:4259","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-2530 and says what differs; it is read like any other.","created_at":"2026-11-15T11:08:46.745488+00:00"}]}