{"id":"XE-12563","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":827,"title":"[Medium] SSH gateway: unsolicited channel responses on an accepted session channel freeze the connection mux","area":"node-api","claimed_tier":"medium","assessed_tier":null,"verdict":"duplicate","duplicate_of":null,"tracked":true,"internal_ref":"#1182","internal_url":"https://github.com/xeprotocol/core/issues/1182","status":"closed","closed_reason":"duplicate","github_state":"","disclosed_at":null,"award_xe":null,"award_approved":false,"paid_ref":"","created_at":"2026-11-14T06:41:47.849623+00:00","updated_at":"2026-11-20T19:45:48.316300+00:00","source_created_at":null,"told_at":"2026-11-20T19:45:48.352750+00:00","status_changed_at":"2026-11-20T19:45:48.326158+00:00","url":"https://bounty.xe.network/XE-12563","body":"# [Medium] SSH gateway: unsolicited channel responses on an accepted session channel freeze the connection mux\n\n**Tier claim: Medium** — one authenticated leaseholder freezes one of their own SSH connections with 17 tiny packets addressed to an accepted channel 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). This leg works on **session** channels, which XE-4903's own control proved immune to the channel-*request* flood.\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 channel request-success/failure messages with a **blocking send** on the channel's `ch.msg`, a 16-slot buffered channel that is only ever read when the application calls `SendRequest` with `WantReply=true` and waits for the reply. On XE's gateway, nothing ever reads `ch.msg` on an accepted channel: `handleSession` ranges only over the channel's *requests* (`node/ssh_gateway.go:211-236`), and the one `SendRequest` the gateway makes (`sendExitStatus`, `:242-245`) uses `WantReply=false`. An authenticated leaseholder who opens a session channel and sends 17 unsolicited `SSH_MSG_CHANNEL_SUCCESS` (99) / `SSH_MSG_CHANNEL_FAILURE` (100) packets addressed to that channel's server-side id 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.\n\n## Root cause (file:line)\n\n1. `go.mod:13` — `golang.org/x/crypto v0.47.0`.\n2. Library `ssh/channel.go:477` — `msg: make(chan interface{}, chanSize)` with `chanSize = 16` (`ssh/handshake.go:26`).\n3. Library `ssh/channel.go:462-467` (`(*channel).handlePacket`, runs on the mux read loop): `*channelRequestSuccessMsg` / `*channelRequestFailureMsg` fall into the `default:` case:\n   ```go\n   default:\n       ch.msg <- msg   // BLOCKING send; loop stalls when full\n   ```\n   (Open-confirm/failure messages are *not* a vector: `responseMessageReceived` errors on inbound channels. Only the 99/100 response messages reach the blocking send.)\n4. The only reader of `ch.msg` is `SendRequest` with `WantReply=true` (`ssh/channel.go:588-604`). The gateway never calls it that way on accepted channels: `handleSession` never calls `SendRequest` at all, `handleDirectTCPIP` never calls it, and `sendExitStatus` passes `WantReply=false`.\n5. `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.\n6. `node/ssh_gateway.go:30,84-94` — `maxSSHConnections = 100`; the slot is released only by the `defer` in the handler goroutine, which never runs.\n7. Upstream fix (v0.53.0): `handlePacket` now drops response messages arriving when no `SendRequest` is pending (`sentRequestPending` 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_ChannelResponseFlood -v -count=1`:\n\n```\ncontrol: second session channel opens promptly without any flood\nattack: authenticate, open a session channel, send 20 unsolicited\n        SSH_MSG_CHANNEL_SUCCESS packets to the server channel id\nprobe: open a second session channel -> TIMED OUT after 3s (mux read loop frozen)\nPASS: mux frozen after 20 unsolicited channel responses on a session channel (2nd open timed out after 3s)\nPASS: gw.Stop() hangs >3s after flood + client disconnect (connSem slot held forever)\n--- PASS: TestR46_ChannelResponseFlood (6.51s)\n```\n\nThe control step (second channel opens fine with no flood) proves the freeze is caused by the flood. The `Stop()` hang proves the slot is held permanently even after the attacker disconnects. 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 tiny packets on one session channel 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 `ch.msg`), different message type (requests vs responses), different fix site (drain direct-tcpip requests vs gate channel responses). Decisively: XE-4903's own control proves the identical flood on a *session* channel (which XE drains in `handleSession`) does **not** freeze the connection — this report freezes it on a session channel, so it cannot be XE-4903's mechanism.\n- **XE-5949 (GO-2026-6354)** — channel-REQUEST flood on a *rejected* channel's `incomingRequests`. Same distinction (requests vs responses, `incomingRequests` vs `ch.msg`), and this report needs an *accepted* channel, not a rejected one.\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).\n- **XE-4826 / XE-10029 / XE-0716** — channel-count / channel-data exhaustion. This report opens exactly one channel and sends no channel data.\n- The sibling report on unsolicited *global* responses (same round, same reporter) is a separate leg: different buffer (`globalResponses` vs `ch.msg`), different message types (81/82 vs 99/100), different fix site (`mux.go` vs `channel.go`), different precondition (no channel needed vs one accepted channel) — the same separation the board already accepts between XE-4903 and XE-5949.\n- Keyword sweeps over all 1,948 titles (open/closed/awarded) for `channel response`, `ch.msg`, `response flood`, `unsolicited` → 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 channel responses with `sentRequestPending` 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":3061,"source":"web","source_ref":"reporter:827:b0f9dfbf1754eb80","author":"xe:952f5eaf","team":false,"body":"Minor citation correction: `sendExitStatus` is at `node/ssh_gateway.go:248`, not :242-245 as written in the body. The claim stands unchanged — it calls SendRequest with WantReply=false, so it never reads ch.msg.","created_at":"2026-11-14T06:44:59.154921+00:00"},{"id":15168,"source":"desk","source_ref":"reply:13058","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-12563 and says what differs; it is read like any other.","created_at":"2026-11-20T19:45:48.316300+00:00"}]}