Bounty
XE-16690 · Bounty

[High] SSH gateway: unbounded channels per authenticated connection exhaust gateway goroutines and flood VM sshd

Closed · duplicate —claimed High xe#643 filed 2026-11-17 05:12 UTC by kecedanzz77-bit

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 after ssh.NewServerConn and enforces only the connection-level caps.
  • The channel loop (node/ssh_gateway.go:218-245) accepts every session and direct-tcpip channel 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-tcpip channels open an unbounded number of concurrent TCP connections to the provider VM's sshd, tripping MaxStartups and 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

Joseph Denneteam2026-11-22 23:26 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-16690 and says what differs; it is read like any other.