<!-- XE-10005 · SSH Gateway Connection Pool Starvation: handleDirectTCPIP lacks read/idle timeouts permitting permanent semaphore DoS · testnet -->
*Markdown view of <https://bounty.xe.network/XE-10005>. The page is the record; this is the same page for reading.*

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

Verdict
:   Duplicate

Tier
:   —

Claimed
:   —

Area
:   Node / API

Duplicate of
:   —

Tracked
:   internally

Updated
:   2026-11-20 00:33 UTC

Told
:   2026-11-20 00:33 UTC

### Patches

None linked.

### History

- [552619](https://bounty.xe.network/log/552619) 2026-11-20 00:33 UTC proposal.adopted
- [552618](https://bounty.xe.network/log/552618) 2026-11-20 00:33 UTC reply.sent
- [552617](https://bounty.xe.network/log/552617) 2026-11-20 00:33 UTC ticket.status new → closed
- [552044](https://bounty.xe.network/log/552044) 2026-11-20 00:33 UTC proposal.adopted
- [552043](https://bounty.xe.network/log/552043) 2026-11-20 00:33 UTC ticket.facts area
- [552042](https://bounty.xe.network/log/552042) 2026-11-20 00:33 UTC proposal.adopted
- [552041](https://bounty.xe.network/log/552041) 2026-11-20 00:33 UTC ticket.facts
- [552040](https://bounty.xe.network/log/552040) 2026-11-20 00:33 UTC proposal.adopted
- [552039](https://bounty.xe.network/log/552039) 2026-11-20 00:33 UTC ticket.facts
- [552038](https://bounty.xe.network/log/552038) 2026-11-20 00:33 UTC proposal.adopted
- [552037](https://bounty.xe.network/log/552037) 2026-11-20 00:33 UTC ticket.facts
- [550914](https://bounty.xe.network/log/550914) 2026-11-20 00:31 UTC note.added

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

### 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 Denne**team2026-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.
