{"id":"XE-9701","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Staged Block Validation Bypass: ValidateStagedBlock omits asset matching, destination validation, and memo validation on BlockReceive and BlockSend","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1096","internal_url":"https://github.com/xeprotocol/core/issues/1096","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T06:31:44.514938+00:00","updated_at":"2026-11-20T00:33:21.646534+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:21.673340+00:00","status_changed_at":"2026-11-20T00:33:21.654622+00:00","url":"https://bounty.xe.network/XE-9701","body":"## Vulnerability Summary\n\nIn `core/ledger.go:2732-2870`, `ValidateStagedBlock(b *Block, parentBalance uint64) error` performs consensus validation on candidate blocks competing in BFT quorum elections before they are promoted or staged.\n\nNormal block ingestion pipelines enforce critical structural protocol invariants:\n1. In `validateAndAddReceive` (`core/ledger.go:1107-1114`):\n   ```go\n   pendingAsset := pending.Asset\n   if pendingAsset == \"\" {\n       pendingAsset = \"XE\"\n   }\n   if b.Asset != pendingAsset {\n       return fmt.Errorf(\"receive asset %q does not match pending send asset %q\", b.Asset, pendingAsset)\n   }\n   ```\n   And `ValidateMemo(b.Memo)` is enforced during block verification/parsing (`core/encoding.go:79`).\n2. In `validateAndAddSend` (`core/ledger.go:999-1009`):\n   ```go\n   if err := ValidateMemo(b.Memo); err != nil {\n       return fmt.Errorf(\"send: %w\", err)\n   }\n   ```\n\nHowever, inside `ValidateStagedBlock` (`core/ledger.go:2740-2778`):\n```go\n\tcase BlockSend:\n\t\tif b.Amount == 0 {\n\t\t\treturn fmt.Errorf(\"staged send: amount must be > 0\")\n\t\t}\n\t\tif b.Amount > parentBalance {\n\t\t\treturn fmt.Errorf(\"staged send: insufficient balance: have %d, sending %d\", parentBalance, b.Amount)\n\t\t}\n\t\tif b.Balance != parentBalance-b.Amount {\n\t\t\treturn fmt.Errorf(\"staged send: balance mismatch: expected %d, got %d\", parentBalance-b.Amount, b.Balance)\n\t\t}\n\t\tif b.Destination == \"\" {\n\t\t\treturn fmt.Errorf(\"staged send: must have a destination\")\n\t\t}\n\t\tif b.Destination == b.Account {\n\t\t\treturn fmt.Errorf(\"staged send: cannot send to self\")\n\t\t}\n        // MISSING: ValidateMemo(b.Memo)\n\n\tcase BlockReceive:\n\t\tif b.Source == \"\" {\n\t\t\treturn fmt.Errorf(\"staged receive: must reference a source send\")\n\t\t}\n\t\tpending, err := l.store.GetPendingSend(b.Source)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"staged receive: GetPendingSend: %w\", err)\n\t\t}\n\t\tif pending == nil {\n\t\t\treturn fmt.Errorf(\"staged receive: source send not pending: %s\", shortHash(b.Source))\n\t\t}\n\t\tif pending.Destination != b.Account {\n\t\t\treturn fmt.Errorf(\"staged receive: send not addressed to this account\")\n\t\t}\n\n\t\tif l.isLiveLeaseEscrow(b.Source) {\n\t\t\treturn fmt.Errorf(\"staged receive: cannot receive a live lease escrow: %s\", shortHash(b.Source))\n\t\t}\n\t\texpectedBal := parentBalance + pending.Amount\n\t\tif expectedBal < parentBalance {\n\t\t\treturn fmt.Errorf(\"staged receive: balance would overflow uint64\")\n\t\t}\n\t\tif b.Balance != expectedBal {\n\t\t\treturn fmt.Errorf(\"staged receive: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n        // MISSING: b.Asset != pendingAsset check!\n        // MISSING: Destination must be empty (\"\") check!\n        // MISSING: ValidateMemo(b.Memo)\n```\n\nNotice that `ValidateStagedBlock` for `BlockReceive` **completely omits checking that `b.Asset` matches `pending.Asset`**!\nFurthermore, it does not check that `b.Destination == \"\"` on a receive block, nor does it enforce `ValidateMemo(b.Memo)` on staged sends and receives.\n\n---\n\n## Vulnerable Code Locations\n\n- `core/ledger.go:2752-2778`:\n  `case BlockReceive` compares `b.Source`, `pending.Destination`, `isLiveLeaseEscrow`, and updates `b.Balance` based on `pending.Amount`. However, it never compares `b.Asset` with `pending.Asset`!\n- `core/ledger.go:2740-2751`:\n  `case BlockSend` omits memo validation `ValidateMemo(b.Memo)`.\n\n---\n\n## Attack & Failure Scenario\n\n1. **Cross-Asset Balance Inflation / Stealing via Quorum Staging**:\n   - Alice has a pending send of 1,000 XE from Bob (`pending.Asset = \"XE\"`, `pending.Amount = 1000`).\n   - Alice creates a conflicting `BlockReceive` with `b.Asset = \"XUSD\"`, referencing Bob's pending send hash `b.Source`.\n   - In a quorum election on Alice's account, representative nodes execute `ValidateStagedBlock(candidate, parentBalance)`.\n   - `ValidateStagedBlock` checks `pending.Amount == 1000`, adds it to `parentBalance`, and verifies `b.Balance`. **It never verifies that `b.Asset == pending.Asset`**!\n   - The candidate block wins the quorum vote, is promoted via `confirmConflict` / `swapBlockLocked`, and Alice's account now has 1,000 XUSD instead of 1,000 XE on the canonical chain!\n2. **Permanent Consensus Split / Chain Fork**:\n   - Nodes performing standard block synchronization (`validateAndAddReceive`) verify:\n     ```go\n     if b.Asset != pendingAsset {\n         return fmt.Errorf(\"receive asset %q does not match pending send asset %q\", b.Asset, pendingAsset)\n     }\n     ```\n   - When peers syncing from scratch or from network gossip ingest this block, `validateAndAddReceive` throws an asset mismatch error and rejects the block.\n   - The network fractures into a permanent consensus fork: nodes participating in the quorum conflict accepted the block, while standard sync nodes reject it as invalid!\n\n---\n\n## Impact\n\n1. **Cross-Asset Arbitrary Conversion / Balance Manipulation**:\n   Attackers can receive XE pending transfers as high-value XUSD balances by winning staged conflict elections, bypassing the protocol's currency division.\n2. **Consensus Desynchronization / Chain Partition**:\n   Discrepancies between `ValidateStagedBlock` and `validateAndAddReceive` allow invalid cross-asset blocks into the staged/canonical state, causing follower nodes to permanently diverge from representative nodes.\n\n---\n\n## Remediation\n\n1. In `core/ledger.go`, update `ValidateStagedBlock` for `BlockReceive` to strictly check asset parity:\n   ```go\n   case BlockReceive:\n       ...\n       pendingAsset := pending.Asset\n       if pendingAsset == \"\" {\n           pendingAsset = \"XE\"\n       }\n       if b.Asset != pendingAsset {\n           return fmt.Errorf(\"staged receive: asset %q does not match pending send asset %q\", b.Asset, pendingAsset)\n       }\n       if b.Destination != \"\" {\n           return fmt.Errorf(\"staged receive: must not have destination\")\n       }\n       if err := ValidateMemo(b.Memo); err != nil {\n           return fmt.Errorf(\"staged receive: %w\", err)\n       }\n   ```\n2. For `BlockSend`, ensure memo validation is enforced:\n   ```go\n   case BlockSend:\n       ...\n       if err := ValidateMemo(b.Memo); err != nil {\n           return fmt.Errorf(\"staged send: %w\", err)\n       }\n   ```","patch_refs":[],"thread":[{"id":13269,"source":"desk","source_ref":"reply:11291","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-9701 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:21.646534+00:00"}]}