Bounty
XE-0048 · Bounty

SSH gateway: 100 silent pre-auth connections exhaust all connection slots and deny the gateway indefinitely (no handshake deadline)

Awarded High xe#67 filed 2026-10-26 12:17 UTC by juantzy7

Report

Suggested tier: High Area: SSH gateway (node/ssh_gateway.go), compute leasing access path Code: released tree at HEAD 978785929bc17a2f4ab30c383e5fc9cf4d634512 (testnet-0005)

Summary

The SSH gateway shipped with the node takes one slot from a fixed pool of 100 connection slots for every accepted TCP connection, before any handshake or authentication takes place, and it never sets a deadline on the connection. The SSH library the node pins, golang.org/x/crypto/ssh v0.47.0, has no handshake timeout of its own. A client that opens a connection and sends nothing therefore holds its slot for as long as it keeps the socket open. One unauthenticated host holding 100 silent connections fills the pool completely, and from that moment the gateway closes every new connection at accept time, including connections from legitimate lease holders presenting the correct lease key. The denial lasts exactly as long as the attacker keeps the sockets open, and nothing in the gateway ever expires a pre-auth connection. The same codebase does enforce a 30 second handshake deadline on its tunnel protocol (net/tunnel.go), so the missing deadline on the gateway reads as an oversight rather than a design choice.

Root cause

All references are to the released code at the HEAD above.

  1. node/ssh_gateway.go:30 declares const maxSSHConnections = 100, and the gateway constructor creates the semaphore channel with that capacity at node/ssh_gateway.go:57.
  2. The accept loop in Start() (node/ssh_gateway.go:66) acquires one slot per accepted connection at node/ssh_gateway.go:82, before the connection is handed to a handler goroutine. When no slot is free it logs "ssh: connection limit reached (100), rejecting" (node/ssh_gateway.go:84) and closes the new connection immediately. The slot is released only when the handler goroutine returns (node/ssh_gateway.go:91), and the handler returns only when the connection ends.
  3. handleConnection (node/ssh_gateway.go:104) passes the raw connection straight to ssh.NewServerConn at node/ssh_gateway.go:149. There is no call to SetDeadline, SetReadDeadline or SetWriteDeadline anywhere in node/ssh_gateway.go.
  4. go.mod:13 pins golang.org/x/crypto v0.47.0, and its ssh server code contains no handshake timeout: NewServerConn blocks reading the client version string and then the key exchange for as long as the peer stays silent.
  5. The gateway is a shipped, documented server. The node starts it on 0.0.0.0 whenever it runs with --ssh-port greater than 0 (flag at cmd/xe/main.go:1312, gateway started at cmd/xe/main.go:1421 to 1423). The shipped xe ssh client defaults to the team's public gateway, XE_SSH_HOST defaulting to ldn.test.network and the port to 2222 (cmd/xe/main.go:1195 to 1201).
  6. Contrast inside the same codebase: net/tunnel.go:22 defines tunnelHandshakeDeadline = 30 seconds and applies it at net/tunnel.go:73 and net/tunnel.go:151, the sync protocols set stream deadlines, and all three HTTP servers set a 10 second ReadHeaderTimeout. The SSH gateway is the one server with no handshake deadline at all.

Reproduction

Everything below ran locally on loopback against the released code, with the gateway constructed through the real node.NewSSHGateway. No load was sent to the public testnet or to any public node. Full proof sources and captured outputs accompany this report as a proof of concept file; the two proofs are summarized here.

Proof A, a Go test through the real authentication path (test file node/zz_lane_sshgw_test.go, run with: go test ./node/ -run TestSSHGatewayIdleConnectionExhaustion -v -count=1). A legitimate client using the correct lease hash as username and the correct private key completes authentication and a session and receives the gateway's jump hint. The attacker then opens 100 raw TCP connections and sends nothing. The identical legitimate login is reset at accept time and the gateway logs "connection limit reached (100), rejecting". It is still rejected after a further 3 seconds. When the attacker closes the silent connections, the legitimate login succeeds again. Result: PASS in 3.53 seconds.

