Bounty
XE-0015 · Bounty

security(node,api,core): Unauthenticated VM Credential/Tunnel Access, Post-Expiry Lease Tunneling & Renewed Lease / Multi-Asset Accounting Flaws

Fixing claimed Severe xe#4 filed 2026-10-18 05:26 UTC by Khanhtnq

Report

Disclosure Note: We attempted to report these findings privately to security@xe.network per the XE Bug Bounty Program guidelines, but the address bounced (no MX/recipient configured), and GitHub Private Vulnerability Reporting is not enabled on xeprotocol/xe. We are opening this report along with a companion Fix PR containing surgical patches and regression tests.


Summary

During a security audit of the xeprotocol/xe Track 1 modules (node/, api/, core/), we identified four High/Severe vulnerabilities affecting leased VM authentication/isolation, P2P/HTTP tunnel access control, renewed lease escrow/supply conservation, and multi-asset (XE / XUSD) ledger accounting:

# Severity Component Vulnerability
1 Severe node/vm.go, api/handler.go Unauthenticated VM plaintext credential & status disclosure via P2P vm_status RPC and HTTP GET /vms, GET /vms/{lease}
2 Severe node/node.go, api/tunnel.go, node/ssh_gateway.go Unauthenticated P2P /xe/tunnel/2.0.0 hijacking (ValidateTunnelLease ignores peerID) and post-expiry VM tunnel/SSH access
3 High node/node.go, core/supply.go, core/ledger.go, core/types.go Broken BlockLeaseRenew accounting: unrecoverable consumer escrow on forceSettleLease, permanent XUSD supply conservation failure, missing per-lease lock & conflict staging failure
4 High core/ledger.go, core/spendable.go, node/node.go Multi-asset (XE vs XUSD) balance corruption in Ledger.GetBalance, Node.GetAllAccounts, SpendableBalances, and conflict parentBalance calculation

Finding 1: Unauthenticated VM Plaintext Credential & Status Disclosure (node/vm.go, api/handler.go)

Root Cause

  1. Unauthenticated P2P vm_status RPC (node/vm.go:40-55): When a lease is provisioned without an AccessPubKey (credential mode), VMManager.Provision generates plaintext SSH credentials (vm.Credentials{Username, Password}) and stores them on vm.Info.Credentials. Unlike vm_credentials (node/vm.go:27-30, which verifies providerPeer == from), the vm_status P2P handler (n.Msg.Handle("vm_status", ...)) performs no peer authorization and serializes the entire vm.Info struct—including plaintext Credentials—to any requesting libp2p peer:
    n.Msg.Handle("vm_status", func(from peer.ID, payload json.RawMessage) (json.RawMessage, error) {
        ...
        info, err := n.VMManager.Get(req.LeaseHash)
        if err != nil {
            return nil, err
        }
        return json.Marshal(info) // leaks info.Credentials to any peer 'from'
    })
    
  2. Unauthenticated HTTP GET /vms & GET /vms/{lease} (api/handler.go:200-201, node/vm.go:136-167): GET /vms and GET /vms/{lease} are registered without h.requireAdmin(...), exposing all local vm.Info structs (including plaintext Credentials) to any unauthenticated HTTP client. Furthermore, when GET /vms/{lease} is called for a lease not in consumerVMs, Node.GetVM(leaseHash) (node/vm.go:156) queries the remote provider's vm_status P2P RPC even if the local node is not the lease consumer.

Impact

Because leaseHash values are public on the DAG ledger, any libp2p peer or unauthenticated HTTP client can query any active credential-mode lease and obtain its plaintext SSH username and password.


Finding 2: Unauthenticated P2P /xe/tunnel/2.0.0 Hijacking & Post-Expiry VM Tunnel/SSH Access (node/node.go, api/tunnel.go, node/ssh_gateway.go)

