{"id":"XE-4323","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Consensus ledger desync: GetAssetBalanceAtBlock bypasses cascade overlay during conflict reorgs, causing false balance mismatch and winner promotion rejection","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":"invalid","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"invalid","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-10T22:06:13.956919+00:00","updated_at":"2026-11-15T17:58:22.562652+00:00","source_created_at":null,"told_at":"2026-11-15T17:58:25.706707+00:00","status_changed_at":"2026-11-15T17:42:49.126764+00:00","url":"https://bounty.xe.network/XE-4323","body":"## Vulnerability Summary\n\nIn `core/ledger.go:3014-3040`, `GetAssetBalanceAtBlock(account, asset, blockHash string)` computes the historical asset balance of an account up to a specific block boundary. This function is called directly by the consensus engine in `core/quorum.go:306-313` during `confirmConflict`:\n```go\nif result.ConflictPrev != \"0\" {\n    parentBalance = qm.ledger.GetAssetBalanceAtBlock(result.ConflictAccount, asset, result.ConflictPrev)\n}\nif err := qm.ledger.ValidateStagedBlock(winnerBlock, parentBalance); err != nil {\n    log.Printf(\"confirmConflict: staged winner %s failed validation: %v — refusing promotion\", shortHash(result.WinnerHash), err)\n    return fmt.Errorf(\"confirmConflict: invalid staged winner: %w\", err)\n}\n```\n\nHowever, while `xusdBalanceOnChain` in `core/rollback.go` was patched to consult lease state during reorgs, `GetAssetBalanceAtBlock` in `core/ledger.go`:\n1. Reads directly from the underlying physical store via `l.store.GetAccountChain(account)` instead of `l.getAccountChainOverlay(account)`.\n2. Resolves lease settlements via `ls.GetLease(b.Source)` directly from the physical store instead of `l.getLeaseOverlay(b.Source)`.\n\nWhen `confirmConflict` or `SwapBlock` executes a reorg unwinding across dependent blocks, an active `cascadeCommit` overlay is in place. Because `GetAssetBalanceAtBlock` completely ignores the active cascade overlay, it returns a stale/desynchronized `parentBalance`. Consequently, `ValidateStagedBlock` fails with a false `balance mismatch`, causing the node to refuse promotion of the legitimate BFT quorum winner and deadlocking consensus conflict resolution.\n\n---\n\n## Vulnerable Code Location\n\nIn `core/ledger.go:3014-3040`:\n```go\nfunc (l *Ledger) GetAssetBalanceAtBlock(account, asset, blockHash string) uint64 {\n    chain, err := l.store.GetAccountChain(account) // <-- Bypasses account chain overlay!\n    if err != nil || chain == nil {\n        return 0\n    }\n    ls, hasLeases := l.store.(LeaseStore)\n    xusd := asset == \"XUSD\"\n    var bal uint64\n    for _, b := range chain.Blocks {\n        a := b.Asset\n        if a == \"\" {\n            a = \"XE\"\n        }\n        if a == asset {\n            bal = b.Balance\n        }\n        if xusd && b.Type == BlockLeaseSettle && hasLeases {\n            if lease, lerr := ls.GetLease(b.Source); lerr == nil && lease != nil { // <-- Bypasses lease overlay!\n                bal += lease.Stake\n            }\n        }\n        if b.Hash == blockHash {\n            break\n        }\n    }\n    return bal\n}\n```\n\n---\n\n## Failure Mechanism\n\n1. **Conflict Resolution During Reorg**: A conflict winner (`winnerBlock`) is selected by 67%+ quorum on an account that has uncommitted/unwound blocks under an active cascade overlay.\n2. **Historical Balance Calculation**: `confirmConflict` invokes `GetAssetBalanceAtBlock(account, asset, prev)` to establish the parent balance baseline before validating the staged winner.\n3. **Overlay Bypass**:\n   - `GetAssetBalanceAtBlock` reads blocks and lease states directly from the persistent store (`l.store`), completely oblivious to the unwound state in the active cascade overlay.\n   - If previous blocks in the account chain or related lease settlements were modified/reverted in the cascade overlay, `GetAssetBalanceAtBlock` calculates an incorrect balance.\n4. **Promotion Refusal**:\n   - `ValidateStagedBlock` verifies `winnerBlock.Balance == parentBalance - amount` (or `+ amount`).\n   - Due to the desynchronized `parentBalance`, `ValidateStagedBlock` returns `balance mismatch: expected X, got Y`.\n   - `confirmConflict` logs `refusing promotion` and halts consensus resolution for the conflict.\n\n---\n\n## Proposed Mitigation\n\nUpdate `GetAssetBalanceAtBlock` in `core/ledger.go` to respect active cascade overlays:\n1. Use `l.getAccountChainOverlay(account)` instead of `l.store.GetAccountChain(account)`.\n2. Use `l.getLeaseOverlay(b.Source)` instead of `ls.GetLease(b.Source)`.","patch_refs":[],"thread":[{"id":6481,"source":"desk","source_ref":"reply:5121","author":"XE desk","team":true,"body":"Thanks for the report. We read it against the code and could not confirm a bug in what it describes.\n\nThis report is closed as invalid. If we have missed something, file a new report that links\nhttps://bounty.xe.network/XE-4323 and says what; it is read like any other.","created_at":"2026-11-15T17:58:22.562652+00:00"}]}