CVE-2026-42189: Russh Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-f5v4-2wr6-hqmg
CVSS 7.5
CWE-789 CWE-770
Published
Advisory Summary

CVE-2026-42189 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-789: Memory Allocation with Excessive Size Value) affecting Russh libraries in the crates.io ecosystem. The issue involves russh has pre-auth dos via unbounded allocation in its keyboard-interactive auth handler. Remediation is available by upgrading affected packages to version 0.60.1.

CVE-2026-42189 at a Glance

CVE Identifier CVE-2026-42189
GHSA Identifier GHSA-f5v4-2wr6-hqmg
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-789: Memory Allocation with Excessive Size Value
Affected Product Russh
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-42189

To remediate this vulnerability, upgrade all affected Russh dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

russh fixed: 0.60.1
Upgrade russh to 0.60.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for russh

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-42189, inspect your project dependencies for Russh:

inspect dependencies for russh

Analyze the terminal output to locate any version of Russh in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.60.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-789: Memory Allocation with Excessive Size Value, where the product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated. In Russh, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary A pre-authentication denial-of-service vulnerability exists in the server's keyboard-interactive authentication handler. A malicious client can crash any russh-based server that implements keyboard-interactive auth (e.g., for 2FA/TOTP) with a single malformed packet, requiring no credentials. ## Vulnerability Details In `russh/src/server/encrypted.rs`, the function `read_userauth_info_response` decodes a `u32` count from the client's `SSH_MSG_USERAUTH_INFO_RESPONSE` and passes it directly to `Vec::with_capacity()`: ```rust let n = map_err!(u32::decode(r))?; // Bound both allocation and iteration by remaining packet data to // prevent a malicious client from causing a multi-GB allocation or // billions of loop iterations with a crafted count. // Each response needs at least 4 bytes (length prefix). let max_responses = r.remaining_len().saturating_add(3) / 4; let n = (n as usize).min(max_responses); let mut responses = Vec::with_capacity(n); for _ in 0..n { responses.push(Bytes::decode(r).ok()) } ``` An attacker can send `n = 0x10000000` (268M) or larger in a minimal packet (~50 bytes after encryption). The server attempts to allocate `n * ~24 bytes` (size of `Option<Bytes>`) = ~6.4GB, causing an OOM crash. ## Attack Flow 1. Attacker connects via TCP, completes key exchange (no credentials needed -- this is the anonymous DH handshake, not authentication) 2. Sends `USERAUTH_REQUEST` with method `keyboard-interactive` 3. Server handler returns `Auth::Partial` with prompts (standard for 2FA/TOTP) 4. Attacker sends `USERAUTH_INFO_RESPONSE` with `n = 0x10000000` and no response data 5. Server calls `Vec::with_capacity(268_435_456)`, OOM killed No authentication is required. The allocation occurs before the handler validates any credentials. The attack is repeatable faster than the server can restart. ## Affected Configurations Any russh-based server where the `Handler::auth_keyboard_interactive` implementation returns `Auth::Partial` (i.e., sends prompts to the client). The default handler returns `Auth::reject()` and is not affected. Source code review suggests that downstream projects using keyboard-interactive for multi-step auth (e.g., TOTP/2FA) follow the affected pattern, since returning `Auth::Partial` before credential verification is the intended API usage for prompting. ## Confirmed End-to-End PoC There is a complete Docker-contained PoC confirming the OOM kill: - Minimal russh server returning `Auth::Partial` for keyboard-interactive - Python client (paramiko for key exchange) sends malformed `USERAUTH_INFO_RESPONSE` - Container with 512MB memory limit; server is OOM-killed (exit code 137) Available on request. ## Proposed Fix Cap the `Vec::with_capacity` allocation to what the remaining packet data can actually contain. Each response requires at least 4 bytes (length prefix), so: ```rust let n = map_err!(u32::decode(r))?; // Bound both allocation and iteration by remaining packet data to // prevent a malicious client from causing a multi-GB allocation or // billions of loop iterations with a crafted count. // Each response needs at least 4 bytes (length prefix). let max_responses = r.remaining_len().saturating_add(3) / 4; let n = (n as usize).min(max_responses); let mut responses = Vec::with_capacity(n); for _ in 0..n { responses.push(Bytes::decode(r).ok()) } ``` This bounds the allocation to at most the packet size (~256KB), while preserving the existing behavior for well-formed packets. This fix has been implemented, tested, and contributed via the temporary private fork. ## Severity Pre-auth, remote, no credentials required, crashes the server process affecting all active sessions.

CVE-2026-42189 Affected Russh Versions

1 component(s)
Fixed Versions:
0.60.1
Product / Package Ecosystem Affected Versions Fixed Version
russh
crates.io
< 0.60.1
0.60.1

References

Frequently Asked Questions

