Unauthenticated cross-tenant libp2p tunnel: any peer can open a raw TCP tunnel to any accepted lease's VM, bypassing the HTTP tunnel's signature check
Report
Suggested tier: Medium
XE address (reward destination): 9b663fdac108be34a3b715ef78a9f9bd878af6ef8142f388c6514918e6852dd7
Summary
net/tunnel.go, SetupTunnelHandler (the /xe/tunnel/2.0.0 stream handler, registered for every node at node/node.go:549) + node/node.go:2176, ValidateTunnelLease.
The tunnel handler's ONLY gate is ValidateTunnelLease(leaseHash, peerID), and that function never inspects peerID — it checks only that the lease exists, is LeaseAccepted, and that this node is the provider. There is no check that the dialing peer is the lease's consumer (PeerForAccount(lease.Consumer)), no signature over the lease hash, and no comparison against AccessPubKey. The peerID parameter is dead.
Contrast with the two intended gates on the same VM: the HTTP endpoint POST /tunnel/{leaseHash}/tcp (api/tunnel.go) requires header X-Signature verified by core.VerifyHexSignature(lease.AccessPubKey, …) over the lease hash, and the SSH gateway (node/ssh_gateway.go) compares the presented Ed25519 key byte-for-byte with AccessPubKey. The libp2p tunnel skips both.
Reachability: any peer can connect to a provider's libp2p host (no allowlist; NetworkGater only bans wrong-network/wrong-version peers, and a stock xe node passes netcheck trivially). Lease hashes are public (GET /leases, GET /leases/{hash}). The attacker needs no account, no key, no signature — only the 32-byte lease hash, sent as the first tunnel message. No per-peer rate limiter is applied to the tunnel protocol (unlike net/msg.go, net/sync.go, net/netcheck.go, which all use peerRateLimiter); only the libp2p resource manager's per-IP connection cap (8 conns/IP, net/host.go) bounds it.
Impact
Capped, honestly stated: the tunnel hands the attacker a raw TCP pipe to the victim VM's SSH port (vm/qemu_manager.go:298 / vm/lima_manager.go:182, DialSSH dials 127.0.0.1:<vm ssh port>). The VM itself still requires the lease SSH key: QEMU cloud-init installs ONLY the AccessPubKey (vm/qemu_template.go, ssh_pwauth: false) and Lima sets PermitRootLogin prohibit-password + PasswordAuthentication no (vm/lima_template.go). So this is NOT a direct shell — the attacker cannot log in without the consumer's private key. What it does give a complete stranger, for ANY tenant's VM on ANY provider: unauthenticated network reachability to the VM's sshd (banner/version fingerprinting, sshd exploit surface, SSH-auth probing), cross-tenant isolation failure at the tunnel layer, and an unthrottled channel for connection-exhaustion against the provider (each tunnel holds a backend TCP conn + 2 goroutines, registry unbounded, no per-lease/per-peer tunnel cap). Hence Medium, not High: no shell, no data, no funds without the lease key.
Steps to reproduce
Unit test against the real node code (github.com/xeprotocol/xe, testnet-0005, commit 89a542e):
git clone https://github.com/xeprotocol/xe
cd xe
cp trackc_tunnel_test.go node/
go test ./node -run TestTrackC_TunnelAnyPeer -v
Note: trackc_tunnel_test.go is NOT in the public repository — the PoC test file is attached to this issue; without it, the XE team cannot run this reproduction.
TestTrackC_TunnelAnyPeer: an arbitrary unrelated peer (not the lease consumer, not the provider) calls ValidateTunnelLease for an accepted lease.
Expected: the unrelated peer is rejected; only the lease consumer's peer passes. Actual (reproduced 2026-11-13, PASS as a bug-demonstrating test):
=== RUN TestTrackC_TunnelAnyPeer
trackc_tunnel_test.go:56: consumer peer allowed (expected)
trackc_tunnel_test.go:63: BUG CONFIRMED: arbitrary unrelated peer "2dLTETvbnJuVtSUUsA3XG8dr8DHCyM6vsZT1bcv9rHB4cVgTtehi6CXjbA" passes ValidateTunnelLease for lease abababababab (provider 8d6944d627cd, consumer 90c1f2c13523)
trackc_tunnel_test.go:70: control: unknown lease rejected (expected)
trackc_tunnel_test.go:80: control: settled lease rejected (expected)
--- PASS: TestTrackC_TunnelAnyPeer (0.00s)
Root cause
node/node.go:2176, ValidateTunnelLease: the peerID argument is never compared against anything — no peerID == n.PeerForAccount(lease.Consumer) check, no signature over the lease hash by AccessPubKey. The libp2p tunnel handler (net/tunnel.go, SetupTunnelHandler) relies solely on this function, unlike the HTTP tunnel endpoint and the SSH gateway, which both authenticate the caller.
Suggested fix
In ValidateTunnelLease, require peerID == n.PeerForAccount(lease.Consumer) (directory lookup, as provisionVM/GetVM already do for the consumer), or better, require the dialing peer to present a signature over the lease hash by the AccessPubKey in the tunnel handshake (same check as the HTTP endpoint). Also cap concurrent tunnels per lease/per peer and apply the existing peerRateLimiter to the tunnel protocol.
Controls verified (same track, all PASS / NOT VULNERABLE)
- VM access with the wrong key is blocked at the SSH gateway and at the HTTP tunnel endpoint (Round 1, still holds) — the libp2p tunnel is the exception: it checks NO key at all.
- SSH session reuse after lease expiry / cancel / settle: a new
direct-tcpipchannel re-enters throughValidateTunnelLease, which re-checks state — settled/cancelled/expired leases are rejected; the provider closes registered tunnels infinishSettleand tears the VM down within 10 s viacleanupOrphanedVMsfor any terminal lease. - No unauthenticated state change was found on any other API endpoint (full route enumeration in
api/handler.go). - VM/tunnel key confusion: SSH gateway and HTTP tunnel both require exactly
AccessPubKey; QEMU/Lima install exactly that key. No confusion path found.
Thread
Thanks. This is the same finding as https://bounty.xe.network/XE-0015, 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-13374 and says what differs; it is read like any other.