<!-- XE-16867 · [Medium] SSH gateway per-IP limits have no IPv6 subnet grouping — one /64 fills all connection slots · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16867>. The page is the record; this is the same page for reading.*

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](https://github.com/xeprotocol/xe/issues/677)
filed 2026-11-17 06:50 UTC
by kecedanzz77-bit

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   Node / API

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770002](https://bounty.xe.network/log/770002) 2026-11-22 23:26 UTC reply.mirror\_failed
- [769807](https://bounty.xe.network/log/769807) 2026-11-22 23:26 UTC proposal.adopted
- [769806](https://bounty.xe.network/log/769806) 2026-11-22 23:26 UTC reply.sent
- [769805](https://bounty.xe.network/log/769805) 2026-11-22 23:26 UTC proposal.adopted
- [769804](https://bounty.xe.network/log/769804) 2026-11-22 23:26 UTC ticket.status new → closed
- [768729](https://bounty.xe.network/log/768729) 2026-11-22 23:25 UTC proposal.adopted
- [768728](https://bounty.xe.network/log/768728) 2026-11-22 23:25 UTC ticket.facts area
- [768727](https://bounty.xe.network/log/768727) 2026-11-22 23:25 UTC proposal.adopted
- [768726](https://bounty.xe.network/log/768726) 2026-11-22 23:25 UTC ticket.facts
- [768725](https://bounty.xe.network/log/768725) 2026-11-22 23:25 UTC proposal.adopted
- [768724](https://bounty.xe.network/log/768724) 2026-11-22 23:25 UTC ticket.facts
- [766715](https://bounty.xe.network/log/766715) 2026-11-22 23:18 UTC note.added

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

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