{"id":"XE-9686","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Staged Block Validation Bypass: ValidateStagedBlock omits structural field constraints and memo restrictions on BlockMint and BlockBurn","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:26:30.846047+00:00","updated_at":"2026-11-20T00:33:21.732114+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:21.757008+00:00","status_changed_at":"2026-11-20T00:33:21.742012+00:00","url":"https://bounty.xe.network/XE-9686","body":"## Vulnerability Summary\n\nIn `core/ledger.go:2732-2870`, `ValidateStagedBlock(b *Block, parentBalance uint64) error` performs validation on candidate blocks competing in a BFT quorum election before they are promoted or staged.\n\nNormal block ingestion via `validateAndAddBurn` (`core/ledger.go:1026-1069`) and `validateAndAddMint` (`core/mint.go:28-80`) strictly enforces protocol invariants regarding forbidden routing fields, non-zero values, and memo restrictions:\n\n### For `BlockBurn`:\n- `if b.Destination != \"\" || b.Source != \"\" { return fmt.Errorf(\"burn: must not have source or destination\") }`\n- `if err := ValidateMemo(b.Memo); err != nil { return fmt.Errorf(\"burn: %w\", err) }`\n\n### For `BlockMint`:\n- `if b.Destination != \"\" || b.Source != \"\" { return fmt.Errorf(\"mint: must not have source or destination\") }`\n- `if b.Memo != \"\" { return fmt.Errorf(\"mint: memo not allowed\") }`\n\nHowever, in `ValidateStagedBlock` (`core/ledger.go:2839-2869`), these structural checks are **completely omitted**:\n\n```go\n\tcase BlockBurn:\n\t\tif b.Asset != \"XE\" {\n\t\t\treturn fmt.Errorf(\"staged burn: restricted to XE\")\n\t\t}\n\t\tif b.Amount == 0 {\n\t\t\treturn fmt.Errorf(\"staged burn: amount must be > 0\")\n\t\t}\n\t\tif b.Amount > parentBalance {\n\t\t\treturn fmt.Errorf(\"staged burn: insufficient balance: have %d XE, burning %d\", parentBalance, b.Amount)\n\t\t}\n\t\tif b.Balance != parentBalance-b.Amount {\n\t\t\treturn fmt.Errorf(\"staged burn: balance mismatch: expected %d, got %d\", parentBalance-b.Amount, b.Balance)\n\t\t}\n        // MISSING: check that Destination == \"\" and Source == \"\"\n        // MISSING: ValidateMemo(b.Memo)\n\n\tcase BlockMint:\n\t\tif b.Asset != \"XUSD\" {\n\t\t\treturn fmt.Errorf(\"staged mint: restricted to XUSD\")\n\t\t}\n\t\tif !l.isMinter(b.Account) {\n\t\t\treturn fmt.Errorf(\"staged mint: account %s is not an authorized minter\", shortAddr(b.Account))\n\t\t}\n\t\tif b.Amount == 0 {\n\t\t\treturn fmt.Errorf(\"staged mint: amount must be > 0\")\n\t\t}\n\t\texpectedBal := parentBalance + b.Amount\n\t\tif expectedBal < parentBalance {\n\t\t\treturn fmt.Errorf(\"staged mint: balance would overflow uint64\")\n\t\t}\n\t\tif b.Balance != expectedBal {\n\t\t\treturn fmt.Errorf(\"staged mint: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n        // MISSING: check that Destination == \"\" and Source == \"\"\n        // MISSING: check that b.Memo == \"\"\n```\n\n---\n\n## Vulnerable Code Locations\n\n1. `core/ledger.go:2839-2851`:\n   `case BlockBurn` checks only asset, amount > 0, parent balance, and balance equation. It omits checking `b.Destination == \"\"` and `b.Source == \"\"`, as well as `ValidateMemo(b.Memo)`.\n2. `core/ledger.go:2852-2869`:\n   `case BlockMint` omits verifying that `b.Destination == \"\"` and `b.Source == \"\"`, and omits verifying that `b.Memo == \"\"`.\n\n---\n\n## Attack & Failure Scenario\n\n1. An authorized minter (or an attacker generating a conflicting burn block on their account during a reorg/fork) constructs a `BlockMint` or `BlockBurn` with malicious, oversized, or smuggling fields:\n   - For example, a `BlockMint` populated with `b.Destination = \"xe_victim_account\"` and a non-empty `b.Memo`.\n   - Or a `BlockBurn` populated with an unvalidated arbitrary-length memo (> 256 bytes or illegal UTF-8 / control characters) or a phantom `b.Source` / `b.Destination`.\n2. When injected into an active conflict or quorum vote election, peer nodes execute `ValidateStagedBlock(candidate, parentBalance)`.\n3. Because `ValidateStagedBlock` omits these checks, the malformed block passes validation and is accepted into `stagedStore` via `PutStagedBlock` and promoted via `confirmConflict` / `swapBlockLocked`.\n4. When `swapBlockLocked` calls `commitBlockWrite`, the block is permanently appended to the canonical chain.\n5. In downstream P2P sync and ledger verification:\n   - Nodes syncing the block through standard ingestion pipelines (`validateAndAddMint` or `validateAndAddBurn`) reject the block due to `b.Destination != \"\"` or `b.Memo != \"\"`.\n   - The network suffers an immediate **consensus split / chain fork**: nodes that staged the block via quorum consider it canonical, while nodes receiving the block via normal sync reject it as invalid!\n\n---\n\n## Impact\n\n1. **Permanent Network Fork / Consensus Split**:\n   Inconsistent validation invariants between live block ingestion and staged conflict resolution allow blocks with illegal routing fields or forbidden memos to enter the chain, causing peers syncing from scratch to reject the chain.\n2. **Protocol Smuggling & Storage Bloat**:\n   Attackers can smuggle arbitrary metadata into `BlockMint` and oversized unvalidated memos into `BlockBurn` past the consensus validation layer.\n\n---\n\n## Remediation\n\nIn `core/ledger.go`, update `ValidateStagedBlock`:\n\n```go\n\tcase BlockBurn:\n\t\tif b.Asset != \"XE\" {\n\t\t\treturn fmt.Errorf(\"staged burn: restricted to XE\")\n\t\t}\n\t\tif b.Destination != \"\" || b.Source != \"\" {\n\t\t\treturn fmt.Errorf(\"staged burn: must not have source or destination\")\n\t\t}\n\t\tif b.Amount == 0 {\n\t\t\treturn fmt.Errorf(\"staged burn: amount must be > 0\")\n\t\t}\n\t\tif b.Amount > parentBalance {\n\t\t\treturn fmt.Errorf(\"staged burn: insufficient balance: have %d XE, burning %d\", parentBalance, b.Amount)\n\t\t}\n\t\tif b.Balance != parentBalance-b.Amount {\n\t\t\treturn fmt.Errorf(\"staged burn: balance mismatch: expected %d, got %d\", parentBalance-b.Amount, b.Balance)\n\t\t}\n\t\tif err := ValidateMemo(b.Memo); err != nil {\n\t\t\treturn fmt.Errorf(\"staged burn: %w\", err)\n\t\t}\n\n\tcase BlockMint:\n\t\tif b.Asset != \"XUSD\" {\n\t\t\treturn fmt.Errorf(\"staged mint: restricted to XUSD\")\n\t\t}\n\t\tif !l.isMinter(b.Account) {\n\t\t\treturn fmt.Errorf(\"staged mint: account %s is not an authorized minter\", shortAddr(b.Account))\n\t\t}\n\t\tif b.Destination != \"\" || b.Source != \"\" {\n\t\t\treturn fmt.Errorf(\"staged mint: must not have source or destination\")\n\t\t}\n\t\tif b.Memo != \"\" {\n\t\t\treturn fmt.Errorf(\"staged mint: memo not allowed\")\n\t\t}\n\t\tif b.Amount == 0 {\n\t\t\treturn fmt.Errorf(\"staged mint: amount must be > 0\")\n\t\t}\n\t\texpectedBal := parentBalance + b.Amount\n\t\tif expectedBal < parentBalance {\n\t\t\treturn fmt.Errorf(\"staged mint: balance would overflow uint64\")\n\t\t}\n\t\tif b.Balance != expectedBal {\n\t\t\treturn fmt.Errorf(\"staged mint: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n```","patch_refs":[],"thread":[{"id":13271,"source":"desk","source_ref":"reply:11293","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-9686 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:21.732114+00:00"}]}