{"id":"XE-9786","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 attestation verification on BlockLeaseForceSettle","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:12:58.449951+00:00","updated_at":"2026-11-20T00:33:18.982022+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:19.003754+00:00","status_changed_at":"2026-11-20T00:33:18.988407+00:00","url":"https://bounty.xe.network/XE-9786","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 `BlockLeaseForceSettle` is ingested normally through `validateAndAddLeaseForceSettle` (`core/ledger.go:1879-1970`), the node strictly verifies:\n1. `b.Asset == \"XUSD\"` (`core/ledger.go:1880-1882`).\n2. `leaseBlock.Account == b.Account` ensuring only the original consumer can force-settle their own lease (`core/ledger.go:1896-1898`).\n3. `!lease.Settled && lease.State == LeaseAccepted` (`core/ledger.go:1914-1922`).\n4. Timekeeper attestations verifying `forceTime >= eligibleAt` (where `eligibleAt = expiry + LeaseSettleGrace + LeaseForceSettleGap`) and `forceTime < expiry + LeaseEscrowExpiry` (`core/ledger.go:1935-1946`).\n5. Refund calculation taking into account the full lease escrow plus all renewal topups (`commit.AssetCredit = &AssetDelta{Account: b.Account, Asset: \"XUSD\", Amount: refundAmount}`).\n\nHowever, inside `ValidateStagedBlock` (`core/ledger.go:2821-2831`):\n```go\n\tcase BlockLeaseForceSettle:\n\t\tpending, err := l.store.GetPendingSend(b.Source)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"staged lease_force_settle: GetPendingSend: %w\", err)\n\t\t}\n\t\tif pending == nil {\n\t\t\treturn fmt.Errorf(\"staged lease_force_settle: no pending escrow 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_force_settle: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n```\n\nNotice the critical omissions in `ValidateStagedBlock` for `BlockLeaseForceSettle`:\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 `BlockLeaseForceSettle` 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, unexpired, or already settled lease can be prematurely force-settled during staged conflict resolution!\n4. **Never verifies timekeeper attestations**: It bypasses the required wait gap (`LeaseSettleGrace + LeaseForceSettleGap`), allowing instant force-settlement without proof of provider inactivity.\n\n---\n\n## Vulnerable Code Locations\n\n- `core/ledger.go:2821-2831`:\n  `ValidateStagedBlock` for `BlockLeaseForceSettle` checks only that `l.store.GetPendingSend(b.Source)` exists and matches `b.Balance == parentBalance + pending.Amount`. It omits consumer ownership verification, lease state verification, attestation verification, and asset matching.\n\n---\n\n## Attack & Failure Scenario\n\n1. **Third-Party Escrow Hijacking / Premature Force-Settle**:\n   - Alice creates a lease escrow of 50,000 XUSD (`b.Source`).\n   - Attacker Bob creates a staged `BlockLeaseForceSettle` candidate referencing Alice's escrow hash `b.Source` on his own account.\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 + pending.Amount`.\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 50,000 XUSD escrow refund directly into his balance.\n2. **Permanent Consensus Split / BFT Fork**:\n   - Nodes ingesting the promoted block via standard peer sync (`validateAndAddLeaseForceSettle`) check `leaseBlock.Account == b.Account` and timekeeper attestations.\n   - Syncing nodes reject the block with `lease_force_settle: only the consumer can force-settle a lease` or `lease not yet force-settleable`.\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. **Bypass of Provider Protection / Premature Sashing**:\n   Consumers (or attackers) can force-settle leases without waiting for the grace period and force-settle gap, bypassing timekeeper attestations.\n3. **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 BlockLeaseForceSettle` in `ValidateStagedBlock` to verify asset type, source lease ownership, and lease state:\n```go\n\tcase BlockLeaseForceSettle:\n\t\tif b.Asset != \"XUSD\" {\n\t\t\treturn fmt.Errorf(\"staged lease_force_settle: 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_force_settle: source lease block not found\")\n\t\t}\n\t\tif leaseBlock.Type != BlockLease {\n\t\t\treturn fmt.Errorf(\"staged lease_force_settle: 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_force_settle: only consumer can force-settle lease\")\n\t\t}\n\t\tlease, ok, err := l.getLeaseOverlay(b.Source)\n\t\tif !ok || err != nil || lease == nil {\n\t\t\treturn fmt.Errorf(\"staged lease_force_settle: lease not found\")\n\t\t}\n\t\tif lease.Settled || lease.State != LeaseAccepted {\n\t\t\treturn fmt.Errorf(\"staged lease_force_settle: lease not in force-settleable state\")\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_force_settle: no pending escrow 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_force_settle: balance mismatch: expected %d, got %d\", expectedBal, b.Balance)\n\t\t}\n```","patch_refs":[],"thread":[{"id":13222,"source":"desk","source_ref":"reply:11244","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-9786 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:18.982022+00:00"}]}