{"id":"XE-16691","kind":"bounty","visibility":"public","source":"github","source_repo":"xeprotocol/xe","source_ref":"644","source_url":"https://github.com/xeprotocol/xe/issues/644","reporter_id":2920,"title":"[Medium] Tunnel handler: no concurrency limit and no idle timeout lets one peer exhaust provider VM SSH","area":"p2p-sync","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":false,"internal_ref":"","internal_url":"","status":"closed","closed_reason":"duplicate","github_state":"open","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-17T05:13:22.837799+00:00","updated_at":"2026-11-22T23:26:17.418722+00:00","source_created_at":"2026-11-17T05:12:54+00:00","told_at":"2026-11-22T23:26:17.461205+00:00","status_changed_at":"2026-11-22T23:26:17.430740+00:00","url":"https://bounty.xe.network/XE-16691","body":"## Summary\n`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.\n\n## Root Cause\n- After the handshake (`tunnelHandshakeDeadline` 30s), the handler calls `s.SetDeadline(time.Time{})` (`net/tunnel.go:100`), removing all deadlines; the two `io.Copy` goroutines then run until either side closes.\n- `TunnelRegistry` only tracks tunnels for lease-close cleanup (`CloseTunnelsForLease`); it never limits how many exist.\n- 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.\n\n## Impact\n- ~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.\n- Each idle tunnel holds a libp2p stream, a backend TCP connection, and 2 goroutines indefinitely (idle tunnels never time out), exhausting provider-node resources.\n\n## Note on related reports\n#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.\n\n## Verification\nSource-level at HEAD `8cc209d` (testnet-0006).\n\n## Suggested fix\nPer-lease and per-peer tunnel caps; idle timeout (e.g. close after 5-10 min with no bytes transferred).","patch_refs":[],"thread":[{"id":18885,"source":"desk","source_ref":"reply:16562","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-16691 and says what differs; it is read like any other.","created_at":"2026-11-22T23:26:17.418722+00:00"}]}