XE-0003 · Bounty
Audit: Lease Stake Oversubscription Race, sys.timekeepers Key Hex/Deduplication Bypass, Memo Unicode C1/Bidi Injection, and Lease Cancel Uint64 Overflow
Report
Security Audit Report: XE Protocol (Track 1 Bug Bounty)
This audit report identifies 4 high/medium severity vulnerabilities across consensus, ledger state transitions, statechain DAO configuration validation, and node lease orchestration, accompanied by unit tests with 100% pass rates.
Finding 1: Provider Lease Accept & Marketplace Stake Oversubscription Race Condition
- Severity: High
- Components:
ode/node.go\ (\handleMarketplace, \utoAcceptLease) - Vulnerability:
When a node acts as a compute provider, leases require committing XUSD stake (\core.LeaseStake(amount)). While resource metrics (VCPUs, Memory, Disk) are tracked in
eservedRes\ during the async VM provisioning window, in-flight XUSD stake commitments are not tracked.- Concurrently incoming lease requests check
.Ledger.GetAssetBalances(myAddr)["XUSD"]\ before provisioning. Because the on-chain \BlockLeaseAccept\ block is only minted after VM provisioning completes, concurrent lease acceptance routines believe the entire unreserved balance is available. - Both VMs are provisioned, but the second routine acquires \lockCreateMu, discovers \stake > xusdBal, and aborts with "XUSD balance changed during provisioning (...) tearing down".
- Consequently, the consumer's on-chain lease is left unfulfilled, causing the provider to suffer reputation penalties (\EventLeaseUnfulfilled) and wasting node compute.
- Similarly, \handleMarketplace\ publishes signed \ResourceOffer\ messages against current unreserved balance without factoring in in-flight lease acceptances.
- Concurrently incoming lease requests check
- Resolution:
Added
eservedStake uint64\ protected by
eservedResMu\ to track active in-flight stake commitments. In \utoAcceptLease, stake is reserved prior to VM provisioning and atomically released via \defer. In \handleMarketplace, offer evaluation subtracts
eservedStake\ from available XUSD.
Finding 2: Incomplete \sys.timekeepers\ Key Validation (Missing Hex Decoding & Duplicate Key Permissibility)
- Severity: High
- Components: \statechain/kvstore.go\ (\alidateSysKeyValue)
- Vulnerability:
Unlike \sys.dao_keyset, \sys.minter, and \sys.oracle\ which strictly decode keys with \hex.DecodeString(k)\ and enforce uniqueness (\seen[k]), \sys.timekeepers\ only validated key length (\len(k) != 64).
- A malicious or misconfigured DAO transaction can set invalid non-hex characters or duplicate timekeeper public keys.
- If duplicate keys are accepted (e.g. [K, K]\ with \ hreshold: 2), a single compromised timekeeper key satisfies the multi-party quorum, bypassing threshold assumptions.
- Non-hex characters pass KV validation but later fail and abort subsequent timekeeper attestation verification routines (\core.ValidateAttestations).
- Resolution: Enforced \hex.DecodeString(k)\ and duplicate key rejection (\seen[k]) in \statechain/kvstore.go\ for \sys.timekeepers, matching the invariants of \sys.dao_keyset\ and \sys.minter.
Finding 3: Missing Uint64 Arithmetic Overflow Check in \alidateAndAddLeaseCancel\
- Severity: High
- Components: \core/ledger.go\ (\alidateAndAddLeaseCancel)
- Vulnerability:
In \alidateAndAddLeaseCancel, the expected refund balance calculation:
\\go
oldBal := l.getAssetBalanceOverlay(b.Account, "XUSD")
expectedBal := oldBal + leaseBlock.Amount
\
omitted the uint64 overflow check present in \alidateAndAddReceive\ and \alidateAndAddLeaseForceSettle. If \oldBal + leaseBlock.Amount\ overflows \math.MaxUint64, \expectedBal\ silently wraps around. An attacker or edge case could submit or validate invalid balance assertions resulting in balance truncation or state corruption. - Resolution: Added explicit overflow check: \\go if expectedBal < oldBal { return fmt.Errorf("lease_cancel would overflow uint64 balance") } \\
Finding 4: Unicode C1 Control Character & Bidirectional / Invisible Format Spoofing Injection in \ValidateMemo\
- Severity: Medium
- Components: \core/memo.go\ (\ValidateMemo)
- Vulnerability:
\ValidateMemo\ checked ASCII control bytes using \c < 0x20 || c == 0x7F\ by indexing raw bytes. In UTF-8, non-ASCII codepoints are encoded as multi-byte sequences where every byte has the high bit set (>= 0x80).
- C1 control codes (\U+0080\ to \U+009F, including CSI \U+009B\ and OSC \U+009D) completely bypassed the check. These codes are utilized in ANSI escape sequences for terminal command execution and log injection.
- Unicode Bidirectional Overrides (\U+202E\ RLO) and zero-width/formatting characters (\U+200B, \U+2066..U+2069, \U+FEFF) bypassed the validation, enabling visual address/memo spoofing on block explorers, wallets, and CLI interfaces.
- Resolution: Iterate over decoded runes in \ValidateMemo\ and enforce rejection via \unicode.IsControl(r)\ (covering C0, DEL, and C1 control blocks) and \unicode.Is(unicode.Cf, r)\ (covering bidirectional overrides and formatting code points).
Verification & Unit Tests
Comprehensive unit tests covering all 4 vulnerabilities were created and verified:
- \core/memo_test.go: 18 test cases validating ASCII, C0, C1 (NEL, CSI, OSC), Bidi (RLO, LRI), zero-width spaces, and BOM rejections.
- \core/ledger_test.go: Verification of overflow rejection on \alidateAndAddLeaseCancel\ as well as valid cancellation handling.
- \statechain/kvstore_test.go: Validation of \sys.timekeepers\ hex validity, duplicate key detection, threshold boundaries, and key lengths.
ode/node_test.go: Concurrency test proving that
eservedStake\ prevents oversubscription across parallel lease accepts.
All packages compile and pass tests cleanly (\go test ./...\ -> 0 failures).
A companion Pull Request with the fixes and tests has been submitted.
Thread
XE deskteam2026-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-0003.