{"id":"XE-12562","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":827,"title":"[Medium] SSH gateway: unsolicited global SSH responses freeze the connection mux, permanently holding a connSem slot","area":"node-api","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1049","internal_url":"https://github.com/xeprotocol/core/issues/1049","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T06:41:43.416626+00:00","updated_at":"2026-11-20T19:46:00.306249+00:00","source_created_at":null,"told_at":"2026-11-20T19:46:00.335652+00:00","status_changed_at":"2026-11-20T19:46:00.315929+00:00","url":"https://bounty.xe.network/XE-12562","body":"# [Medium] SSH gateway: unsolicited global SSH responses freeze the connection mux, permanently holding a connSem slot\n\n**Tier claim: Medium** — one authenticated leaseholder freezes one of their own SSH connections with 17 tiny packets and holds one gateway `connSem` slot **forever**, even after disconnecting; 100 such connections exhaust the whole `maxSSHConnections = 100` pool and the gateway refuses **all** new SSH connections. Availability only (no data, no funds), authenticated precondition — Medium, same grading as XE-4903/XE-5949 (the same permanence, different buffer).\n\n**Area:** node SSH gateway / dependency\n**Repo pin:** xe @ `89a542e` (testnet-0005); `go.mod:13` pins `golang.org/x/crypto v0.47.0` (vulnerable; fixed upstream in v0.53.0).\n\n## Summary (3 sentences)\n\nIn `golang.org/x/crypto v0.47.0` the SSH server mux delivers unsolicited global request-success/failure messages with a **blocking send** on `m.globalResponses`, a 16-slot buffered channel that is only ever read when the application itself sends a global request and waits for the reply. XE's SSH gateway never sends a global request (`node/ssh_gateway.go` only ever *discards* inbound global requests via `ssh.DiscardRequests`), so `globalResponses` is never drained. An authenticated leaseholder who sends 17 unsolicited `SSH_MSG_REQUEST_SUCCESS` (81) / `SSH_MSG_REQUEST_FAILURE` (82) packets blocks the mux read loop forever: no further packets are read on that connection (no new channels, no close processing), `handleConnection` never returns, and the `connSem` slot is held permanently — no channel needs to be opened at all.\n\n## Root cause (file:line)\n\n1. `go.mod:13` — `golang.org/x/crypto v0.47.0`.\n2. Library `ssh/mux.go:121` — `globalResponses: make(chan interface{}, chanSize)` with `chanSize = 16` (`ssh/handshake.go:26`).\n3. Library `ssh/mux.go:270` (`handleGlobalPacket`, runs on the mux read loop):\n   ```go\n   case *globalRequestSuccessMsg, *globalRequestFailureMsg:\n       m.globalResponses <- msg   // BLOCKING send; loop stalls when full\n   ```\n   The only reader of `globalResponses` is `(*mux).sendGlobalRequest` (`ssh/mux.go:143`), which the gateway never calls.\n4. `node/ssh_gateway.go:159-177` — after `ssh.NewServerConn` succeeds, `handleConnection` blocks on `for newChan := range chans`; it returns only when the mux closes, which never happens once the read loop is blocked.\n5. `node/ssh_gateway.go:30,84-94` — `maxSSHConnections = 100`; the slot is released only by the `defer` in the handler goroutine, which never runs.\n6. Upstream fix (v0.53.0): `handleGlobalPacket` now drops responses arriving when no `SendRequest` is pending (`globalSentPending` gate) and sends non-blocking — confirming the class and the fix site.\n\n## Reproduction (executed, deterministic, local only)\n\nReal `node.NewSSHGateway` in-process (stub lease backend, real ed25519 lease key, accepted lease) + a hand-written raw SSH client (the stock client cannot emit unsolicited response messages). Test `node/zz_r46_sshgw_test.go`, `go test ./node/ -run TestR46_GlobalResponseFlood -v -count=1`:\n\n```\ncontrol: second session channel opens promptly without any flood\nattack: authenticate, send 20 unsolicited SSH_MSG_REQUEST_SUCCESS packets (no channel opened)\nprobe: open a second session channel -> TIMED OUT after 3s (mux read loop frozen)\nPASS: mux frozen after 20 unsolicited global responses (2nd channel open timed out after 3s)\nPASS: gw.Stop() hangs >3s after flood + client disconnect (connSem slot held forever)\n--- PASS: TestR46_GlobalResponseFlood (6.51s)\n```\n\nThe control step (second channel opens fine with no flood) proves the freeze is caused by the flood, not by a broken gateway. The `Stop()` hang proves the slot is held permanently even after the attacker disconnects — the same permanence XE-4903 demonstrated for its leg. No live node was touched; everything ran on loopback.\n\n## Impact\n\n- One ordinary leaseholder (a valid lease + matching ed25519 key — normal customer credentials) freezes a gateway connection with 17 zero-payload packets and holds one of 100 `connSem` slots forever.\n- 100 frozen connections (one per slot) deny SSH gateway service to every leaseholder until the node process is restarted; `gw.Stop()` itself hangs in `wg.Wait()`, so even a graceful restart is blocked.\n- Scope is the SSH gateway only (jump-host port 2222, leaseholder → their own VM). Not consensus, not funds, not chain data — hence Medium, not High.\n\n## Why this is NOT a duplicate\n\n- **XE-4903 (GO-2026-6355)** — channel-REQUEST flood on an *accepted direct-tcpip* channel whose `incomingRequests` are discarded. Different buffer (`incomingRequests` vs `globalResponses`), different message type (requests vs responses), different fix site (drain direct-tcpip requests / established-state vs gate global responses). XE-4903's own control proves session channels are immune to its flood; this report needs **no channel at all**.\n- **XE-5949 (GO-2026-6354)** — channel-REQUEST flood on a *rejected* channel's `incomingRequests`. Same distinction: requests vs responses, `incomingRequests` vs `globalResponses`, and this report works with zero channels open (5949 needs a rejected channel).\n- **XE-6554 (CVE-2026-39827)** — memory growth from rejected channels retained in `chanList`. Different sink (heap vs mux liveness), different mechanism (no flood of any kind here — 17 packets freeze the loop without growing memory).\n- **XE-0048 / XE-2616 / XE-4139 / XE-10547** — pre-auth silent-connection slot exhaustion (no handshake deadline). This is post-auth, completes handshake + auth, and survives any handshake-deadline fix.\n- **XE-7931** — post-auth *idle* connections holding slots (zero channels, zero bytes, no flood). Different mechanism (idle hold vs mux-loop deadlock) and different fix (idle timeout vs response gating). A fix for XE-7931 does not unblock a frozen mux loop.\n- **XE-4826 / XE-10029 / XE-0716** — channel-count / channel-data exhaustion. This report opens zero channels.\n- Keyword sweeps over all 1,948 titles (open/closed/awarded) for `unsolicited`, `globalResponses`, `global response`, `request success`, `response flood` → zero hits for this mechanism; live `q=` searches agree.\n\n## Suggested fix\n\n- Upgrade `golang.org/x/crypto` to v0.53.0+ (upstream gates unsolicited global responses with `globalSentPending` and sends non-blocking).\n- XE-side hardening (defense in depth): none available in the gateway's own code — the send is inside the library's mux loop, so the upgrade is the real fix. A per-connection liveness watchdog (close connections whose mux makes no progress) would bound the damage.\n\n## Payout address\n\n`xe:952f5eaffd7af01d1c452ea68f2b37ed340ab773ed6ae4fb73c18fb2ef4edc8d`","patch_refs":[],"thread":[{"id":3060,"source":"web","source_ref":"reporter:827:4fc64eefa9ffd381","author":"xe:952f5eaf","team":false,"body":"Correction to the report body (does not change the mechanism or severity — it makes the finding stronger): `globalResponses` is NOT a 16-slot buffer. `ssh/mux.go:120` constructs it as `make(chan interface{}, 1)` — buffer 1, not `chanSize`. The mux read loop therefore blocks on the 2nd unsolicited global response, not the 17th. Confirmed with a 2-packet PoC (`TestR46_GlobalResponseTwoPackets`): after 2 unsolicited SSH_MSG_REQUEST_SUCCESS packets, a second channel open timed out after 3s and gw.Stop() hung >3s after client disconnect — identical permanence to the 20-packet repro in the body. Correct figures: 2 packets freeze the connection (not 17); buffer is 1 (not 16); citation is mux.go:120 (not mux.go:121).","created_at":"2026-11-14T06:44:58.962097+00:00"},{"id":15438,"source":"desk","source_ref":"reply:13329","author":"Joseph Denne","team":true,"body":"Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the\nfirst verifiable submission, so this one closes as a duplicate. If you believe it is a different\nbug, file a new report that links https://bounty.xe.network/XE-12562 and says what differs; it is read like any other.","created_at":"2026-11-20T19:46:00.306249+00:00"}]}