Root Cause

  1. ValidateTunnelLease Ignores peerID (node/node.go:2176-2189): When a remote peer opens a /xe/tunnel/2.0.0 stream (net/tunnel.go:70-128) and sends a 32-byte leaseHash, the provider invokes Node.ValidateTunnelLease(leaseHash string, peerID peer.ID). However, ValidateTunnelLease completely ignores peerID and never checks whether peerID matches n.PeerForAccount(lease.Consumer):
    func (n *Node) ValidateTunnelLease(leaseHash string, peerID peer.ID) error {
        lease := n.GetLease(leaseHash)
        if lease == nil { return fmt.Errorf("lease not found") }
        if lease.State != core.LeaseAccepted { return fmt.Errorf("lease not active") }
        if lease.Provider != n.KeyPair.Address() { return fmt.Errorf("not the provider for this lease") }
        return nil
    }
    
    Any libp2p peer on the network can send the public 32-byte leaseHash to /xe/tunnel/2.0.0 and receive a raw TCP stream bridged directly to the VM's internal SSH port (DialSSH). Combined with Finding 1, any peer on the P2P network can take over any credential-mode VM.
  2. Post-Expiry Tunnel & SSH Gateway Access (node/node.go:2182, 2208, api/tunnel.go:25, node/ssh_gateway.go:121): A lease remains in lease.State == core.LeaseAccepted after lease.EffectiveExpiry() during LeaseSettleGrace (1 hour) and LeaseForceSettleGap (+25 minutes), or up to 8 days (LeaseEscrowExpiry + LeaseArchiveGap) before archival. None of ValidateTunnelLease, OpenTunnelForLease, handleTunnelTCP, or SSHGateway.handleConnection checks lease.StartTime > 0 && core.Now().UnixNano() >= lease.EffectiveExpiry(), allowing continued SSH and TCP tunnel access after lease expiration.

Finding 3: Broken BlockLeaseRenew Accounting in Force-Settlement, Supply Conservation & Conflict Staging (node/node.go, core/supply.go, core/ledger.go, core/types.go)

Root Cause

  1. Consumer Cannot Force-Settle Renewed Leases (node/node.go:1928-1940 vs core/ledger.go:1969-1976): Each BlockLeaseRenew block tops up the lease's pending escrow (commit.TopUpPendingID = b.Source, commit.TopUpPendingAmount = b.Amount), so pending.Amount equals lease.Cost + sum(renewals.Cost). In core/ledger.go:1970, validateAndAddLeaseForceSettle requires b.Balance == oldBal + pending.Amount. However, Node.forceSettleLease (node/node.go:1934, 1938) sets b.Balance = oldXUSD + lease.Cost and b.Amount = lease.Cost (ignoring lease.Renewals). Consequently, n.Ledger.AddBlock(b) rejects every forceSettleLease attempt on a renewed lease with balance mismatch, trapping the consumer's initial + renewal XUSD in escrow until LeaseEscrowExpiry burns it. Additionally, validateAndAddLeaseForceSettle does not validate b.Amount == pending.Amount.
  2. Permanent XUSD Supply Conservation Failure on Renewed Lease Settle/Expiry (core/supply.go:95-96, 213-215, 280-284): termsFromChain ignores BlockLeaseRenew blocks and walk() only adds l.Cost (omitting l.Renewals[i].Cost) to EscrowBurned when a lease settles or expires. Because BlockLeaseSettle / archiveExpiredLease deletes the entire topped-up PendingSend, settling or expiring any renewed lease causes SupplyAuditor.Report() (GET /supply) to permanently report Conserved: false with a negative XUSD discrepancy equal to the sum of all renewal costs.
  3. Missing Per-Lease Lock & Conflict Staging Support for BlockLeaseRenew (core/ledger.go:492-498, 2779-2785): isLeaseStateTransition omits BlockLeaseRenew, so addBlock (line 788) does not acquire l.acquireLeaseLock(b.Source) during BlockLeaseRenew. Additionally, ValidateStagedBlock (line 2779) omits case BlockLeaseRenew:, rejecting conflicting lease_renew blocks with staged block: unknown type: lease_renew.

Finding 4: Multi-Asset (XE vs XUSD) Balance Corruption in GetBalance, GetAllAccounts, SpendableBalances, and Conflict Staging (core/ledger.go, core/spendable.go, node/node.go)