Proof B, a measurement harness running the real gateway with a real SSH client as the legitimate probe (run with: go run . 35, for a 35 second hold). At baseline the banner probe returns SSH-2.0-Go, a full client handshake reaches the authentication stage in 2 to 4 milliseconds, and the process sits at 5 goroutines and 7 to 8 file descriptors. After 100 raw connections that send zero bytes are opened, the process is at 102 goroutines and 207 file descriptors, the banner probe gets EOF, and full SSH client probes are reset immediately. Legitimate access is denied 100 percent for the whole hold. After holds of 35 and 40 seconds the state is unchanged, and on release the gateway recovers instantly (handshake back to 2 milliseconds, goroutines back to 5).

On duration, stated precisely: the indefinite hold is a code level inference, because no deadline exists anywhere on this listener to expire a pre-auth connection. What was measured is total denial across holds of 35 to 40 seconds in the harness and 3 seconds in the unit test, and 35 seconds already exceeds the 30 second handshake deadline this codebase enforces on its own tunnel protocol. No multi hour outage is claimed as measured.

Impact

Every lease holder who reaches a leased VM through an SSH gateway run with --ssh-port loses that access completely for the duration of the attack, including everyone using the documented default flow in which the shipped xe ssh client targets the team's public gateway at ldn.test.network:2222. The operator running such a gateway has its users cut off at the same time.

Attacker cost: 100 idle TCP connections from a single host. No account, no key, no lease, no funds, no proof of work, and zero bytes of application data. There is no ongoing traffic to detect or rate limit, and the attacker can re-establish the full set of connections in under a second after any interruption.

Bounds, stated honestly: only the gateway jump function is denied. The node itself, the ledger, P2P networking and the HTTP API keep running, and no consensus or finality impact is claimed. The gateway is opt-in on the server side (a node must be started with --ssh-port greater than 0); the affected deployment is any gateway actually run that way, which on the evidence of the shipped client defaults includes the team's public gateway, whose exact deployment configuration (flags and any fronting controls) was not observed. An alternate access path survives: a consumer running their own node can still reach their VM through that node's own API tunnel. That path is not the shipped default flow, it does not restore the attacked gateway service, and every user of a shared or public gateway is denied at once regardless.

Suggested fix

Set a deadline on each accepted connection before the handshake and clear it once the handshake succeeds, mirroring the pattern the codebase already uses for tunnels: conn.SetDeadline(time.Now().Add(30 * time.Second)) before ssh.NewServerConn in handleConnection, then conn.SetDeadline(time.Time{}) after a successful handshake. In addition, add a per-IP cap on concurrent pre-auth connections in the accept loop, so a single host cannot consume the whole pool even inside the deadline window. Counting only post-handshake connections against the global semaphore would also remove the pre-auth exhaustion vector entirely.

Relation to previously reported issues

This finding is distinct from issue #4, although both touch node/ssh_gateway.go. Issue #4 concerns the authentication and lease layer of the gateway (the lease state check in the authentication callback around node/ssh_gateway.go:121 and the missing peer binding in ValidateTunnelLease) and the tunnel design; those defects operate inside or after authentication and need a lease context. This finding sits one layer below, in the accept loop before any authentication exists: it needs no credential and no lease, its mechanism (a pre-auth semaphore with no handshake deadline) is different, and its fix is disjoint (issue #4's fix PR adds no deadline). It is likewise distinct from issues #41 and #47, which concern rate limiting keyed by libp2p peer ID on the P2P message layer; this listener is plain TCP, has no peer IDs and no rate limiter of any kind.

Methodology

This research was assisted by AI tooling. Every claim in this report was validated by running the included proofs against the released code at the stated HEAD, and every line reference was re-checked against that tree before submission.

Reporter XE address for reward payment: 616c200e9cf87b2f831f0956a16125d041636e9bf69517c4a6e85d78af9b73d8

Thread

Nothing public yet.