-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"Russh's April 20 patch for a denial-of-service bug on the server side of keyboard-interactive authentication shipped with a commit message that named the bug class out loud. \"Response count was read as a u32 from the client and passed directly to `Vec::with_capacity()`, allowing a malicious client to trigger a multi-GB allocation with a single small packet, crashing the server via OOM.\" The patched function was `read_userauth_info_response` in `russh/src/server/encrypted.rs`. The mirror image of that bug, the same `Vec::with_capacity` call against the same kind of untrusted `u32`, sat in `russh/src/client/encrypted.rs` on the same release.\n\nThirty days later, on May 20, russh merged the fix for CVE-2026-48110. The patch is the mirror image of April's, in the file next door, by a different author.\n\nAt v0.60.3, after the April patch shipped and before the May patch landed, the russh crate contained exactly two calls to `Vec::with_capacity` in non-test code, across 21,387 lines of source. One had a `remaining_len()` bound written above it. The other was CVE-2026-48110.\n\n## The April commit message named the bug class out loud\n\nThe April fix landed in russh as commit `6c3c80a`, released in v0.60.1. The commit's title is the SCM placeholder GitHub uses for security-advisory PRs: \"Merge commit from fork.\" The commit body is precise:\n\n> Bound both the Vec allocation and loop iteration count by the remaining packet data when parsing SSH_MSG_USERAUTH_INFO_RESPONSE. Previously, the response count was read as a u32 from the client and passed directly to `Vec::with_capacity()`, allowing a malicious client to trigger a multi-GB allocation with a single small packet, crashing the server via OOM.\n>\n> The fix caps the count to the maximum number of responses that could fit in the remaining packet data (each needs at least 4 bytes for a length prefix), bounding allocation to at most the packet size (~256KB).\n\nThe diff is six lines of meaningful change:\n\n```diff\n if let Some(CurrentRequest::KeyboardInteractive { ref submethods }) = auth_request.current {\n let n = map_err!(u32::decode(r))?;\n\n- let mut responses = Vec::with_capacity(n as usize);\n+ // Bound both allocation and iteration by remaining packet data to\n+ // prevent a malicious client from causing a multi-GB allocation or\n+ // billions of loop iterations with a crafted count.\n+ // Each response needs at least 4 bytes (length prefix).\n+ let max_responses = r.remaining_len().saturating_add(3) / 4;\n+ let n = (n as usize).min(max_responses);\n+ let mut responses = Vec::with_capacity(n);\n for _ in 0..n {\n responses.push(Bytes::decode(r).ok())\n }\n```\n\nThe shape of the bug is fully described in those four comment lines. An attacker-controlled `u32` field in an SSH message reaches `Vec::with_capacity()` without ever being checked against the size of the message that contains it. SSH packets are bounded at around 256 KB. The count field is bounded only by the type, four billion and change. A four-byte field tells the allocator to reserve gigabytes.\n\nThe April patch is the kind of fix a code reviewer can verify in thirty seconds. Cap the count by what the packet could actually contain. Per-element minimum size is 4 bytes (the length prefix on a string). `remaining_len() / 4` is the ceiling. `min()` it. Done.\n\nThe fix does not introduce a helper. It inlines the bound at the bug site. Every other decoder that calls `u32::decode` and feeds the result to a `Vec::with_capacity` is, on April 21, still unbounded. That is the design.\n\n## The same shape, in the file next door\n\nRussh implements both sides of the SSH wire. `russh/src/server/encrypted.rs` is the handler dispatch for messages the server receives. `russh/src/client/encrypted.rs` is the handler dispatch for messages the client receives. The two files are siblings. They handle opposite ends of the same protocol exchanges.\n\nKeyboard-interactive authentication (RFC 4256) has two halves. The server sends `SSH_MSG_USERAUTH_INFO_REQUEST` with a list of prompts the user must answer. The client returns `SSH_MSG_USERAUTH_INFO_RESPONSE` with a list of strings, one per prompt. Both messages carry a `u32` count followed by that many fields.\n\nApril fixed the server's response handler. The client's request handler, at `russh/src/client/encrypted.rs:166` in v0.60.3, looked like this:\n\n```rust\n} else if let Some(auth::CurrentRequest::KeyboardInteractive {\n ..\n}) = auth_request.current\n{\n debug!(\"keyboard_interactive\");\n\n // read fields\n let name = map_err!(String::decode(&mut r))?;\n let instructions = map_err!(String::decode(&mut r))?;\n let _lang = map_err!(String::decode(&mut r))?;\n let n_prompts = map_err!(u32::decode(&mut r))?;\n\n // read prompts\n let mut prompts =\n Vec::with_capacity(n_prompts.try_into().unwrap_or(0));\n for _i in 0..n_prompts {\n let prompt = map_err!(String::decode(&mut r))?;\n let echo = map_err!(u8::decode(&mut r))? != 0;\n prompts.push(Prompt {\n prompt: prompt.to_string(),\n echo,\n });\n }\n map_err!(ensure_end(&r))?;\n```\n\nThe decode reads three strings and a `u32`. The `u32` is `n_prompts`. The `u32` is passed to `Vec::with_capacity` through `.try_into().unwrap_or(0)`. The `.try_into().unwrap_or(0)` looks defensive and is not. `u32::try_into::()` cannot fail on any platform russh runs on, so the `unwrap_or(0)` branch is unreachable. The `Vec::with_capacity` receives the full `u32` widened to `usize`.\n\nA `Prompt` is a `String` plus a `bool`, 32 bytes after padding on a 64-bit target. `Vec::with_capacity(u32::MAX as usize)` requests `4_294_967_295 * 32` bytes, roughly 137 GB. The Rust allocator returns failure. The Vec growth path on allocation failure aborts the process.\n\nA single SSH packet from the server kills the client.\n\nThe May fix is structurally identical to April's:\n\n```diff\n- let mut prompts =\n- Vec::with_capacity(n_prompts.try_into().unwrap_or(0));\n+ // Each prompt needs at least a 4-byte length plus a 1-byte echo flag.\n+ let max_prompts = r.remaining_len() / 5;\n+ let n_prompts = n_prompts as usize;\n+ if n_prompts > max_prompts {\n+ return Err(crate::Error::Inconsistent.into());\n+ }\n+ let mut prompts = Vec::with_capacity(n_prompts);\n```\n\nCap the count by `remaining_len()` divided by the per-element minimum size. Per-element minimum is 5 this time (a 4-byte length prefix plus a 1-byte echo flag) instead of 4. The cap is otherwise the same shape. The inline comment is the same shape.\n\nApril's per-element minimum was four bytes. May's is five. The patch math diverges on exactly one digit.\n\n## What a malicious SSH server sends\n\nThe keyboard-interactive flow starts when the russh client sends `SSH_MSG_USERAUTH_REQUEST` with `method = \"keyboard-interactive\"`. Russh clients that allow keyboard-interactive as an authentication option route every connection's auth phase through this handler. The default examples in the russh repository include keyboard-interactive in the methods list.\n\nAfter receiving the auth request, a malicious SSH server responds:\n\n```\nbyte SSH_MSG_USERAUTH_INFO_REQUEST (60)\nstring \"\" (name)\nstring \"\" (instructions)\nstring \"\" (language)\nuint32 0xFFFFFFFF (num_prompts)\n```\n\nThe packet is 17 bytes plus the message-type byte and SSH framing. Total wire size under 50 bytes.\n\nThe russh client decodes the three empty strings, reads `n_prompts = 4_294_967_295`, and calls `Vec::with_capacity(4_294_967_295)`. The Rust allocator either grants overcommitted virtual memory that will OOM-kill the process on first touch, or fails the allocation immediately and the `RawVec` allocation-failure handler aborts. The russh client process is dead before it reads any of the prompts the request claimed to contain.\n\nCVSS records this as `AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`. The `PR:N` is correct from the attacker's vantage. The attacker is an SSH endpoint. No credentials are required to be an SSH endpoint. Any russh-based SSH client that connects to an attacker-controlled host and offers keyboard-interactive as an auth method is killed by a single inbound packet during the auth phase.\n\nThe reach is the set of programs that link russh and act as SSH clients. That includes git-over-SSH front-ends, SFTP tooling, automated backup clients, and admin tools that drive remote shells. The attack does not require the attacker to be on the target network, host the target server, or hold any credential. It requires only that the target connect to an SSH service the attacker controls.\n\n## The grep was already on the maintainer's screen\n\nAfter the April patch lands in v0.60.1, this command is the audit:\n\n```bash\n$ grep -rn \"Vec::with_capacity\" russh/src/\nrussh/src/server/encrypted.rs:531: let mut responses = Vec::with_capacity(n);\nrussh/src/client/encrypted.rs:166: Vec::with_capacity(n_prompts.try_into().unwrap_or(0));\n```\n\nTwo lines. 21,387 lines of Rust in `russh/src/`. The grep returns exactly two matches outside test code.\n\nMatch one is line 531 of `server/encrypted.rs`. Six lines above it is the April patch's bound. The match exists because someone reading the file in April typed it.\n\nMatch two is line 166 of `client/encrypted.rs`. There is no bound above it. The local variable being passed to `with_capacity` is named `n_prompts` and was decoded as a `u32` from the wire four lines earlier. The shape is identical to the bug the April patch closed. The shape is identical to the bug the April commit message described in plain English.\n\nThe grep that finds the next instance is the same grep that finds the patched one. A reviewer who pulls up `Vec::with_capacity` to verify April's fix is looking at the May bug in the second pane.\n\nRussh's April fix shipped as a private security advisory PR (\"Merge commit from fork\" is GitHub's marker for private security-advisory branches). The advisory workflow surfaces the file the patch touches. It does not enforce a grep across the rest of the codebase. The author of the April fix and the author of the May fix are different humans. The April author closed an instance. The May author found the instance the April patch had named.\n\nRussh shipped v0.60.1, v0.60.2, and v0.60.3 with the second match unbounded.\n\n## Russh's decode path is the substrate\n\nThis is the [design-debt-driver](/patterns/design-debt-driver) shape. Russh's decode path is the component, and \"decode an untrusted `u32`, feed it directly to a Vec sizing function\" is the bug class. The class has produced exhibits.\n\nGHSA-vgvv-x7xg-6cqg, fixed in v0.44.1 (August 2024). The vulnerable site was the SSH packet length parser in `russh/src/cipher/mod.rs`. The fix added a bound check on a `u32` length field read off the wire before it was used to size a buffer. Same shape, different decoder, in the lowest layer of the stack.\n\nThe April 2026 fix in `read_userauth_info_response`. The May 2026 fix in the keyboard-interactive client handler. Two patches, one month apart, on the same protocol exchange, on opposite sides.\n\nThree CVEs from the same shape over twenty-two months. Each fix is an inline bound at the bug site. Russh does not have a `decode_bounded_vec` helper. Russh's `helpers.rs` defines `read_prefixed` for byte strings, but nothing for length-prefixed sequences of typed values. Every decoder that consumes a count writes the bound check itself, or does not write one and ships the next instance of this class.\n\nThe substrate is the pattern `let n = u32::decode(r)?; Vec::with_capacity(n)`. The pattern is written one inlined fix at a time. The patches addressed instances. The substrate held the primitive. The next decoder added by a contributor who does not know to grep `Vec::with_capacity` will produce the next instance.\n\nThe SSH protocol has more length-prefixed sequences than this. Channel open requests carry counts. KEXINIT carries name-lists. Extension exchange carries entry counts. Each of those is a decoder that, written without a shared bounded helper, can repeat the bug. The April patch is documentation of how to write the bound inline. It is not enforcement of the bound across the codebase.\n\nPoC: [Eugeny/russh](https://github.com/Eugeny/russh) commit [311f6cf](https://github.com/Eugeny/russh/commit/311f6cf129016d5edc8db474a29062b0e1d69889) (fix), advisory [GHSA-4r3c-5hpg-58qr](https://github.com/Eugeny/russh/security/advisories/GHSA-4r3c-5hpg-58qr).","closing_line":"The April patch wrote the grep. Nobody ran it.","hook_md":"Russh's April 20 patch for a denial-of-service bug on the server side of keyboard-interactive authentication shipped with a commit message that named the bug class out loud. \"Response count was read as a u32 from the client and passed directly to `Vec::with_capacity()`, allowing a malicious client to trigger a multi-GB allocation with a single small packet, crashing the server via OOM.\" The patched function was `read_userauth_info_response` in `russh/src/server/encrypted.rs`. The mirror image of that bug, the same `Vec::with_capacity` call against the same kind of untrusted `u32`, sat in `russh/src/client/encrypted.rs` on the same release.\n\nThirty days later, on May 20, russh merged the fix for CVE-2026-48110. The patch is the mirror image of April's, in the file next door, by a different author.\n\nAt v0.60.3, after the April patch shipped and before the May patch landed, the russh crate contained exactly two calls to `Vec::with_capacity` in non-test code, across 21,387 lines of source. One had a `remaining_len()` bound written above it. The other was CVE-2026-48110.","post_id":608,"slug":"russh-cve-2026-48110-april-fix-named-may-bug","title":"CVE-2026-48110: Russh's April Patch Named the May Bug","type":"initial","unreadable_sentence":"At v0.60.3, russh contained exactly two calls to Vec::with_capacity in non-test code. One had a remaining_len bound written above it. The other was CVE-2026-48110."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCas6G4gAKCRDeZjl4jgkQ JhHHAQDVMkUyluv4QgVBT13b+Bfuxcce6C+8uQg/Qn/NbFXMgQEArw1GxN9gsDZw 4PViYZPxeY1Ugd+bkuccpZTr2opWZAw= =4L99 -----END PGP SIGNATURE-----