[High] SSH gateway: unbounded channels per authenticated connection exhaust gateway goroutines and flood VM sshd
Report
Summary
The SSH gateway (node/ssh_gateway.go) limits TCP connections (100 total, 10 per IP) but places no limit on SSH channels per connection. After authenticating once with a valid lease, a client can open an unbounded number of session and direct-tcpip channels. Each direct-tcpip channel opens a libp2p tunnel to the provider VM's sshd plus two io.Copy goroutines; each session channel spawns a goroutine. One cheap lease can therefore exhaust the gateway's goroutines/memory and trip the VM sshd's MaxStartups, denying SSH to the legitimate consumer and other tenants.
Root Cause
promoteToSession(node/ssh_gateway.go:177-190) is called once per TCP connection afterssh.NewServerConnand enforces only the connection-level caps.- The channel loop (
node/ssh_gateway.go:218-245) accepts everysessionanddirect-tcpipchannel with no per-connection, per-lease, or global channel counter:session->go gw.handleSession(...)direct-tcpip->go gw.handleDirectTCPIP(...)->OpenTunnel(libp2p stream + 2 goroutines + handler + watcher)
golang.org/x/crypto/ssh(mux.go:handleChannelOpen) imposes no channel-count limit; it forwards every open to the application.
Impact
- Gateway-wide DoS: tens of thousands of channels from one authenticated connection = unbounded goroutine and memory growth on the gateway node.
- Cross-tenant DoS: unbounded
direct-tcpipchannels open an unbounded number of concurrent TCP connections to the provider VM's sshd, trippingMaxStartupsand denying SSH to the legitimate lease consumer and other tenants on that VM. - The 100/10 connection limits do not bound this at all.
Verification
Source-level: the limits in ssh_gateway.go (maxSSHConnections, maxSessionsPerIP) are only consulted in promoteToSession, which runs once per connection; the for newChan := range chans loop has no counter or cap. Audited at HEAD 8cc209d (testnet-0006).
Suggested fix
Cap channels per connection (e.g. 16-32) and per lease; reject excess channel opens.
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-16690 and says what differs; it is read like any other.