Root Cause

  1. Ledger.GetBalance & Node.GetAllAccounts Return XUSD Balance as XE Balance (core/ledger.go:2361-2372, node/node.go:998-1001): An AccountChain interleaves both "XE" and "XUSD" blocks where b.Balance stores the post-block balance of b.Asset. However, Ledger.GetBalance(account) returns chain.LatestBalance() (chain.Blocks[len-1].Balance) and Node.GetAllAccounts() sets Balance: chain[len(chain)-1].Balance. Whenever an account's latest block is an "XUSD" block (mint, lease, lease_accept, lease_renew, lease_cancel, lease_force_settle, or XUSD send/receive), both methods return the account's XUSD balance as its XE balance.
  2. Conflict Staging parentBalance Omits BlockLeaseSettle Stake Return & Default "XE" Asset (core/ledger.go:832-842): When staging a conflict block in addBlock, parentBalance is computed via an inline loop (if cb.Asset == b.Asset { parentBalance = cb.Balance }) instead of l.GetAssetBalanceAtBlock(b.Account, b.Asset, b.Previous). This misses the lease.Stake credited to "XUSD" by BlockLeaseSettle blocks (commit.AssetCredit), causing ValidateStagedBlock to reject valid "XUSD" conflict blocks on provider chains after a lease settlement with a false balance mismatch.
  3. SpendableBalances Omits BlockLeaseSettle Stake Credit (core/spendable.go:30-50): When BlockLeaseSettle (b.Asset == "XE") executes on a provider's chain, lease.Stake is returned to the provider's "XUSD" balance. While rebuildAssetBalances and GetAssetBalanceAtBlock credit lease.Stake to "XUSD" on BlockLeaseSettle, SpendableBalances (core/spendable.go) ignores it, under-reporting the provider's finalized spendable XUSD balance by lease.Stake and miscomputing unfinalized XUSD outflows after an unfinalized BlockLeaseSettle.

Thread

kenmungeneskar2026-10-24 14:31 UTCgithub

Independent reproduction of Finding 3 (XUSD supply conservation), with the exact identity

Not a new report — just confirming from the outside, with numbers, that this still reproduces on testnet-0005.

Measured on GET /supply (6 samples over ~30 s, identical every time):

field value
XUSD.created 213000000
XUSD.accounted 212967682
XUSD.discrepancy −32318
XUSD.conserved false

And the gap is exactly the renewal escrow that termsFromChain drops:

Σ renewals[].cost over all 101 leases (46 renewals) = 32318
XUSD.created − XUSD.accounted                       = 32318   ← exact match

Reproduce in three commands:

NODE=https://ldn.core.test.network
curl -s $NODE/supply | jq '(.assets.XUSD.created - .assets.XUSD.accounted)'   # 32318
curl -s "$NODE/leases?limit=1000" | jq '[.[].renewals[]?.cost] | add'        # 32318
curl -s $NODE/supply | jq '.assets.XUSD | {escrow_burned, conserved}'        # 67738, false

Two data points that may help when fixing:

  1. escrow_burned currently equals the sum of settled leases' initial cost only (67738) — which confirms renewals are the only missing term. Cancelled leases are correctly excluded (they are refunded, not burned; their 1551 is absent from escrow_burned).
  2. The discrepancy drifts monotonically with renewals: a few hours earlier the same node reported −27665 with escrow_burned=58432. That makes conserved a usable post-fix regression check: after the fix it should flip to true on the existing ledger (no wipe needed), and any future renewal must not move it.

Happy to leave this as evidence under this issue rather than filing a separate report.

Reyzz952026-11-10 10:27 UTCgithub

Still reproduces at HEAD 89a542e (testnet-0005, 2026-11-10).

ValidateTunnelLease (node/node.go:2176-2190) still ignores peerID and performs no expiry check. A stranger libp2p peer that knows only the public lease hash reaches the VM SSH via SetupTunnelHandler (net/tunnel.go), and a lease expired ~47h ago is still accepted. Same ticket, same code: unauthenticated vm_status (node/vm.go:40-55) still returns full vm.Info including plaintext credentials to any peer.

Note the HTTP API path is fixed (XE-0026, X-Signature vs AccessPubKey) — the libp2p path has no auth at all.