CVE-2026-128087: russh kex_done Shared-secret Callback Runs Before Server Vulnerability

LOW
Advisory Identifier: GHSA-9264-jvgf-6w2f
CVSS 3.7
CWE-863 CWE-696
Published
Advisory Summary

CVE-2026-128087 is a LOW (CVSS 3.7) shared-secret callback runs before server vulnerability (CWE-863: Incorrect Authorization) affecting russh kex_done libraries in the crates.io ecosystem. The issue involves shared-secret callback runs before server host-key verification. Remediation is available by upgrading affected packages to version 0.65.1.

CVE-2026-128087 at a Glance

CVE Identifier CVE-2026-128087
GHSA Identifier GHSA-9264-jvgf-6w2f
Severity LOW
CVSS v3.1 Base Score 3.7
CWE Classification CWE-863: Incorrect Authorization
Affected Product russh kex_done
Package Ecosystem crates.io
Published Date
Last Updated

Security Impact

CVSS: 3.7

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

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

How to Fix CVE-2026-128087

To remediate this vulnerability, upgrade all affected russh kex_done 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.65.1
Upgrade russh to 0.65.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-128087, inspect your project dependencies for russh kex_done:

inspect dependencies for russh

Analyze the terminal output to locate any version of russh kex_done in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.65.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-863: Incorrect Authorization, where the product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. In russh kex_done, 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 malicious SSH server whose host key is rejected can still cause russh's `client::Handler::kex_done()` callback to execute with the raw key-exchange shared secret. Applications using the callback for its documented protocol-bridging purpose may derive keys, initialize a secondary data channel, or perform another externally visible action before russh calls `check_server_key()` and rejects the server. ### Details During the initial key exchange, russh calls `kex_done()` immediately after the server proves possession of the presented host key, but before the application decides whether that key belongs to the intended server: ```rust let shared_secret = newkeys.kex.shared_secret_bytes(); handler .kex_done(shared_secret, &newkeys.names, session) .await?; // Initial KEX only checks trust afterwards. if let Some(certificate) = server_host_certificate { if !handler.check_server_key(&certificate.into()).await? { return Err(crate::Error::UnknownKey.into()); } } else if let Some(server_host_key) = server_host_key { let check = handler.check_server_key(&server_host_key.into()).await?; if !check { return Err(crate::Error::UnknownKey.into()); } } ``` This is in `russh/src/client/mod.rs` at lines 2036-2078 of commit `183a22e8f8f490fa09b6eb7bd044ef99d8c4414f`. The API documentation describes `check_server_key()` as the important trust decision that prevents man-in-the-middle attacks. It describes `kex_done()` as the callback for deriving keys for secondary encrypted channels. The feature request that introduced the callback specifically lists VPN-over-SSH, UDP data planes, file transfer, and custom enterprise transports as intended uses. Cryptographic verification of the KEX signature does not establish peer identity: an attacker operating its own SSH server can always produce a valid signature with its own host key. Identity is established only when `check_server_key()` accepts that key or certificate. ### Expected behavior For the initial key exchange, `check_server_key()` should accept the server identity before `kex_done()` exposes the shared secret for secondary-channel initialization. ### Actual behavior `kex_done()` runs first. An untrusted server can therefore trigger application-defined secondary-channel actions even though `check_server_key()` subsequently rejects it with `UnknownKey`. The callback was introduced by commit `500bef1eccc1c48ac674e2a262aa7887777431eb` and is present from `v0.55.0` through current `v0.65.0`. ### Proof of concept The following self-contained Cargo project starts a local russh server with a fresh, untrusted host key. The client models the documented bridge use case by exporting the shared secret in `kex_done()`, while `check_server_key()` rejects the server. It asserts both the failed connection and the callback order. Create an empty directory and add `Cargo.toml`: ```toml [package] name = "russh-kex-before-host-trust-poc" version = "0.1.0" edition = "2024" [dependencies] rand = { version = "0.10", features = ["thread_rng"] } russh = "=0.65.0" tokio = { version = "1", features = ["macros", "net", "rt-multi-thread"] } ``` Create `src/main.rs`: ```rust use std::sync::{Arc, Mutex}; use russh::keys::{Algorithm, PrivateKey, PublicKeyOrCertificate}; use russh::{Names, client, server}; #[derive(Clone)] struct TestServer; impl server::Handler for TestServer { type Error = russh::Error; } #[derive(Clone)] struct RejectingClient { events: Arc<Mutex<Vec<&'static str>>>, exported_secret: Arc<Mutex<Option<Vec<u8>>>>, } impl client::Handler for RejectingClient { type Error = russh::Error; async fn kex_done( &mut self, shared_secret: Option<&[u8]>, _names: &Names, _session: &mut client::Session, ) -> Result<(), Self::Error> { self.events.lock().unwrap().push("kex_done"); // Model a bridge exporting KEX material to a secondary protocol. *self.exported_secret.lock().unwrap() = shared_secret.map(ToOwned::to_owned); Ok(()) } async fn check_server_key( &mut self, _server_public_key: &PublicKeyOrCertificate, ) -> Result<bool, Self::Error> { self.events.lock().unwrap().push("check_server_key"); Ok(false) } } #[tokio::main] async fn main() { let mut server_config = server::Config::default(); server_config.inactivity_timeout = None; server_config .keys .push(PrivateKey::random(&mut rand::rng(), Algorithm::Ed25519).unwrap()); let server_config = Arc::new(server_config); let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap(); let address = listener.local_addr().unwrap(); tokio::spawn(async move { let (stream, _) = listener.accept().await.unwrap(); let _ = server::run_stream(server_config, stream, TestServer).await; }); let events = Arc::new(Mutex::new(Vec::new())); let exported_secret = Arc::new(Mutex::new(None)); let client = RejectingClient { events: events.clone(), exported_secret: exported_secret.clone(), }; let result = client::connect( Arc::new(client::Config::default()), address, client, ) .await; println!("connection accepted: {}", result.is_ok()); println!("callback order: {:?}", events.lock().unwrap()); println!( "secret exported before rejection: {}", exported_secret.lock().unwrap().is_some() ); assert!(matches!(result, Err(russh::Error::UnknownKey))); assert_eq!( events.lock().unwrap().as_slice(), &["kex_done", "check_server_key"] ); assert!(exported_secret.lock().unwrap().is_some()); } ``` Run: ```sh cargo run --quiet ``` Observed with russh `v0.65.0`: ```text connection accepted: false callback order: ["kex_done", "check_server_key"] secret exported before rejection: true ``` The connection fails with `russh::Error::UnknownKey`, but the security-sensitive callback and its modeled external side effect have already occurred. ### Impact Applications overriding `kex_done()` to bootstrap a secondary encrypted transport are affected. An unauthenticated attacker who can impersonate the SSH endpoint can complete KEX with an attacker-owned host key and trigger secondary channel initialization before that key is rejected. Depending on the bridge, this can expose early secondary-channel data or make the application act on a session established with an untrusted peer. Ordinary clients that leave `kex_done()` at its no-op default, or implementations that independently defer all callback-derived actions until host trust has been confirmed, are not affected.

CVE-2026-128087 Affected russh kex_done Versions

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

References

Frequently Asked Questions

What is CVE-2026-128087?
CVE-2026-128087 is a security vulnerability in russh kex_done involving Shared-secret callback runs before server host-key verification under CWE-863: Incorrect Authorization.
Which russh kex_done versions are affected?
Affected versions include releases prior to 0.65.1 across affected packages: russh.
What version fixes CVE-2026-128087?
Upgrading to 0.65.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.65.1. Upgrade your dependency to 0.65.1 or later.
What is the CVSS score of CVE-2026-128087?
CVE-2026-128087 has a CVSS v3.1 base score of 3.7 (LOW) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2026-128087?
CVE-2026-128087 is classified under CWE-863: Incorrect Authorization (The product performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check.).
How can I check crates.io dependencies for CVE-2026-128087?
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-9264-jvgf-6w2f",
  "modified" : "2026-11-13T19:20:16Z",
  "published" : "2026-11-13T19:20:16Z",
  "aliases" : [ "CVE-2026-128087" ],
  "summary" : "russh kex_done: Shared-secret callback runs before server host-key verification",
  "details" : "### Summary\n\nA malicious SSH server whose host key is rejected can still cause russh's `client::Handler::kex_done()` callback to execute with the raw key-exchange shared secret. Applications using the callback for its documented protocol-bridging purpose may derive keys, initialize a secondary data channel, or perform another externally visible action before russh calls `check_server_key()` and rejects the server.\n\n### Details\n\nDuring the initial key exchange, russh calls `kex_done()` immediately after the server proves possession of the presented host key, but before the application decides whether that key belongs to the intended server:\n\n```rust\nlet shared_secret = newkeys.kex.shared_secret_bytes();\nhandler\n    .kex_done(shared_secret, &newkeys.names, session)\n    .await?;\n\n// Initial KEX only checks trust afterwards.\nif let Some(certificate) = server_host_certificate {\n    if !handler.check_server_key(&certificate.into()).await? {\n        return Err(crate::Error::UnknownKey.into());\n    }\n} else if let Some(server_host_key) = server_host_key {\n    let check = handler.check_server_key(&server_host_key.into()).await?;\n    if !check {\n        return Err(crate::Error::UnknownKey.into());\n    }\n}\n```\n\nThis is in `russh/src/client/mod.rs` at lines 2036-2078 of commit `183a22e8f8f490fa09b6eb7bd044ef99d8c4414f`.\n\nThe API documentation describes `check_server_key()` as the important trust decision that prevents man-in-the-middle attacks. It describes `kex_done()` as the callback for deriving keys for secondary encrypted channels. The feature request that introduced the callback specifically lists VPN-over-SSH, UDP data planes, file transfer, and custom enterprise transports as intended uses.\n\nCryptographic verification of the KEX signature does not establish peer identity: an attacker operating its own SSH server can always produce a valid signature with its own host key. Identity is established only when `check_server_key()` accepts that key or certificate.\n\n### Expected behavior\n\nFor the initial key exchange, `check_server_key()` should accept the server identity before `kex_done()` exposes the shared secret for secondary-channel initialization.\n\n### Actual behavior\n\n`kex_done()` runs first. An untrusted server can therefore trigger application-defined secondary-channel actions even though `check_server_key()` subsequently rejects it with `UnknownKey`.\n\nThe callback was introduced by commit `500bef1eccc1c48ac674e2a262aa7887777431eb` and is present from `v0.55.0` through current `v0.65.0`.\n\n### Proof of concept\n\nThe following self-contained Cargo project starts a local russh server with a fresh, untrusted host key. The client models the documented bridge use case by exporting the shared secret in `kex_done()`, while `check_server_key()` rejects the server. It asserts both the failed connection and the callback order.\n\nCreate an empty directory and add `Cargo.toml`:\n\n```toml\n[package]\nname = \"russh-kex-before-host-trust-poc\"\nversion = \"0.1.0\"\nedition = \"2024\"\n\n[dependencies]\nrand = { version = \"0.10\", features = [\"thread_rng\"] }\nrussh = \"=0.65.0\"\ntokio = { version = \"1\", features = [\"macros\", \"net\", \"rt-multi-thread\"] }\n```\n\nCreate `src/main.rs`:\n\n```rust\nuse std::sync::{Arc, Mutex};\n\nuse russh::keys::{Algorithm, PrivateKey, PublicKeyOrCertificate};\nuse russh::{Names, client, server};\n\n#[derive(Clone)]\nstruct TestServer;\n\nimpl server::Handler for TestServer {\n    type Error = russh::Error;\n}\n\n#[derive(Clone)]\nstruct RejectingClient {\n    events: Arc<Mutex<Vec<&'static str>>>,\n    exported_secret: Arc<Mutex<Option<Vec<u8>>>>,\n}\n\nimpl client::Handler for RejectingClient {\n    type Error = russh::Error;\n\n    async fn kex_done(\n        &mut self,\n        shared_secret: Option<&[u8]>,\n        _names: &Names,\n        _session: &mut client::Session,\n    ) -> Result<(), Self::Error> {\n        self.events.lock().unwrap().push(\"kex_done\");\n\n        // Model a bridge exporting KEX material to a secondary protocol.\n        *self.exported_secret.lock().unwrap() = shared_secret.map(ToOwned::to_owned);\n        Ok(())\n    }\n\n    async fn check_server_key(\n        &mut self,\n        _server_public_key: &PublicKeyOrCertificate,\n    ) -> Result<bool, Self::Error> {\n        self.events.lock().unwrap().push(\"check_server_key\");\n        Ok(false)\n    }\n}\n\n#[tokio::main]\nasync fn main() {\n    let mut server_config = server::Config::default();\n    server_config.inactivity_timeout = None;\n    server_config\n        .keys\n        .push(PrivateKey::random(&mut rand::rng(), Algorithm::Ed25519).unwrap());\n    let server_config = Arc::new(server_config);\n\n    let listener = tokio::net::TcpListener::bind(\"127.0.0.1:0\").await.unwrap();\n    let address = listener.local_addr().unwrap();\n    tokio::spawn(async move {\n        let (stream, _) = listener.accept().await.unwrap();\n        let _ = server::run_stream(server_config, stream, TestServer).await;\n    });\n\n    let events = Arc::new(Mutex::new(Vec::new()));\n    let exported_secret = Arc::new(Mutex::new(None));\n    let client = RejectingClient {\n        events: events.clone(),\n        exported_secret: exported_secret.clone(),\n    };\n\n    let result = client::connect(\n        Arc::new(client::Config::default()),\n        address,\n        client,\n    )\n    .await;\n\n    println!(\"connection accepted: {}\", result.is_ok());\n    println!(\"callback order: {:?}\", events.lock().unwrap());\n    println!(\n        \"secret exported before rejection: {}\",\n        exported_secret.lock().unwrap().is_some()\n    );\n\n    assert!(matches!(result, Err(russh::Error::UnknownKey)));\n    assert_eq!(\n        events.lock().unwrap().as_slice(),\n        &[\"kex_done\", \"check_server_key\"]\n    );\n    assert!(exported_secret.lock().unwrap().is_some());\n}\n```\n\nRun:\n\n```sh\ncargo run --quiet\n```\n\nObserved with russh `v0.65.0`:\n\n```text\nconnection accepted: false\ncallback order: [\"kex_done\", \"check_server_key\"]\nsecret exported before rejection: true\n```\n\nThe connection fails with `russh::Error::UnknownKey`, but the security-sensitive callback and its modeled external side effect have already occurred.\n\n### Impact\n\nApplications overriding `kex_done()` to bootstrap a secondary encrypted transport are affected. An unauthenticated attacker who can impersonate the SSH endpoint can complete KEX with an attacker-owned host key and trigger secondary channel initialization before that key is rejected. Depending on the bridge, this can expose early secondary-channel data or make the application act on a session established with an untrusted peer.\n\nOrdinary clients that leave `kex_done()` at its no-op default, or implementations that independently defer all callback-derived actions until host trust has been confirmed, are not affected.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "russh"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.55.0"
      }, {
        "fixed" : "0.65.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/security/advisories/GHSA-9264-jvgf-6w2f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/pull/808"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/commit/43a46d67a80a7355fcd2fb25e7e00d79aec8184c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Eugeny/russh"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Eugeny/russh/releases/tag/v0.65.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-696", "CWE-863" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-13T19:20:16Z",
    "nvd_published_at" : null
  }
}