{"id":"XE-9772","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Staged Block Validation Bypass: ValidateStagedBlock omits consumer authorization, lease state check, and asset verification on BlockLeaseCancel","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":"XE-0028","tracked":true,"internal_ref":"#1094","internal_url":"https://github.com/xeprotocol/core/issues/1094","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T07:02:52.687145+00:00","updated_at":"2026-11-20T00:33:19.023248+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:19.045607+00:00","status_changed_at":"2026-11-20T00:33:19.030515+00:00","url":"https://bounty.xe.network/XE-9772","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 staging or promotion to the canonical ledger.\n\nWhen `BlockLeaseCancel` is ingested normally through `validateAndAddLeaseCancel` (`core/ledger.go:1792-1877`), the node strictly verifies:\n1. `b.Asset == \"XUSD\"` (`core/ledger.go:1793-1795`).\n2. `leaseBlock.Account == b.Account` ensuring only the original consumer can cancel their own lease (`core/ledger.go:1809-1811`).\n3. `existing.State == LeaseCreated` (or `LeaseAccepted` with resolve winner), explicitly forbidding cancelling settled, expired, or force-settled leases:\n   ```go\n   if existing != nil && existing.State != LeaseCreated {\n       return fmt.Errorf(\"cannot cancel lease in %s state\", existing.State)\n   }\n   ```\n4. `pending.Asset == \"XUSD\"` matching the returned escrow balance.\n\nHowever, in `ValidateStagedBlock` (`core/ledger.go:2809-2820`):\n```go\n\tcase BlockLeaseCancel:\n\t\tpending, err := l.store.GetPendingSend(b.Source)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: GetPendingSend: %w\", err)\n\t\t}\n\t\tif pending == nil {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: no pending send for lease\")\n\t\t}\n\t\texpectedBal := parentBalance + pending.Amount\n\t\tif b.Balance != expectedBal {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n```\n\nNotice the critical omissions in `ValidateStagedBlock` for `BlockLeaseCancel`:\n1. **Never checks `b.Asset == \"XUSD\"`**: It allows arbitrary asset tags (e.g. minting `XE` or cross-asset balance manipulation).\n2. **Never checks consumer authorization (`leaseBlock.Account == b.Account`)**: Any third-party attacker account can stage a `BlockLeaseCancel` referencing another user's lease escrow (`b.Source`) and steal the escrow amount into their own balance!\n3. **Never inspects lease state (`l.store.GetLease`)**: An active, settled, or force-settled lease escrow can be cancelled and double-refunded during staged conflict resolution!\n\n---\n\n## Vulnerable Code Locations\n\n- `core/ledger.go:2809-2820`:\n  `ValidateStagedBlock` for `BlockLeaseCancel` checks only that `l.store.GetPendingSend(b.Source)` exists and matches `b.Balance == parentBalance + pending.Amount`. It omits consumer ownership verification, lease state verification, and asset matching.\n\n---\n\n## Attack & Failure Scenario\n\n1. **Third-Party Escrow Theft / Unauthorized Refund**:\n   - Alice creates a lease escrow of 10,000 XUSD (`b.Source`).\n   - Attacker Bob (competing in an open or contested block election on his account) creates a staged `BlockLeaseCancel` candidate referencing Alice's escrow hash `b.Source`.\n   - When Bob's candidate is validated via `ValidateStagedBlock(candidate, parentBalance)`, the node checks:\n     - `pending != nil` (Alice's escrow exists in store).\n     - `b.Balance == parentBalance + 10,000`.\n   - Because `ValidateStagedBlock` **does not check `leaseBlock.Account == b.Account`**, Bob's block passes validation!\n   - If Bob's block is promoted via quorum, Bob receives Alice's 10,000 XUSD escrow refund directly into his balance.\n2. **Permanent Consensus Split / BFT Fork**:\n   - Nodes ingesting the promoted block via standard peer sync (`validateAndAddLeaseCancel`) check `leaseBlock.Account == b.Account`.\n   - Syncing nodes reject the block with `lease_cancel: only the consumer can cancel a lease`.\n   - The network fractures into a permanent consensus fork between quorum-staging nodes and standard synchronization nodes.\n\n---\n\n## Impact\n\n1. **Unauthorized Escrow Theft**:\n   Any network account can hijack and refund third-party lease escrows to their own account during staged conflict elections.\n2. **Permanent Consensus Partition**:\n   Discrepancy between live block ingestion and staged block validation allows blocks violating protocol ownership to enter the ledger, causing follower nodes to permanently desynchronize.\n\n---\n\n## Remediation\n\nIn `core/ledger.go`, update `case BlockLeaseCancel` in `ValidateStagedBlock` to verify asset type, source lease ownership, and lease state:\n```go\n\tcase BlockLeaseCancel:\n\t\tif b.Asset != \"XUSD\" {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: asset must be XUSD\")\n\t\t}\n\t\tleaseBlock, err := l.store.GetBlock(b.Source)\n\t\tif err != nil || leaseBlock == nil {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: source lease block not found\")\n\t\t}\n\t\tif leaseBlock.Type != BlockLease {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: source block is not a lease block\")\n\t\t}\n\t\tif leaseBlock.Account != b.Account {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: only consumer can cancel lease\")\n\t\t}\n\t\tif existing, ok, err := l.getLeaseOverlay(b.Source); ok && existing != nil {\n\t\t\tif existing.State != LeaseCreated && existing.State != LeaseAccepted {\n\t\t\t\treturn fmt.Errorf(\"staged lease_cancel: cannot cancel lease in %s state\", existing.State)\n\t\t\t}\n\t\t}\n\t\tpending, err := l.store.GetPendingSend(b.Source)\n\t\tif err != nil || pending == nil {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: no pending send for lease\")\n\t\t}\n\t\texpectedBal := parentBalance + pending.Amount\n\t\tif b.Balance != expectedBal {\n\t\t\treturn fmt.Errorf(\"staged lease_cancel: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n```","patch_refs":[],"thread":[{"id":13223,"source":"desk","source_ref":"reply:11245","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as https://bounty.xe.network/XE-0028, 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-9772 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:19.023248+00:00"}]}