{"id":"XE-2543","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":464,"title":"Receive blocks accept an arbitrary Amount that is neither validated nor signed — forged \"received\" amounts display in the official explorer","area":"leasing-ledger","claimed_tier":"minor","assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0060","tracked":true,"internal_ref":"#1102","internal_url":"https://github.com/xeprotocol/core/issues/1102","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-10T04:30:43.412832+00:00","updated_at":"2026-11-16T10:40:12.433042+00:00","source_created_at":null,"told_at":"2026-11-15T11:08:50.221209+00:00","status_changed_at":"2026-11-15T11:08:50.197738+00:00","url":"https://bounty.xe.network/XE-2543","body":"## Summary\r\n\r\nA `receive` block can carry any `Amount` value: `validateAndAddReceive`\r\nnever compares it with the pending send's amount, and `Amount` is not part\r\nof the block-hash preimage for receives, so it is also not covered by the\r\nblock's ed25519 signature. In a local harness I committed a receive claiming\r\n`Amount = 1,000,000,000` for a real transfer of 100 XE, then changed the\r\namount post-signing to 5,000,000,000 without changing the block hash or\r\nbreaking signature verification. On-chain balances are unaffected (they are\r\nderived from the send/pending, not from receive `Amount`), but the official\r\nexplorer displays `b.amount` for receive blocks, so a crafted receive shows\r\na fake \"received 1,000,000,000 XE\" in the official UI — and any off-chain\r\nintegrator reading receive `Amount` is misled the same way.\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-m1/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\r\na local keypair (same pattern as the accepted XE-2530 harness);\r\n`Difficulty=0`. Balances seeded via the test helper `SeedAssetForTesting`.\r\n\r\nScenario:\r\n1. T0: account A seeded with 1,000 XE; A sends 100 XE to B (pending\r\n   created).\r\n2. Exploit: B submits a receive with `Amount = 1,000,000,000` but the\r\n   correct `Balance` (= 0 + 100). `AddBlock` must accept it.\r\n3. Mutation: take the committed receive, change `Amount` post-signing to\r\n   5,000,000,000, and recompute `HashBlock` / `VerifyBlock` / the ed25519\r\n   signature check.\r\n4. Control: a receive with the correct `Amount` (100) but a wrong `Balance`\r\n   (999) must be rejected; the correct receive afterwards must succeed.\r\n\r\nThe harness was run **3 times in a row; all 3 runs were identical** (same\r\nhashes, same acceptance/rejection, same balances, exit 0, `M-1\r\nREPRODUCED`).\r\n\r\n## What happened\r\n\r\n**Exploit — lying receive: ACCEPTED**\r\n- Send A→B 100 XE hash\r\n  `58644d085da35a28f005aa1e7f12f2bc937e8d180bde03a01a325a7c4e8e5b5c`\r\n- Receive (B, first block on the account) with `Amount=1,000,000,000`,\r\n  `Balance=100` hash\r\n  `f68b15334cb847249ef5145495a19d3bd931c3847b289f3cb14d5e96996573c0`\r\n- `AddBlock` ACCEPTED it; the stored block carries\r\n  `Amount=1000000000`; B's XE balance is 100 (derived from pending, not\r\n  from `Amount`); the escrow pending is consumed.\r\n- Post-signing mutation (`Amount` 1,000,000,000 → 5,000,000,000):\r\n  `HashBlock` is UNCHANGED\r\n  (`f68b15334cb847249ef5145495a19d3bd931c3847b289f3cb14d5e96996573c0`);\r\n  `VerifyBlock` on the mutated block still passes; the ed25519 signature\r\n  still verifies against the same hash.\r\n\r\n**Bonus proof (free from the control run):** the honest receive\r\n(`Amount=100`, `Balance=100`) has the IDENTICAL hash `f68b1533…` as the\r\nlying receive (`Amount=1,000,000,000`) — two blocks differing ONLY in\r\n`Amount` hash identically, which is direct proof that `Amount` is not in\r\nthe hash preimage.\r\n\r\n**Control — wrong Balance: REJECTED**\r\n- Receive `Amount=100`, `Balance=999` → rejected:\r\n  `open-receive balance mismatch: expected 100, got 999`\r\n- The correct receive afterwards (`Amount=100`, `Balance=100`) → accepted.\r\n  This proves the harness validates correctly and ONLY `Amount` escapes\r\n  validation.\r\n\r\n## Impact\r\n\r\n- A receive block can state any received amount, and the value is stored\r\n  verbatim by every node. The official explorer renders it:\r\n  `blockAmount()` in `web/assets/block.js:106-115` returns\r\n  `formatAmount(b.amount, b.asset)` for type `receive`. A crafted receive\r\n  therefore displays as e.g. \"received 1,000,000,000 XE\" in the official\r\n  UI, while the account's real balance (shown in the balance column) is\r\n  only 100 XE. The same misleading value reaches any off-chain integrator\r\n  or payment processor that reads receive `Amount`.\r\n- Because `Amount` is also outside the hash preimage, the value can be\r\n  altered after signing by anyone relaying the block (peer, API, indexer)\r\n  without invalidating the hash or the signature — the tampered block still\r\n  verifies.\r\n- This is Minor, not Medium: there is no on-chain effect. Balances\r\n  (`rebuildAssetBalances`, `GetAssetBalanceAtBlock`), rollback undo\r\n  (rebuilt from the source send block), and the supply auditor\r\n  (`termsFromChain`) all derive from the send/pending, never from receive\r\n  `Amount`. No funds can be created or lost through this gap and there is\r\n  no consensus split. It is a data-integrity / display-trust issue, not a\r\n  funds-safety issue.\r\n\r\n## Expected behavior\r\n\r\n`validateAndAddReceive` should reject a receive whose `Amount` differs from\r\n`pending.Amount` (as `validateAndAddSend` already validates its own\r\n`Amount`), and/or `Amount` should be included in the canonical encoding\r\nfor receives (or the field removed if it is intentionally unused). A block\r\nfield that the official UI displays as a received amount should not be\r\nfreely forgeable and unsigned.\r\n\r\n## Root cause (code, public repo HEAD 02e9641)\r\n\r\n- `core/ledger.go:1081-1160` (`validateAndAddReceive`): the only amount\r\n  check is on the derived `Balance` (`b.Balance == oldBal +\r\n  pending.Amount`, or `b.Balance == pending.Amount` for an open-receive).\r\n  `b.Amount` is never compared with `pending.Amount`. Compare with\r\n  `validateAndAddSend` (`core/ledger.go:972`), which validates\r\n  `Amount > 0`, `Amount <= balance`, and the exact `Balance`.\r\n- `core/encoding.go:139` (`MarshalBlockCanonical`, `case BlockReceive`):\r\n  only `Source` is written — `Amount` is absent. `MarshalBlockAux`\r\n  (`core/encoding.go:301-331`) carries nothing for receives (only lease\r\n  types get certificate/attestation aux data, plus an optional declared\r\n  pubkey). Therefore `HashBlock` (`core/crypto.go:85-99`,\r\n  `sha256(networkID || canonical || aux)`) does not cover `Amount`, and\r\n  the ed25519 signature (over the hash) does not cover it either.\r\n- `web/assets/block.js:106-115` (`blockAmount()`): returns\r\n  `formatAmount(b.amount, b.asset)` for `receive`, i.e. the UI trusts the\r\n  unsigned, unvalidated field.\r\n- The field is vestigial on every on-chain path, which is why the gap went\r\n  unnoticed: `Amount uint64 \\`json:\"amount,omitempty\"\\``\r\n  (`core/types.go:74`); live, all 37 recent receives carry `Amount` absent\r\n  (= 0) — no client fills it.\r\n\r\n## Relation to existing receive tickets (not a duplicate)\r\n\r\nI checked the desk ticket list (2026-11-10). The existing receive tickets\r\nall cover different mechanisms:\r\n- XE-2447 (New, 9 Nov): receive *timestamp* outside the skew window.\r\n- XE-1733 (claimed Minor): the SDK `receive()` signs a pending without\r\n  checking — SDK layer, not ledger validation.\r\n- XE-0479: SDK frontier + receive opening block.\r\n- XE-0253: SDK `receiveAll` abort on a lease escrow.\r\n- XE-0137: descendant-receive race in swap leading to supply inflation.\r\nNone of them is about ledger-level validation of receive `Amount`, or about\r\n`Amount` being outside the hash preimage. This report is a different\r\nmechanism (ledger validation + encoding/hash coverage), a different entry\r\npoint, and a different impact (display trust, not supply or SDK behavior).\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-m1/main.go` (package `main`, same module) and\r\n   run from the repo root: `go run ./poc-m1`\r\n3. Observe the exploit: the receive with `Amount=1,000,000,000` and correct\r\n   `Balance=100` is accepted; the stored block carries Amount 1e9 while B's\r\n   balance is 100; mutating `Amount` to 5,000,000,000 leaves `HashBlock`\r\n   unchanged and `VerifyBlock` + the ed25519 signature still pass.\r\n4. Observe the control: the receive with `Balance=999` is rejected\r\n   (`open-receive balance mismatch: expected 100, got 999`); the correct\r\n   receive afterwards is accepted.\r\n5. Re-run 3 times — the harness is deterministic (identical hashes and\r\n   verdicts in all 3 runs).\r\n\r\n## Evidence\r\n\r\n- Harness: `poc-m1/main.go` (attached).\r\n- Full logs of the 3 verification runs: `rerun-20261110-1.log` …\r\n  `rerun-20261110-3.log` (all exit 0, `M-1 REPRODUCED`; identical except\r\n  for the wall-clock second in the genesis log line).\r\n- Result summary: `RESULT.md`.\r\n- Key hashes (identical in all 3 runs): send\r\n  `58644d085da35a28f005aa1e7f12f2bc937e8d180bde03a01a325a7c4e8e5b5c`;\r\n  lying receive AND honest receive (same hash — the point of the bug)\r\n  `f68b15334cb847249ef5145495a19d3bd931c3847b289f3cb14d5e96996573c0`;\r\n  wrong-Balance receive\r\n  `13dffdcbf76b90e88bebbce7d3274276febe830639fa2828d9e569a4664582dc`.\r\n\r\n## Notes\r\n\r\n- The harness simplifies the network: one local ledger, memory store,\r\n  `Difficulty=0`, simulated clock. No live network behavior is involved —\r\n  the claim is about validation and encoding logic, which the harness\r\n  exercises directly against the same code the node runs.\r\n- Honest caveat: the impact is off-chain only, and the field may be\r\n  intentionally unused on-chain (all live clients leave it at 0). If the\r\n  team considers receive `Amount` a vestigial field, the minimal fix is to\r\n  stop displaying it in the explorer; if it is meant to be meaningful, it\r\n  should be validated against `pending.Amount` and included in the\r\n  canonical encoding. Either way, an unsigned, unvalidated field that the\r\n  official UI presents as a received amount is a trust issue worth fixing.\r\n- Suggested fix (trivial): in `validateAndAddReceive`, add\r\n  `if b.Amount != pending.Amount { return error }`; and/or include\r\n  `Amount` in the canonical encoding for `BlockReceive` (or remove the\r\n  field from the struct and the explorer).\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":5584,"source":"desk","source_ref":"reply:4258","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0060, 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-2543 and says what differs; it is read like any other.","created_at":"2026-11-15T11:08:46.745488+00:00"}]}