{"id":"CVE-2026-48107","aliases":["GHSA-g9g7-5cgw-6v28"],"title":"Russh: Unchecked keyboard-interactive prompt count in client auth path","summary":"Russh: Unchecked keyboard-interactive prompt count in client auth path","severity":"medium","cvss":6.5,"cwe":["CWE-20"],"vendor":"russh","product":"russh","ecosystem":"rust","affected":["russh >= 0.37.0, < 0.61.0"],"patched":["russh 0.61.0"],"published":"2026-06-11","updated":"2026-06-11","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-g9g7-5cgw-6v28","references":[{"url":"https://github.com/Eugeny/russh/security/advisories/GHSA-g9g7-5cgw-6v28"},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-48107"},{"url":"https://github.com/advisories/GHSA-g9g7-5cgw-6v28"}],"tags":["ghsa","rust"],"epss":0.00418,"epssPercentile":0.3335,"ingestedAt":"2026-07-07T15:41:59.287Z","slug":"CVE-2026-48107","body":"## Overview\n\n### Summary\nIn the `russh` client keyboard-interactive authentication path, a malicious SSH server could send a `USERAUTH_INFO_REQUEST` with an attacker-controlled prompt count, and the client would use that raw count directly in `Vec::with_capacity(...)` before validating that enough prompt data was actually present in the packet.\n\nThis is a client-side denial-of-service / resource-exhaustion issue on the keyboard-interactive auth path.\n\n### Details\nThe vulnerable code path is in:\n\n- `russh/src/client/encrypted.rs`\n\nWhen the client is in `CurrentRequest::KeyboardInteractive` state and receives `SSH_MSG_USERAUTH_INFO_REQUEST`, it parses:\n\n1. `name`\n2. `instructions`\n3. `language tag`\n4. `n_prompts`\n\nBefore the fix, the code then did:\n\n```rust\nlet n_prompts = map_err!(u32::decode(&mut r))?;\nlet mut prompts = Vec::with_capacity(n_prompts.try_into().unwrap_or(0));\n```\n\nThat means a malicious server could advertise an enormous `n_prompts` value even if the packet contained no prompt bodies at all.\n\nThe fix rejects inconsistent prompt counts before allocating:\n\n```rust\nlet n_prompts = map_err!(u32::decode(&mut r))?;\nlet max_prompts = r.remaining_len() / 5;\nlet n_prompts = n_prompts as usize;\nif n_prompts > max_prompts {\n    return Err(crate::Error::Inconsistent.into());\n}\nlet mut prompts = Vec::with_capacity(n_prompts);\n```\n\nEach prompt needs at least 4 bytes of string length plus 1 byte of echo flag, so `remaining_len() / 5` is a safe upper bound. If the declared count exceeds what the packet can actually contain, the packet is malformed and is now rejected instead of being silently truncated.\n\nThe tester did not find a same-class server-side bug in the reciprocal `USERAUTH_INFO_RESPONSE` path. The server already bounds the response count by remaining packet length before allocating.\n\nAffected package and versions:\n\n- package: `russh`\n- earliest affected stable: `0.37.0`\n- confirmed affected current release: `0.60.2`\n\nThe tester does not believe this issue affects the other crates in this workspace (`russh-config`, `russh-cryptovec`, `pageant`, or `russh-util`).\n\n### PoC\nAn in-tree regression test was added:\n\n- `client::tests::oversized_keyboard_interactive_prompt_count_is_rejected`\n\nThe test builds a client session in `WaitingAuthRequest(KeyboardInteractive)` state, feeds it a synthetic `USERAUTH_INFO_REQUEST` packet with:\n\n- normal `name`\n- normal `instructions`\n- empty language tag\n- `n_prompts = u32::MAX`\n- no prompt bodies\n\nOn the fixed code, the client rejects the packet with `Error::Inconsistent` and does not emit a reply to the caller.\n\nFor old-code impact verification, the pre-fix path was also checked separately with a constrained-memory repro. On unfixed `upstream/main`, the same malformed packet attempted a very large allocation and failed with:\n\n```text\nmemory allocation of 137438953440 bytes failed\n```\n\nRelevant verification commands:\n\n```bash\ncargo test -p russh oversized_keyboard_interactive_prompt_count_is_rejected -- --nocapture\ncargo test -p russh --lib --no-default-features --features ring oversized_keyboard_interactive_prompt_count_is_rejected -- --nocapture\n```\n\n### Impact\nSuggested CVSS v3.1:\n\n- `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H`\n- Score: `6.5`\n\nReasoning:\n\n- `AV:N`: reached by a malicious SSH server over the network\n- `AC:L`: the packet format is straightforward\n- `PR:N`: no prior authentication required\n- `UI:R`: the victim must initiate a connection and proceed into keyboard-interactive auth\n- `C:N`, `I:N`:  Confidentiality or integrity impact were not demonstrated\n- `A:H`: the server can drive a very large allocation attempt in the client auth path, which can abort or exhaust client-side resources depending on allocator and platform behavior\n\n## Affected packages\n\n- `russh >= 0.37.0, < 0.61.0`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `russh 0.61.0`","depth":"sunlit","depthScore":36,"depthScoreParts":{"impact":35.8,"likelihood":0.1,"exploitation":0,"ransomware":0},"changes":[]}