Bounty
XE-10005 · Bounty

SSH Gateway Connection Pool Starvation: handleDirectTCPIP lacks read/idle timeouts permitting permanent semaphore DoS

Closed · duplicate — web filed 2026-11-12 09:05 UTC by xe:e4cd6974

Report

Vulnerability Summary

In node/ssh_gateway.go:179-209, SSHGateway.handleDirectTCPIP handles SSH port forwarding channels to tunnel consumer traffic to provider VMs:

func (gw *SSHGateway) handleDirectTCPIP(channel ssh.Channel, lease *core.Lease) {
	defer func() { _ = channel.Close() }()

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
...
	tunnel, err := gw.backend.OpenTunnel(ctx, providerPeer, lease.LeaseHash)
	if err != nil {
		return
	}
	defer func() { _ = tunnel.Close() }()

	var wg sync.WaitGroup
	wg.Add(2)
	go func() { defer wg.Done(); _, _ = io.Copy(channel, tunnel) }()
	go func() { defer wg.Done(); _, _ = io.Copy(tunnel, channel) }()
	wg.Wait()
}

The gateway constrains total concurrent connections via a semaphore channel with a static capacity:

const maxSSHConnections = 100
...
connSem: make(chan struct{}, maxSSHConnections),

The 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.

Because 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.

Root Cause Analysis

  1. Absence of Idle Deadline: io.Copy performs blocking reads without TCP keep-alive or application-level idle timers.
  2. Unbounded WaitGroup Blocking: wg.Wait() hangs forever if neither side sends an EOF or closes the channel.
  3. Global Semaphore Depletion: Each connection consumes 1 of 100 connSem slots. Holding 100 idle channels permanently starves the gateway.

Proposed Remediation

  1. Implement an idle timeout on the underlying tunnel and channel (e.g. 15 minutes of inactivity triggers context cancellation).
  2. Configure TCP keepalive probes on net.Conn instances.
  3. Automatically terminate sessions when leases settle, cancel, or expire.

Thread

Joseph Denneteam2026-11-20 00:33 UTCdesk

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-10005 and says what differs; it is read like any other.