LeaseStakeDivisor hardcoded to 0 — provider collateral stake is silently zero
Report
TITLE (kolom title issue):
LeaseStakeDivisor hardcoded to 0 — provider collateral stake is silently zero
===== BODY (textarea) =====
Severity: Medium — validation gap (economic invariant). See escalation note.
Area: Compute leasing · core/ledger.go
Summary
Provider collateral stake is silently disabled: LeaseStakeDivisor is hardcoded to 0, so
LeaseStake(cost) returns 0 for every input and validateAndAddLeaseAccept enforces
block.amount == 0. A provider therefore accepts and settles leases with zero XUSD at risk,
removing the economic disincentive against accepting compute without delivering it.
Root cause
core/ledger.go:
const (
LeaseVCPURate = uint64(20_000)
LeaseMemGBRate = uint64(10_000)
LeaseDiskGBRate = uint64(1_000)
LeaseStakeDivisor = uint64(0) // ← collateral divisor is zero
)
func LeaseStake(cost uint64) uint64 {
if LeaseStakeDivisor == 0 {
return 0 // ← always this branch
}
stake := ceilDiv(cost, LeaseStakeDivisor)
if stake == 0 { stake = 1 } // ← min-1µXUSD clamp: unreachable
return stake
}
The clamp if stake == 0 { stake = 1 } is dead code — it only has meaning for a non-zero divisor.
validateAndAddLeaseAccept then requires b.Amount == 0 (rejecting any non-zero stake),
lease_settle returns lease.Stake (always 0), and lease_force_settle forfeits 0.
Why this is not intentional
The code itself assumes non-zero stake, independent of any documentation:
- The minimum clamp in
LeaseStake(above) is only reachable withLeaseStakeDivisor != 0. core/supply.gotrackslocked_stakeandstake_forfeitedand reports them inGET /supply; both are permanently0— dead accounting that only exists to describe a collateralized network.- The CLI
pickProvider()filters providers onbalance >= stake, which is a no-op at stake0.
Impact
stake is the only mechanism that punishes a provider for accepting a lease and not delivering
compute. With it zero:
- A provider can
lease_acceptwith nothing at risk, never provision a VM, thenlease_settleat expiry — the timekeeper attestation proves only elapsed time, not delivery — burning the consumer's escrow and minting XE for themselves. This is the "escrow taken without service" case from the Track 1 leasing scope, made costless. lease_force_settleforfeits0, so abandoning a lease has no downside for the provider.
This is not a double-spend: the escrow remains single-use (settle burns it, force_settle
refunds it; ExpectLeaseState + the atomic commit still block double-claims). It is a removed
defensive control, not a direct theft primitive — hence Medium rather than High/Critical.
Reproduce
curl -s 'https://ldn.core.test.network/leases?limit=3' # every lease carries "stake": 0
curl -s 'https://ldn.core.test.network/supply' # XUSD.locked_stake:0, stake_forfeited:0 across 101 leases
Proof of concept
Two tests added to a checkout (Go 1.25), then executed:
$ go test ./core -run TestAudit -v
=== RUN TestAuditLeaseStakeAlwaysZero
audit_probe_test.go:22: CONFIRMED: LeaseStakeDivisor=0 => LeaseStake(cost) always 0; provider collateral is fully disabled
--- PASS: TestAuditLeaseStakeAlwaysZero (0.00s)
=== RUN TestAuditMul64OverflowDetection
--- PASS: TestAuditMul64OverflowDetection (0.00s)
=== RUN TestAuditZeroCollateralEmission
2026/10/24 03:55:44 Genesis block applied: 42000000000000 XE to 378d0f5c2063...
audit_e2e_test.go:103: provider BEFORE lease: XE=1 XUSD=0
audit_e2e_test.go:129: lease cost = 500 µXUSD
audit_e2e_test.go:156: required stake = LeaseStake(500) = 0
audit_e2e_test.go:184: provider AFTER accept: XE=1 XUSD=0
audit_e2e_test.go:212: provider FINAL: XE=501 XUSD=0
audit_e2e_test.go:213: consumer FINAL: XE=999999 XUSD=999500
audit_e2e_test.go:221: CONFIRMED: provider minted 500 µXE emission with ZERO XUSD collateral at risk (stake=0)
--- PASS: TestAuditZeroCollateralEmission (0.00s)
PASS
ok github.com/xeprotocol/xe/core 0.022s
TestAuditZeroCollateralEmission drives the full lifecycle (send → receive → lease → lease_accept
with amount=0 → lease_settle) through the real Ledger; the provider starts with 0 XUSD and
mints 500 µXE with no collateral.
core/audit_probe_test.go
package core
import (
"math"
"math/big"
"testing"
)
// FINDING 1: provider collateral stake is always zero.
func TestAuditLeaseStakeAlwaysZero(t *testing.T) {
inputs := []uint64{0, 1, 2, 5, 10, 100, 1_000_000, 1_000_000_000, math.MaxUint64}
for _, cost := range inputs {
got := LeaseStake(cost)
if got != 0 {
t.Fatalf("LeaseStake(%d) = %d, want 0 (LeaseStakeDivisor is hardcoded 0)", cost, got)
}
}
if LeaseStakeDivisor != 0 {
t.Fatalf("LeaseStakeDivisor = %d (documented as 5)", LeaseStakeDivisor)
}
t.Logf("CONFIRMED: LeaseStakeDivisor=%d => LeaseStake(cost) always 0; provider collateral is fully disabled", LeaseStakeDivisor)
}
// Reference: verify mul64 (hand-rolled 128-bit multiply used in ParseAmount overflow detection)
func TestAuditMul64OverflowDetection(t *testing.T) {
ref := func(a, b uint64) (hi, lo uint64) {
A := new(big.Int).SetUint64(a)
B := new(big.Int).SetUint64(b)
P := new(big.Int).Mul(A, B)
mask := new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 64), big.NewInt(1))
lo = new(big.Int).And(P, mask).Uint64()
hi = new(big.Int).Rsh(P, 64).Uint64()
return
}
cases := []struct{ a, b uint64 }{
{1, 1}, {math.MaxUint32, math.MaxUint32}, {math.MaxUint64, 1},
{0xffffffff, 0xffffffff}, {0x100000000, 0x100000000},
{math.MaxUint64, math.MaxUint64}, {1_000_000, 18_446_744_073_709},
{1_000_000, 18_446_744_073_710},
}
for _, c := range cases {
h, l := mul64(c.a, c.b)
rh, rl := ref(c.a, c.b)
if h != rh || l != rl {
t.Errorf("mul64(%d,%d) = (%d,%d), want (%d,%d)", c.a, c.b, h, l, rh, rl)
}
}
}
core/audit_e2e_test.go
package core_test
import (
"bytes"
"encoding/hex"
"testing"
"time"
"github.com/xeprotocol/xe/core"
"github.com/xeprotocol/xe/store"
)
var testNow time.Time
func stamp() int64 { return testNow.UnixNano() }
func seedAsset(t *testing.T, l *core.Ledger, kp *core.KeyPair, asset string, amount uint64) string {
b := &core.Block{
Type: core.BlockMint,
Account: kp.Address(),
Previous: "0",
Balance: amount,
Amount: amount,
Asset: asset,
Timestamp: stamp(),
PubKey: kp.PubKeyHex(),
}
if err := core.SignBlock(b, kp); err != nil {
t.Fatalf("sign mint: %v", err)
}
if err := l.SeedAssetForTesting(b); err != nil {
t.Fatalf("seed %s: %v", asset, err)
}
return b.Hash
}
// provider with ZERO XUSD collateral accepts a lease and settles it, minting XE emission.
func TestAuditZeroCollateralEmission(t *testing.T) {
testNow = time.Unix(1_700_000_000, 0)
core.Now = func() time.Time { return testNow }
defer func() { core.Now = func() time.Time { return time.Now() } }()
consumer := core.KeyPairFromSeed(bytes.Repeat([]byte{0x01}, 32))
provider := core.KeyPairFromSeed(bytes.Repeat([]byte{0x02}, 32))
timekeeper := core.KeyPairFromSeed(bytes.Repeat([]byte{0x03}, 32))
certHash := hex.EncodeToString(bytes.Repeat([]byte{0x77}, 32))
ms := store.NewMemStore()
ledger := core.NewLedger(ms, core.LedgerConfig{
Difficulty: 0,
TimestampWindow: core.DefaultTimestampWindow,
TimekeeperConfigFn: func() *core.TimekeeperConfig {
return &core.TimekeeperConfig{Keys: []string{timekeeper.PubKeyHex()}, Threshold: 1}
},
CertificateLookupFn: func(hash string) *core.CertificateInfo {
return &core.CertificateInfo{Provider: provider.Address(), ExpiresAt: testNow.UnixNano() + int64(365*24*time.Hour), PriceMultiplierMilli: 1000}
},
EpochAtFn: func(ns int64) []core.EpochParams {
return []core.EpochParams{{R: 1000, PayoutCap: 0, TWAP: 0}}
},
FeatureActiveFn: func(string) bool { return false },
})
seedAsset(t, ledger, consumer, "XE", 1_000_000)
sendBlock := &core.Block{
Type: core.BlockSend,
Account: consumer.Address(),
Previous: ledger.GetChain(consumer.Address())[0].Hash,
Balance: 1_000_000 - 1,
Amount: 1,
Asset: "XE",
Destination: provider.Address(),
Timestamp: stamp(),
}
if err := core.SignBlock(sendBlock, consumer); err != nil {
t.Fatalf("sign send: %v", err)
}
if err := ledger.AddBlock(sendBlock); err != nil {
t.Fatalf("consumer send: %v", err)
}
recvBlock := &core.Block{
Type: core.BlockReceive,
Account: provider.Address(),
Previous: "0",
Balance: 1,
Asset: "XE",
Source: sendBlock.Hash,
Timestamp: stamp(),
PubKey: provider.PubKeyHex(),
}
if err := core.SignBlock(recvBlock, provider); err != nil {
t.Fatalf("sign receive: %v", err)
}
if err := ledger.AddBlock(recvBlock); err != nil {
t.Fatalf("provider open receive: %v", err)
}
provBefore := ledger.GetAssetBalances(provider.Address())
t.Logf("provider BEFORE lease: XE=%d XUSD=%d", provBefore["XE"], provBefore["XUSD"])
if provBefore["XUSD"] != 0 {
t.Fatalf("precondition failed: provider should start with 0 XUSD, has %d", provBefore["XUSD"])
}
consumerChain := ledger.GetChain(consumer.Address())
mintXUSD := &core.Block{
Type: core.BlockMint,
Account: consumer.Address(),
Previous: consumerChain[len(consumerChain)-1].Hash,
Balance: 1_000_000,
Amount: 1_000_000,
Asset: "XUSD",
Timestamp: stamp(),
}
if err := core.SignBlock(mintXUSD, consumer); err != nil {
t.Fatalf("sign xusd mint: %v", err)
}
if err := ledger.SeedAssetForTesting(mintXUSD); err != nil {
t.Fatalf("seed XUSD: %v", err)
}
cost, err := core.LeaseCost(1, 1024, 0, 60, 1000)
if err != nil {
t.Fatalf("LeaseCost: %v", err)
}
t.Logf("lease cost = %d µXUSD", cost)
consBal := ledger.GetAssetBalances(consumer.Address())
consumerChain = ledger.GetChain(consumer.Address())
leaseBlock := &core.Block{
Type: core.BlockLease,
Account: consumer.Address(),
Previous: consumerChain[len(consumerChain)-1].Hash,
Balance: consBal["XUSD"] - cost,
Asset: "XUSD",
Destination: provider.Address(),
Amount: cost,
VCPUs: 1,
MemoryMB: 1024,
DiskGB: 0,
Duration: 60,
CertificateHash: certHash,
Timestamp: stamp(),
}
if err := core.SignBlock(leaseBlock, consumer); err != nil {
t.Fatalf("sign lease: %v", err)
}
if err := ledger.AddBlock(leaseBlock); err != nil {
t.Fatalf("lease block: %v", err)
}
stake := core.LeaseStake(cost)
t.Logf("required stake = LeaseStake(%d) = %d", cost, stake)
att1, err := core.SignAttestation(leaseBlock.Hash, stamp(), timekeeper)
if err != nil {
t.Fatalf("sign accept attestation: %v", err)
}
acceptBlock := &core.Block{
Type: core.BlockLeaseAccept,
Account: provider.Address(),
Previous: recvBlock.Hash,
Balance: 0,
Asset: "XUSD",
Source: leaseBlock.Hash,
Amount: stake,
CertificateHash: certHash,
LockedR: 1000,
LockedPayoutCap: 0,
LockedTWAP: 0,
Attestations: []core.TimekeeperAttestation{*att1},
Timestamp: stamp(),
}
if err := core.SignBlock(acceptBlock, provider); err != nil {
t.Fatalf("sign accept: %v", err)
}
if err := ledger.AddBlock(acceptBlock); err != nil {
t.Fatalf("lease_accept (stake=%d): %v", stake, err)
}
provAfterAccept := ledger.GetAssetBalances(provider.Address())
t.Logf("provider AFTER accept: XE=%d XUSD=%d", provAfterAccept["XE"], provAfterAccept["XUSD"])
testNow = testNow.Add(61 * time.Second)
att2, err := core.SignAttestation(leaseBlock.Hash, stamp(), timekeeper)
if err != nil {
t.Fatalf("sign settle attestation: %v", err)
}
emission := cost
settleBlock := &core.Block{
Type: core.BlockLeaseSettle,
Account: provider.Address(),
Previous: acceptBlock.Hash,
Balance: provAfterAccept["XE"] + emission,
Asset: "XE",
Source: leaseBlock.Hash,
Amount: emission,
Attestations: []core.TimekeeperAttestation{*att2},
Timestamp: stamp(),
}
if err := core.SignBlock(settleBlock, provider); err != nil {
t.Fatalf("sign settle: %v", err)
}
if err := ledger.AddBlock(settleBlock); err != nil {
t.Fatalf("lease_settle: %v", err)
}
provFinal := ledger.GetAssetBalances(provider.Address())
consFinal := ledger.GetAssetBalances(consumer.Address())
t.Logf("provider FINAL: XE=%d XUSD=%d", provFinal["XE"], provFinal["XUSD"])
t.Logf("consumer FINAL: XE=%d XUSD=%d", consFinal["XE"], consFinal["XUSD"])
if provFinal["XUSD"] != 0 {
t.Fatalf("provider should still hold 0 XUSD (never staked collateral), has %d", provFinal["XUSD"])
}
if provFinal["XE"] != provBefore["XE"]+emission {
t.Fatalf("expected provider XE to grow by emission %d, got before=%d after=%d", emission, provBefore["XE"], provFinal["XE"])
}
t.Logf("CONFIRMED: provider minted %d µXE emission with ZERO XUSD collateral at risk (stake=0)", emission)
}
Escalation note
If the consequence above ("escrow without service" via the settle-before-force-settle ordering) is treated as an abused state transition rather than a bare validation gap, High may apply. Left to the team's discretion.
Remediation
Set LeaseStakeDivisor = 5 (restoring stake = ceil(cost/5), and making the min-1µXUSD clamp
reachable), or move the divisor into ApplyGenesisLeaseTiming() beside the other genesis-pinned
lease parameters. Add a test asserting that lease_accept with amount == 0 (or
amount != ceil(cost/5)) is rejected.
Thread
Nothing public yet.