GHSA-3HM4-P7H4-RVWP
russh: pre-authentication stack exhaustion via nested OpenSSH certificates (ssh-key dependency)
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-3HM4-P7H4-RVWP divulgada · CVSS 7.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
russh 0.61.0+ processes attacker-controlled OpenSSH certificate blobs before authentication: on the server side, the `publickey` authentication request is parsed before any signature check; on the client side, the SSH server's host key is parsed during key exchange. The pinned `ssh-key` version (`=0.7.0-rc.10` / `=0.7.0-rc.11`) decodes nested certificates recursively with no depth limit, so a crafted certificate blob aborts the process with an uncatchable stack overflow. About 92 KB of blob is enough to kill any default (2 MiB) thread stack; one full 256 KiB packet (2848 nesting levels) also kills 4 MiB stacks.
The root cause is in the `ssh-key` crate and has been reported upstream to RustCrypto/SSH. This report tracks the russh-side exposure and the dependency coordination; please consider it a heads-up rather than a separate root-cause fix.
Affected versions
- russh >= 0.61.0 through 0.64.1 (current). v0.61.0 is the first release pinning `ssh-key = "=0.7.0-rc.10"`; v0.62.0+ pin `=0.7.0-rc.11`. Both are affected (upstream recursion was introduced in ssh-key 0.7.0-rc.6).
- Releases before 0.61.0 use the `internal-russh-forked-ssh-key` fork based on upstream ssh-key 0.6.x (verified on 0.6.18+upstream-0.6.7); its `KeyData::decode` does not re-enter certificate decoding - not affected.
Vulnerable paths in russh
Server (pre-authentication), `russh/src/server/encrypted.rs:960-964` (`server_read_auth_request_pk`):
let is_real = map_err!(u8::decode(r))?;
let pubkey_algo = map_err!(String::decode(r))?;
let pubkey_key = map_err!(Bytes::decode(r))?;
let key_or_cert = PublicKeyOrCertificate::decode(&pubkey_algo, &pubkey_key);`PublicKeyOrCertificate::decode` (`russh/src/cert.rs:44-59`) calls `ssh_key::Certificate::decode` for certificate algorithm names and `KeyData::decode` otherwise - both lead into the same unbounded recursion for a crafted blob (the outer algorithm name does not need to be certificate-like, because the non-certificate branch calls `KeyData::decode` on the blob, which re-enters the certificate path from the blob's own first string). This happens before any signature verification; a `publickey` probe with `is_real = 0` triggers it.
Client, `russh/src/client/kex.rs:291-304`:
let server_host_key_blob = Bytes::decode(r)?;
let server_host_certificate = if names.host_key_is_certificate {
Some(Certificate::from_bytes(&server_host_key_blob)?)
} else { ...and the non-certificate path (`russh/src/keys/key.rs:40-42`): `ssh_key::public::KeyData::decode(&mut p)`. A malicious/compromised server crashes the client during KEX. wasm builds (russh's wasm client, typically a 1 MiB stack) are affected as well.
Trigger and measurements
Each certificate nesting level costs 92 bytes on the wire with the smallest valid encoding (algorithm string `a-cert-v01@x`, empty nonce/key id/principals/options, empty opaque public key, signature algorithm `a@b` with a 1-byte blob). One 256 KiB SSH packet therefore carries 2848 levels, forcing ~6 MB of stack consumption (~23x amplification).
Measured on Windows x86_64, rustc 1.99.1, release build of a standalone harness (the blob is fed to `Certificate::from_bytes`, the exact function russh calls):
| Thread stack | Crashing depth | Blob size at crash |
|---|---|---|
| Windows main thread (~1 MiB) | 492 | 45,275 B |
| default spawned thread, i.e. Rust std default (2 MiB; also tokio default) | 1000 | 92,011 B |
| 4 MiB | 2016 | 185,483 B |
| 8 MiB | 4048 | 372,427 B (one packet max: 2848 levels = 262,027 B - survives in release) |
Depth 2848 aborts 1 MiB / 2 MiB / 4 MiB threads with `STATUS_STACK_OVERFLOW` (0xC00000FD), verified directly; stack usage ~2.1 KiB/level release, ~6.9 KiB/level debug (debug builds crash even 8 MiB stacks). Rust std gives spawned threads a 2 MiB default/minimum stack (`library/std/src/sys/thread/windows.rs:14`, `library/std/src/sys/thread/unix.rs:31`), which tokio worker threads inherit when `thread_stack_size` is unset - i.e. the default configuration of a typical async server is inside the crash range.
Impact
- One unauthenticated, single-packet request (~92 KB payload) aborts the entire server process in default configurations - not just the connection or task; the abort is not catchable in Rust.
- A malicious server can crash any client that merely connects to it (same parse during KEX).
- wasm targets (client) are affected regardless of host configuration.
Suggested handling
- The root-cause fix belongs in `ssh-key` (depth cap on nested certificate decoding); we have reported it to RustCrypto/SSH and are happy to coordinate timing. Once a fixed `ssh-key` is released, bumping the workspace pin resolves this for russh.
- If an interim mitigation is desired, the parse entry could cheaply pre-validate nesting depth before handing the blob to `ssh-key` (e.g. reject blobs that contain more than one nested `-cert-v01@` algorithm marker), or russh could vendor a patched `ssh-key` as it historically did with `internal-russh-forked-ssh-key`. Raising thread stacks above ~6 MiB is only a partial mitigation (release builds only; not applicable to wasm).
Reporter
Tshellauth
References
- Pinned dependency: `ssh-key = "=0.7.0-rc.11"` (workspace `Cargo.toml`; `=0.7.0-rc.10` at v0.61.0).
- Upstream vulnerable code: https://github.com/RustCrypto/SSH/blob/master/ssh-key/src/certificate.rs#L519 and `ssh-key/src/public/key_data.rs`
- Upstream report: filed 2026-10-16 with RustCrypto/SSH (advisory pending).
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
crates.iorussh |
Corregida | 0.65 | — | — |
0.65Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Eugeny/russh/security/advisories/GHSA-3hm4-p7h4-rvwpLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
