{"id":"XE-10005","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":730,"title":"SSH Gateway Connection Pool Starvation: handleDirectTCPIP lacks read/idle timeouts permitting permanent semaphore DoS","area":"node-api","claimed_tier":null,"assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1049","internal_url":"https://github.com/xeprotocol/core/issues/1049","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-12T09:05:00.490895+00:00","updated_at":"2026-11-20T00:33:20.254143+00:00","source_created_at":null,"told_at":"2026-11-20T00:33:20.267966+00:00","status_changed_at":"2026-11-20T00:33:20.259892+00:00","url":"https://bounty.xe.network/XE-10005","body":"## Vulnerability Summary\n\nIn `node/ssh_gateway.go:179-209`, `SSHGateway.handleDirectTCPIP` handles SSH port forwarding channels to tunnel consumer traffic to provider VMs:\n\n```go\nfunc (gw *SSHGateway) handleDirectTCPIP(channel ssh.Channel, lease *core.Lease) {\n\tdefer func() { _ = channel.Close() }()\n\n\tctx, cancel := context.WithCancel(context.Background())\n\tdefer cancel()\n...\n\ttunnel, err := gw.backend.OpenTunnel(ctx, providerPeer, lease.LeaseHash)\n\tif err != nil {\n\t\treturn\n\t}\n\tdefer func() { _ = tunnel.Close() }()\n\n\tvar wg sync.WaitGroup\n\twg.Add(2)\n\tgo func() { defer wg.Done(); _, _ = io.Copy(channel, tunnel) }()\n\tgo func() { defer wg.Done(); _, _ = io.Copy(tunnel, channel) }()\n\twg.Wait()\n}\n```\n\nThe gateway constrains total concurrent connections via a semaphore channel with a static capacity:\n```go\nconst maxSSHConnections = 100\n...\nconnSem: make(chan struct{}, maxSSHConnections),\n```\n\nThe tunnel forwarding goroutines `io.Copy(channel, tunnel)` and `io.Copy(tunnel, channel)` do not enforce any read/write deadlines, idle timeouts, or keepalive heartbeats. If a client opens an SSH direct-tcpip channel and ceases transmitting data (or half-closes the connection), `wg.Wait()` blocks indefinitely.\n\nBecause `gw.connSem` has only 100 slots, an attacker (or slow/hanging consumer clients) holding 100 idle TCP connections will exhaust the connection pool. Subsequent connection attempts block or fail, completely preventing all legitimate consumers from accessing their active VMs.\n\n## Root Cause Analysis\n\n1. Absence of Idle Deadline: `io.Copy` performs blocking reads without TCP keep-alive or application-level idle timers.\n2. Unbounded WaitGroup Blocking: `wg.Wait()` hangs forever if neither side sends an EOF or closes the channel.\n3. Global Semaphore Depletion: Each connection consumes 1 of 100 `connSem` slots. Holding 100 idle channels permanently starves the gateway.\n\n## Proposed Remediation\n\n1. Implement an idle timeout on the underlying tunnel and channel (e.g. 15 minutes of inactivity triggers context cancellation).\n2. Configure TCP keepalive probes on `net.Conn` instances.\n3. Automatically terminate sessions when leases settle, cancel, or expire.","patch_refs":[],"thread":[{"id":13247,"source":"desk","source_ref":"reply:11269","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-10005 and says what differs; it is read like any other.","created_at":"2026-11-20T00:33:20.254143+00:00"}]}