[Medium] Tunnel handler: no concurrency limit and no idle timeout lets one peer exhaust provider VM SSH
Report
Summary
SetupTunnelHandler (net/tunnel.go:64-118) accepts every /xe/tunnel/2.0.0 stream that passes ValidateTunnelLease, dials the VM's SSH port, then clears the stream deadline and proxies forever with two goroutines per tunnel. There is no per-peer, per-lease, or global tunnel cap and no idle timeout, so a single peer can open enough concurrent tunnels to trip the VM sshd's MaxStartups and deny SSH to the legitimate lease consumer.
Root Cause
- After the handshake (
tunnelHandshakeDeadline30s), the handler callss.SetDeadline(time.Time{})(net/tunnel.go:100), removing all deadlines; the twoio.Copygoroutines then run until either side closes. TunnelRegistryonly tracks tunnels for lease-close cleanup (CloseTunnelsForLease); it never limits how many exist.- The only bound is libp2p's generic resource manager (per-peer inbound streams, ~128 by default), which is shared across all protocols and bypassable with multiple peer IDs.
Impact
- ~100+ concurrent tunnels from one peer exceed a typical sshd
MaxStartups(10:30:100), causing the VM to probabilistically drop all new SSH connections, including the legitimate consumer's. - Each idle tunnel holds a libp2p stream, a backend TCP connection, and 2 goroutines indefinitely (idle tunnels never time out), exhausting provider-node resources.
Note on related reports
#528 / XE-13246 cover the tunnel auth bypass (any peer opening a tunnel for any lease). This report is the distinct resource-exhaustion angle: even with valid authentication, there are no concurrency or idle limits.
Verification
Source-level at HEAD 8cc209d (testnet-0006).
Suggested fix
Per-lease and per-peer tunnel caps; idle timeout (e.g. close after 5-10 min with no bytes transferred).
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-16691 and says what differs; it is read like any other.