{"id":"XE-13261","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"401","source_url":"https://github.com/xeprotocol/xe/issues/401","reporter_id":1743,"title":"[Consensus/High] core/quorum: staged lease block validation defaults empty asset to XE, measuring XUSD costs against XE balances and triggering false promotion quarantine","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":"closed","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T20:42:05.193786+00:00","updated_at":"2026-11-20T00:06:59.994028+00:00","source_created_at":"2026-11-11T17:44:51+00:00","told_at":"2026-11-20T00:04:53+00:00","status_changed_at":"2026-11-20T00:04:29.707209+00:00","url":"https://bounty.xe.network/XE-13261","body":"## Summary\n\nIn `core/quorum.go`, both `promotable()` (lines 253–257) and `confirmConflict()` (lines 297–302) attempt to determine the asset type of a staged block to compute `parentBalance` via `qm.ledger.GetAssetBalanceAtBlock(account, asset, previous)`. When `staged.Asset` is empty (`\"\"`), both functions default the asset to `\"XE\"`:\n\n```go\nasset := staged.Asset\nif asset == \"\" {\n    asset = \"XE\"\n}\nvar parentBalance uint64\nif previous != \"0\" {\n    parentBalance = qm.ledger.GetAssetBalanceAtBlock(account, asset, previous)\n}\nreturn qm.ledger.ValidateStagedBlock(staged, parentBalance) == nil\n```\n\nHowever, all compute lease operations (`BlockLease`, `BlockLeaseAccept`, `BlockLeaseSettle`, `BlockLeaseCancel`, `BlockLeaseForceSettle`) are strictly denominated in `XUSD`. When an empty-asset lease block enters conflict resolution, this fallback causes the node to fetch the account's **XE balance** rather than its **XUSD balance**, and validates the lease cost/stake against the XE balance in `ValidateStagedBlock`.\n\nFurthermore, in `core/ledger.go` (lines 830–845), the pre-conflict staging path computes `parentBalance` using an ad-hoc loop that does not handle default assets (`cb.Asset == \"\"`) or add `lease.Stake` on `BlockLeaseSettle` (unlike `GetAssetBalanceAtBlock`), causing divergence between the pre-conflict staging gate and quorum promotion validation.\n\n---\n\n## Root Cause Analysis\n\n1. **`core/quorum.go:253-255` & `core/quorum.go:297-302`**:\n   `staged.Asset` is defaulted to `\"XE\"` without inspecting `staged.Type`. For any lease block, defaulting to `\"XE\"` evaluates the account's native XE balance for an operation that deducts or escrows XUSD.\n\n2. **False Promotion & Quarantine Trigger**:\n   An account holding sufficient XE but 0 XUSD can construct a conflicting lease block. `promotable()` reports `true` because `ValidateStagedBlock` passes against the XE `parentBalance`. Consequently, the node votes for or considers the block eligible for promotion. When `confirmConflict()` proceeds to promote the staged winner:\n   ```go\n   if err := qm.ledger.swapBlockLocked(result.ConflictAccount, loserHash, result.WinnerHash, winnerBlock); err != nil {\n       if errors.Is(err, ErrWinnerFullValidation) && !IsRetryableError(err) {\n           qm.failedPromotions[failedPromotionKey(...)] = Now()\n           log.Printf(\"confirmConflict: winner %s ... failed full validation deterministically: quarantining for %s...\", ...)\n       }\n   }\n   ```\n   `swapBlockLocked` invokes the full `validateAndAddLease*` path, which checks actual XUSD balances and fails deterministically. This enters the `ErrWinnerFullValidation` quarantine (`failedPromotionTTL = 30s`), causing the node's position to withhold and stalling consensus progress on the conflicting account chain.\n\n3. **Divergent Balance Resolution in `core/ledger.go:830-842`**:\n   ```go\n   var parentBalance uint64\n   if chain != nil && b.Previous != \"0\" {\n       for _, cb := range chain.Blocks {\n           if cb.Asset == b.Asset {\n               parentBalance = cb.Balance\n           }\n           if cb.Hash == b.Previous {\n               break\n           }\n       }\n   }\n   ```\n   This inline search does not normalize `cb.Asset == \"\"` to `\"XE\"`, and does not credit `lease.Stake` returned on `BlockLeaseSettle` (which `GetAssetBalanceAtBlock` in lines 3019–3034 explicitly accounts for).\n\n---\n\n## Impact\n\n- **Consensus / Quorum Denial of Service**: Malicious or malformed conflicting lease blocks bypass lightweight pre-promotion staging checks by substituting XE balance for XUSD requirements, repeatedly poisoning quorum resolution and locking the account chain into 30-second withheld quarantine states.\n- **Discrepancy between Staged Ingest and Promotion**: Honest nodes can accept staged blocks that cannot be applied during conflict settlement.\n\n---\n\n## Recommended Remediation\n\n1. In `core/quorum.go` (`promotable` and `confirmConflict`), derive the expected asset from the block type:\n```go\nasset := staged.Asset\nif asset == \"\" {\n    if isLeaseStateTransition(staged.Type) {\n        asset = \"XUSD\"\n    } else {\n        asset = \"XE\"\n    }\n}\n```\n\n2. In `core/ledger.go` (line 830), replace the inline chain scan with `l.GetAssetBalanceAtBlock(b.Account, b.Asset, b.Previous)` to ensure consistent handling of default assets and settled lease escrow stakes.","patch_refs":[{"id":544,"repo":"xeprotocol/xe","kind":"pr","ref":"406","title":"fix(core/quorum): derive asset from block type on staged lease validation and unify parent balance (#401)","url":"https://github.com/xeprotocol/xe/pull/406","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-11-14T20:42:19.903146+00:00"}],"thread":[{"id":12667,"source":"github","source_ref":"7025798947","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-13261 and says what differs; it is read like any other.","created_at":"2026-11-20T00:04:53+00:00"}]}