<!-- XE-13374 · 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 · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13374>. The page is the record; this is the same page for reading.*

XE-13374 · Bounty

# 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

Closed · duplicate
—claimed Medium
[xe#528](https://github.com/xeprotocol/xe/issues/528)
filed 2026-11-13 03:20 UTC
by AIRDROP TREASURESS

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   Node / API

Duplicate of
:   [XE-0015](https://bounty.xe.network/XE-0015) fixing

Tracked
:   internally

Updated
:   2026-11-20 00:52 UTC

Told
:   2026-11-20 00:50 UTC

### Patches

- [xe#554](https://github.com/xeprotocol/xe/pull/554) open by Khanhtnq
  node,net: authenticate tunnel consumer peer and cap concurrent tunnel streams (Fixes #528)
- [xe#914](https://github.com/xeprotocol/xe/pull/914) open by tipprb
  fix(xe): unauthenticated-cross-tenant-l (fixes #528)

### History

- [559937](https://bounty.xe.network/log/559937) 2026-11-20 00:52 UTC github.state\_pushed
- [559934](https://bounty.xe.network/log/559934) 2026-11-20 00:52 UTC github.labels
- [559549](https://bounty.xe.network/log/559549) 2026-11-20 00:50 UTC reply.mirrored
- [558872](https://bounty.xe.network/log/558872) 2026-11-20 00:50 UTC proposal.adopted
- [558871](https://bounty.xe.network/log/558871) 2026-11-20 00:50 UTC reply.sent
- [558870](https://bounty.xe.network/log/558870) 2026-11-20 00:50 UTC ticket.status new → closed
- [557769](https://bounty.xe.network/log/557769) 2026-11-20 00:49 UTC proposal.adopted
- [557768](https://bounty.xe.network/log/557768) 2026-11-20 00:49 UTC ticket.facts area
- [557767](https://bounty.xe.network/log/557767) 2026-11-20 00:49 UTC proposal.adopted
- [557766](https://bounty.xe.network/log/557766) 2026-11-20 00:49 UTC ticket.facts
- [557765](https://bounty.xe.network/log/557765) 2026-11-20 00:49 UTC proposal.adopted
- [557764](https://bounty.xe.network/log/557764) 2026-11-20 00:49 UTC ticket.facts

[Full history](https://bounty.xe.network/log?ref=XE-13374) · [JSON](https://bounty.xe.network/v1/tickets/XE-13374) · [markdown](https://bounty.xe.network/XE-13374.md)

### 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-tcpip` channel re-enters through `ValidateTunnelLease`, which re-checks state — settled/cancelled/expired leases are rejected; the provider closes registered tunnels in `finishSettle` and tears the VM down within 10 s via `cleanupOrphanedVMs` for 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.

[trackc\_tunnel.txt](https://github.com/user-attachments/files/34781598/trackc_tunnel.txt)

### Thread

**Joseph Denne**team2026-11-20 00:50 UTCgithub

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.