What is CVE-2026-42189?
CVE-2026-42189 is a security vulnerability in Russh involving russh has pre-auth DoS via unbounded allocation in its keyboard-interactive auth handler under CWE-789: Memory Allocation with Excessive Size Value.
Which Russh versions are affected?
Affected versions include releases prior to 0.60.1 across affected packages: russh.
What version fixes CVE-2026-42189?
Upgrading to 0.60.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is russh affected?
Yes, russh is affected in releases prior to 0.60.1. Upgrade your dependency to 0.60.1 or later.
What is the CVSS score of CVE-2026-42189?
CVE-2026-42189 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-42189?
CVE-2026-42189 is classified under CWE-789: Memory Allocation with Excessive Size Value (The product allocates memory based on an untrusted, large size value, but it does not ensure that the size is within expected limits, allowing arbitrary amounts of memory to be allocated.).
How can I check crates.io dependencies for CVE-2026-42189?
Run the dependency tree command: 'inspect dependencies for russh'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-f5v4-2wr6-hqmg",
  "modified" : "2026-05-13T13:34:53Z",
  "published" : "2026-04-24T15:39:37Z",
  "aliases" : [ "CVE-2026-42189" ],
  "summary" : "russh has pre-auth DoS via unbounded allocation in its keyboard-interactive auth handler",
  "details" : "## Summary\n\nA pre-authentication denial-of-service vulnerability exists in the server's keyboard-interactive authentication handler. A malicious client can crash any russh-based server that implements keyboard-interactive auth (e.g., for 2FA/TOTP) with a single malformed packet, requiring no credentials.\n\n## Vulnerability Details\n\nIn `russh/src/server/encrypted.rs`, the function `read_userauth_info_response` decodes a `u32` count from the client's `SSH_MSG_USERAUTH_INFO_RESPONSE` and passes it directly to `Vec::with_capacity()`:\n\n```rust\nlet n = map_err!(u32::decode(r))?;\n\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).\nlet max_responses = r.remaining_len().saturating_add(3) / 4;\nlet n = (n as usize).min(max_responses);\nlet mut responses = Vec::with_capacity(n);\nfor _ in 0..n {\n    responses.push(Bytes::decode(r).ok())\n}\n```\n\nAn attacker can send `n = 0x10000000` (268M) or larger in a minimal packet (~50 bytes after encryption). The server attempts to allocate `n * ~24 bytes` (size of `Option<Bytes>`) = ~6.4GB, causing an OOM crash.\n\n## Attack Flow\n\n1. Attacker connects via TCP, completes key exchange (no credentials needed -- this is the anonymous DH handshake, not authentication)\n2. Sends `USERAUTH_REQUEST` with method `keyboard-interactive`\n3. Server handler returns `Auth::Partial` with prompts (standard for 2FA/TOTP)\n4. Attacker sends `USERAUTH_INFO_RESPONSE` with `n = 0x10000000` and no response data\n5. Server calls `Vec::with_capacity(268_435_456)`, OOM killed\n\nNo authentication is required. The allocation occurs before the handler validates any credentials. The attack is repeatable faster than the server can restart.\n\n## Affected Configurations\n\nAny russh-based server where the `Handler::auth_keyboard_interactive` implementation returns `Auth::Partial` (i.e., sends prompts to the client). The default handler returns `Auth::reject()` and is not affected.\n\nSource code review suggests that downstream projects using keyboard-interactive for multi-step auth (e.g., TOTP/2FA) follow the affected pattern, since returning `Auth::Partial` before credential verification is the intended API usage for prompting.\n\n## Confirmed End-to-End PoC\n\nThere is a complete Docker-contained PoC confirming the OOM kill:\n- Minimal russh server returning `Auth::Partial` for keyboard-interactive\n- Python client (paramiko for key exchange) sends malformed `USERAUTH_INFO_RESPONSE`\n- Container with 512MB memory limit; server is OOM-killed (exit code 137)\n\nAvailable on request.\n\n## Proposed Fix\n\nCap the `Vec::with_capacity` allocation to what the remaining packet data can actually contain. Each response requires at least 4 bytes (length prefix), so:\n\n```rust\nlet n = map_err!(u32::decode(r))?;\n\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).\nlet max_responses = r.remaining_len().saturating_add(3) / 4;\nlet n = (n as usize).min(max_responses);\nlet mut responses = Vec::with_capacity(n);\nfor _ in 0..n {\n    responses.push(Bytes::decode(r).ok())\n}\n```\n\nThis bounds the allocation to at most the packet size (~256KB), while preserving the existing behavior for well-formed packets. This fix has been implemented, tested, and contributed via the temporary private fork.\n\n## Severity\n\nPre-auth, remote, no credentials required, crashes the server process affecting all active sessions.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "russh"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.60.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/security/advisories/GHSA-f5v4-2wr6-hqmg"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-42189"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/commit/6c3c80a9b6d60763d6227d60fa8310e57172a4d1"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Eugeny/russh"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/releases/tag/v0.60.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-770", "CWE-789" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-24T15:39:37Z",
    "nvd_published_at" : "2026-05-08T20:16:31Z"
  }
}