GHSA-35G8-35P8-C8FW
Russh: Unbounded memory exhaustion via CHANNEL_OPEN flood during a client-stalled rekey
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 0.63.2 | russh · -27 d desde divulgación | |
| Divulgación | Publicada | GHSA-35G8-35P8-C8FW divulgada | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice |
Summary
A russh server can be driven to unbounded heap growth (process OOM / kill) by
a peer that speaks only standard SSH messages, in the default configuration.
The peer starts a key re-exchange (sends `SSH_MSG_KEXINIT`) but never sends the
follow-up `SSH_MSG_KEX_ECDH_INIT`, leaving the server's kex state machine in
`SessionKexState::InProgress` indefinitely. While a rekey is in progress the
server's three message-drain paths are all gated off (`if !self.kex.active()`),
but the network-read path stays active, so every `SSH_MSG_CHANNEL_OPEN` the peer
sends is processed inline and appends one reply to an unbounded internal
queue (`priority_receiver`, an `UnboundedReceiver`) that is not dequeued until
the rekey completes. Because the peer decides whether the rekey ever completes,
the queue — and the server's memory — grows without bound.
This is reproducible end-to-end against a real russh server over a real
encrypted transport; see "Proof of concept". A one-line negative control (same
flood, no rekey) keeps memory flat, isolating the rekey window as the sole
trigger.
Impact
- Availability / DoS. Server RSS climbs at roughly 3.3 KB per
- Reached with standard messages, no special configuration. Any handler is
- The peer keeps the connection alive simply by continuing to send, so the
Affected component
- `russh/src/server/session.rs` — `Session::run` `tokio::select!` loop. The
- `russh/src/server/mod.rs` — `reply()` routes a non-kex message received during
- `russh/src/lib_inner.rs` — `ChannelOpenHandleInner`'s `accept`/`reject`/`Drop`
Verified on v0.63.1 (commit `d3ae702`), which is the latest release. The
gating logic predates it.
Details
`Session::run` (`russh/src/server/session.rs:631`) drives a `tokio::select!`
(`:713`). Three of its message-drain sites are gated on `!self.kex.active()`:
- the pre-`select!` batch drain of `priority_receiver`/`receiver`
- the `priority_receiver.recv()` arm (`session.rs:762`),
- the `receiver.recv()` arm (`session.rs:770`, which also holds the only other
The fourth arm, `r = &mut reading` (`session.rs:714`), is ungated: it reads
and processes one incoming packet every loop iteration regardless of rekey
state, calling `reply()` (`server/mod.rs:1128`).
During a rekey, `session.common.encrypted.is_some()`, so the strict-kex
message-ordering guard (`server/mod.rs:1143`, which is additionally gated on
`encrypted.is_none()`) does not apply. A non-kex message therefore falls
through `reply()` to `session.server_read_encrypted(handler, pkt)`
(`server/mod.rs:1232`) and is handled inline. For `SSH_MSG_CHANNEL_OPEN` this
reaches the channel-open handling, which hands the application a
`ChannelOpenHandle`.
Whether the handler accepts or (the trait default) rejects, the handle's
`accept` / `reject` / `Drop` all `send` a `Msg::ChannelOpenReply` on an
`UnboundedSender` (`russh/src/lib_inner.rs:560-603`; `Drop` sends
`AdministrativelyProhibited` at `:594-603`). That sender feeds
`priority_receiver`, declared `UnboundedReceiver<Msg>` (`session.rs:23`) and
created with `tokio::sync::mpsc::unbounded_channel()` (`session.rs:1522`). Its
only drain sites are the three arms gated off during the rekey. So each
`CHANNEL_OPEN` processed during the rekey window appends one reply (carrying a
`PendingChannelOpen` = channel params + mpsc `ChannelRef` + ids, a few KB
retained in practice) to a queue that is never dequeued.
Two facts make this unbounded and remote:
- The server enters `InProgress` the moment it receives the peer's `KEXINIT`
- There is no per-connection cap on channels or on the priority queue, and the
Root cause
The intended design was to *buffer* packets received during a rekey and replay
them afterwards: the fields `pending_reads: Vec<Vec<u8>>` and `pending_len: u32`
(`session.rs:26-27`) exist and are drained at kex completion
(`server/mod.rs:1194-1198`). But nothing ever pushes to `pending_reads` or
increments `pending_len` (they are dead — confirmed by grep across
`russh/src/`). Instead of being buffered, channel messages received during a
rekey are processed inline, and their replies pile up in the unbounded
`priority_receiver`. The missing piece is a bound on — or bounded deferral of —
channel processing while `kex.active()`.
Proof of concept
Everything runs inside a container; nothing touches the host.
Lab. `poc/Dockerfile` builds `russh-lab:head` from Eugeny/russh @ `d3ae702`
(v0.63.1), default features (rust 1.91). A raw-SSH-client PoC
(`poc/poc_rekey_dos.rs`) implements curve25519-sha256 / ssh-ed25519 /
aes256-ctr / hmac-sha2-256 by hand, completes the handshake and a `publickey`
auth, then:
- sends `SSH_MSG_KEXINIT` (server enters `kex.active()`),
- never sends `KEX_ECDH_INIT` (rekey stalls, attacker-held),
- floods `SSH_MSG_CHANNEL_OPEN`.
A minimal server (`poc/poc_server.rs`) uses the trait-default
`channel_open_session` (which rejects by dropping the handle), so the measured
growth is purely the undrained priority queue, not accepted-channel state.
`poc/run.sh` runs the attack leg and an identical negative control with no
rekey. Fresh run inside the lab, `N = 800,000` opens
(`results/rerun-2026-08-29.log`):
=== ATTACK (rekey stall) === (poc_server baseline_RSS=4208KB, N=800000)
t=2s server_RSS=667760KB
t=4s server_RSS=1599600KB
t=6s server_RSS=2556016KB
t=8s server_RSS=2566256KB (flood done; memory retained)
=== CONTROL (no rekey) === (poc_server baseline_RSS=4208KB, N=800000)
t=2s..t=12s server_RSS=4208KB (flat throughout)- ATTACK: RSS `4,208 KB → 2,566,256 KB` (~2.57 GB) and retained after the
- CONTROL: RSS flat at `4,208 KB`. Without the rekey window the replies are
The control isolates the rekey window as the sole trigger. Both legs exercise
the real server entry point (`Session::run` → `reply` → `server_read_encrypted`)
over a real encrypted transport.
Reproduce: `C=russh-lab N=800000 ./poc/run.sh` (see `poc/POC-README.md`).
Remediation
The priority queue carries locally generated channel-open replies, which are
non-kex messages the server must not send during a rekey anyway (RFC 4253
§7.1). So the fix is to bound how much channel work is done during a rekey, not
to drain the queue mid-rekey. Any of:
- (recommended, minimal) cap the number of non-kex messages processed while a
- bound / deferred-buffer channel messages during a rekey using the existing
- bound the number of in-flight channel opens per connection and reject beyond it.
OpenSSH does not service new channels mid-kex; matching that intent closes the
whole family.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
crates.iorussh |
Corregida | 0.63.2 | -27 d | 0.65.1 no afectada |
0.63.2Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://nvd.nist.gov/vuln/detail/CVE-2026-102821https://github.com/Eugeny/russh/security/advisories/GHSA-35g8-35p8-c8fwhttps://github.com/Eugeny/russh/commit/a282af361ac99bc76b80876d1aae128e89dbf66bhttps://github.com/Eugeny/russhhttps://github.com/Eugeny/russh/releases/tag/v0.63.2Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
