<!-- XE-16691 · [Medium] Tunnel handler: no concurrency limit and no idle timeout lets one peer exhaust provider VM SSH · testnet -->
*Markdown view of <https://bounty.xe.network/XE-16691>. The page is the record; this is the same page for reading.*

XE-16691 · Bounty

# \[Medium\] Tunnel handler: no concurrency limit and no idle timeout lets one peer exhaust provider VM SSH

Closed · duplicate
—claimed Medium
[xe#644](https://github.com/xeprotocol/xe/issues/644)
filed 2026-11-17 05:12 UTC
by kecedanzz77-bit

Verdict
:   Duplicate

Tier
:   —

Claimed
:   Medium

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-22 23:26 UTC

Told
:   2026-11-22 23:26 UTC

### Patches

None linked.

### History

- [770291](https://bounty.xe.network/log/770291) 2026-11-22 23:27 UTC reply.mirror\_failed
- [770127](https://bounty.xe.network/log/770127) 2026-11-22 23:26 UTC proposal.adopted
- [770126](https://bounty.xe.network/log/770126) 2026-11-22 23:26 UTC reply.sent
- [770125](https://bounty.xe.network/log/770125) 2026-11-22 23:26 UTC proposal.adopted
- [770124](https://bounty.xe.network/log/770124) 2026-11-22 23:26 UTC ticket.status new → closed
- [769384](https://bounty.xe.network/log/769384) 2026-11-22 23:26 UTC proposal.adopted
- [769383](https://bounty.xe.network/log/769383) 2026-11-22 23:26 UTC ticket.facts area
- [769382](https://bounty.xe.network/log/769382) 2026-11-22 23:26 UTC proposal.adopted
- [769381](https://bounty.xe.network/log/769381) 2026-11-22 23:26 UTC ticket.facts
- [769380](https://bounty.xe.network/log/769380) 2026-11-22 23:26 UTC proposal.adopted
- [769379](https://bounty.xe.network/log/769379) 2026-11-22 23:26 UTC ticket.facts
- [766048](https://bounty.xe.network/log/766048) 2026-11-22 23:17 UTC note.added

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

### Report

## Summary

`SetupTunnelHandler` (`net/tunnel.go:64-118`) accepts every `/xe/tunnel/2.0.0` stream that passes `ValidateTunnelLease`, dials the VM's SSH port, then clears the stream deadline and proxies forever with two goroutines per tunnel. There is no per-peer, per-lease, or global tunnel cap and no idle timeout, so a single peer can open enough concurrent tunnels to trip the VM sshd's `MaxStartups` and deny SSH to the legitimate lease consumer.

## Root Cause

- After the handshake (`tunnelHandshakeDeadline` 30s), the handler calls `s.SetDeadline(time.Time{})` (`net/tunnel.go:100`), removing all deadlines; the two `io.Copy` goroutines then run until either side closes.
- `TunnelRegistry` only tracks tunnels for lease-close cleanup (`CloseTunnelsForLease`); it never limits how many exist.
- The only bound is libp2p's generic resource manager (per-peer inbound streams, \~128 by default), which is shared across all protocols and bypassable with multiple peer IDs.

## Impact

- \~100\+ concurrent tunnels from one peer exceed a typical sshd `MaxStartups` (10:30:100), causing the VM to probabilistically drop all new SSH connections, including the legitimate consumer's.
- Each idle tunnel holds a libp2p stream, a backend TCP connection, and 2 goroutines indefinitely (idle tunnels never time out), exhausting provider-node resources.

## Note on related reports

#528 / XE-13246 cover the tunnel **auth** bypass (any peer opening a tunnel for any lease). This report is the distinct **resource-exhaustion** angle: even with valid authentication, there are no concurrency or idle limits.

## Verification

Source-level at HEAD `8cc209d` (testnet-0006).

## Suggested fix

Per-lease and per-peer tunnel caps; idle timeout (e.g. close after 5-10 min with no bytes transferred).

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