{"id":"XE-9646","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"Staged Block Validation Bypass: ValidateStagedBlock omits MSKeyset validation on BlockMultisigUpdate allowing malformed keyset promotion","area":"consensus","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"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-12T06:13:47.105683+00:00","updated_at":"2026-11-20T00:33:21.816595+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:21.839964+00:00","status_changed_at":"2026-11-20T00:33:21.822701+00:00","url":"https://bounty.xe.network/XE-9646","body":"## Vulnerability Summary\n\nIn `core/ledger.go:2732-2870`, `ValidateStagedBlock(b *Block, parentBalance uint64) error` is called by the consensus engine (`core/quorum.go:309`) before promoting a staged BFT quorum winner block to the canonical chain.\n\nWhile normal ingestion in `validateAndAddMultisigUpdate(b *Block)` (`core/ledger.go:1308-1353`) enforces rigorous checks on keyset integrity:\n1. `if b.MSKeyset == nil { return fmt.Errorf(\"multisig_update must include a keyset\") }`\n2. `if err := ValidateKeyset(b.MSKeyset); err != nil { return fmt.Errorf(\"multisig_update keyset: %w\", err) }`\n3. `oldKs := l.getKeysetOverlay(b.Account); if oldKs == nil { return fmt.Errorf(\"multisig_update: account is not multisig\") }`\n\nIn sharp contrast, `ValidateStagedBlock` handles `BlockMultisigUpdate` with only a balance check (`core/ledger.go:2835-2838`):\n\n```go\n\tcase BlockMultisigUpdate:\n\t\tif b.Balance != parentBalance {\n\t\t\treturn fmt.Errorf(\"staged multisig_update: balance mismatch: expected %d, got %d\", parentBalance, b.Balance)\n\t\t}\n```\n\nIt **completely omits**:\n- Checking if `b.MSKeyset == nil`.\n- Validating the keyset structure via `ValidateKeyset(b.MSKeyset)` (threshold $\\le$ total keys, duplicate public keys, threshold $> 0$, valid Ed25519 hex encodings).\n- Checking whether the account is actually an existing multisig account (`l.getKeysetOverlay(b.Account) != nil`).\n\n---\n\n## Vulnerable Code Locations\n\nIn `core/ledger.go:2835-2838`:\n```go\n\tcase BlockMultisigUpdate:\n\t\tif b.Balance != parentBalance {\n\t\t\treturn fmt.Errorf(\"staged multisig_update: balance mismatch: expected %d, got %d\", parentBalance, b.Balance)\n\t\t}\n        // MISSING: check that b.MSKeyset != nil\n        // MISSING: ValidateKeyset(b.MSKeyset)\n        // MISSING: check that account is already multisig\n```\n\nCompare with `core/ledger.go:1308-1320` (`validateAndAddMultisigUpdate`):\n```go\nfunc (l *Ledger) validateAndAddMultisigUpdate(b *Block) error {\n\tif b.MSKeyset == nil {\n\t\treturn fmt.Errorf(\"multisig_update must include a keyset\")\n\t}\n\tif err := ValidateKeyset(b.MSKeyset); err != nil {\n\t\treturn fmt.Errorf(\"multisig_update keyset: %w\", err)\n\t}\n\n\toldKs := l.getKeysetOverlay(b.Account)\n\tif oldKs == nil {\n\t\treturn fmt.Errorf(\"multisig_update: account is not multisig\")\n\t}\n    ...\n```\n\n---\n\n## Attack & Failure Scenario\n\n1. A conflict arises on a multisig account, or an attacker creates a conflict between a legitimate multisig transaction and a competing `BlockMultisigUpdate`.\n2. The competing block contains an invalid or nil `MSKeyset` (for instance, `Threshold: 0`, empty keys list, duplicate keys, or `MSKeyset: nil`).\n3. If quorum votes converge on this competing candidate or during conflict resolution, `confirmConflict` invokes:\n   ```go\n   if err := qm.ledger.ValidateStagedBlock(winnerBlock, parentBalance); err != nil {\n       ...\n   }\n   ```\n4. `ValidateStagedBlock` only verifies `b.Balance == parentBalance`. Since balance is unchanged, `ValidateStagedBlock` returns `nil` (PASS)!\n5. `confirmConflict` proceeds to call `swapBlockLocked`:\n   - It unrolls prior blocks and invokes `prepareBlockWrite(newBlock)`.\n   - In `prepareBlockWrite`:\n     `commit.PutKeyset = b.MSKeyset`\n     `l.setKeyset(b.Account, b.MSKeyset)`\n   - The malformed or nil `MSKeyset` is committed to storage and written to the active ledger in-memory keyset cache!\n6. If `b.MSKeyset` was nil or had threshold 0, any subsequent transaction on this account attempting signature verification crashes with nil pointer dereference or permanently freezes all funds because `VerifyMultisigAny` cannot satisfy an invalid threshold.\n\n---\n\n## Impact\n\n1. **Permanent Account Hijacking / Fund Freezing via Malformed Staged Winners**:\n   A winning quorum block containing an unvalidated `BlockMultisigUpdate` can set an unspendable keyset (threshold 0 or empty keys), permanently locking all funds in the multisig treasury.\n2. **Crash & State Corruption**:\n   If `b.MSKeyset == nil`, later operations calling `l.GetKeyset(b.Account).Keys` panic with nil pointer dereference, causing local and peer validator nodes to crash on block execution.\n3. **Consensus Invariant Breakage**:\n   Different validation rules between live ingestion (`validateAndAddMultisigUpdate`) and consensus resolution (`ValidateStagedBlock`) allow blocks that would fail ingestion to be promoted through conflict resolution.\n\n---\n\n## Remediation\n\nIn `ValidateStagedBlock` in `core/ledger.go`, update `case BlockMultisigUpdate`:\n\n```go\n\tcase BlockMultisigUpdate:\n\t\tif b.Balance != parentBalance {\n\t\t\treturn fmt.Errorf(\"staged multisig_update: balance mismatch: expected %d, got %d\", parentBalance, b.Balance)\n\t\t}\n\t\tif b.MSKeyset == nil {\n\t\t\treturn fmt.Errorf(\"staged multisig_update: missing keyset\")\n\t\t}\n\t\tif err := ValidateKeyset(b.MSKeyset); err != nil {\n\t\t\treturn fmt.Errorf(\"staged multisig_update: invalid keyset: %w\", err)\n\t\t}\n\t\tif l.getKeysetOverlay(b.Account) == nil {\n\t\t\treturn fmt.Errorf(\"staged multisig_update: account is not multisig\")\n\t\t}\n```","patch_refs":[],"thread":[{"id":13273,"source":"desk","source_ref":"reply:11295","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-9646 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:21.816595+00:00"}]}