Bounty
XE-16867 · Bounty

[Medium] SSH gateway per-IP limits have no IPv6 subnet grouping — one /64 fills all connection slots

Closed · duplicate —claimed Medium xe#677 filed 2026-11-17 06:50 UTC by kecedanzz77-bit

Report

Summary

The SSH gateway's per-IP pre-auth and session limits key on the full remote IPv6 address with no subnet grouping, so an attacker with a single IPv6 /64 (one standard allocation) can rotate source addresses and bypass the per-IP limits entirely, filling all gateway connection slots. The SSH gateway is the only limiter in the codebase without subnet grouping: the API rate limiter groups IPv6 by /64, and the libp2p resource manager groups by /56 and /48.

Root Cause

remoteIP (node/ssh_gateway.go:122-127) returns the full remote host, and both limiters key on it verbatim:

  • acquirePreAuth (node/ssh_gateway.go:130-142): maxPreAuthPerIP = 3 per address, maxPreAuthConnections = 100 global (:38-40)
  • promoteToSession (node/ssh_gateway.go:158-170): maxSessionsPerIP = 10 per address, maxSSHConnections = 100 global (:32-34)

Contrast with the rest of the codebase:

  • clientKey (api/handler.go:416-429) groups IPv6 by /64 prefix.
  • newResourceManager (net/host.go:90-99) applies per-subnet limits at /56 and /48 for IPv6.

Impact

Pre-auth (no credentials needed): 3 slots per rotated address → all 100 maxPreAuthConnections slots filled. Each held connection dies at the 10s handshake deadline (sshHandshakeDeadline, node/ssh_gateway.go:36), but sustained reconnects keep the gateway locked out indefinitely. Legitimate tenants cannot connect.

Sessions (one valid lease key): 10 sessions per rotated address → all 100 maxSSHConnections slots filled, and with no post-auth idle timeout (conn.SetDeadline(time.Time{}) after handshake, node/ssh_gateway.go:240) they stay filled indefinitely.

Verification

Executed in-package test against the real accounting functions (acquirePreAuth / promoteToSession):

single IPv6 address 2001:db8::1: 3 pre-auth allowed, 4th rejected
rotating within 2001:db8::/64: 97 additional pre-auth slots acquired
preAuthTotal now 100 (global cap maxPreAuthConnections=100)
rotating within 2001:db8::/64: 100 authenticated sessions acquired (global cap maxSSHConnections=100)

Contrast test confirms the API limiter puts the whole /64 in one bucket: clientKey(2001:db8::1) = clientKey(2001:db8::2) = clientKey(2001:db8::ffff) = 2001:db8::/64.

Note on related reports

Distinct from #67 (awarded; pre-auth exhaustion with no handshake deadline on testnet-0005 — fixed on HEAD with the 10s deadline plus per-IP limits; this report is about the per-IP limits in that fix being bypassable via address rotation). Distinct from #643 (unbounded channels per connection) and #584 (lease never re-validated). Searched "SSH gateway IPv6", "maxSessionsPerIP pre-auth limit", "IPv6 rotation rate limit /64" — no covering report found.

Suggested fix

Group IPv6 remotes by /64 (or /56, matching the libp2p layer) in remoteIP / acquirePreAuth / promoteToSession, mirroring clientKey in api/handler.go.

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