Russh has shipped a function called read_ssh_id since the file was first added to the project. The Rust SSH client called it to read the server's identification string. The Rust SSH server called it to read the client's identification string. RFC 4253 §4.2 grants one of those directions permission to send pre-banner lines, and grants the other none. The function modeled the union: pre-banner lines accepted from either side, with no count, with no line-length cap shorter than the buffer, until the inactivity timeout fired. CVE-2026-48108 is what a russh server reading from a client gets when the function reading the input was written for a client reading from a server.
CVE-2026-48108: Russh's Server Called The Client's Banner Parser
vendor
pattern
cve
proof of concept
RFC 4253 §4.2 has a side
The SSH transport protocol specifies the version exchange in one short paragraph. Two sentences from it carry every constraint that matters for CVE-2026-48108:
The server MAY send other lines of data before sending the version string. ... The maximum length of the string is 255 characters, including the Carriage Return and Line Feed.
The permission is a server permission. The cap is a hard length cap on the identification line itself. OpenSSH's sshd enforces both: it rejects pre-banner traffic from clients, and it rejects banners longer than the spec allows. Russh, prior to v0.61.0, enforced neither.
The function with no direction in its name
Pre-patch, russh/src/ssh_read.rs exposes one method for reading the banner phase. Both the client and server crates use it:
pub async fn read_ssh_id(&mut self) -> Result<&[u8], Error> {
let ssh_id = self.id.as_mut().unwrap();
loop {
let mut i = 0;
let n = AsyncReadExt::read(&mut self.r, &mut ssh_id.buf[ssh_id.total..]).await?;
ssh_id.total += n;
if n == 0 {
return Err(Error::Disconnect);
}
// ... scan ssh_id.buf[..ssh_id.total] for CRLF, set bytes_read = i + 2 ...
if ssh_id.bytes_read > 0 {
if i >= 8 {
if let Ok(s) = std::str::from_utf8(&ssh_id.buf[..i]) {
if s.starts_with("SSH-1.99-") || s.starts_with("SSH-2.0-") {
ssh_id.sshid_len = i;
return Ok(ssh_id.id());
}
}
}
// Else, it is a "preliminary" (see RFC 4253 §4.2),
// and we can discard it and read the next one.
ssh_id.total = 0;
ssh_id.bytes_read = 0;
}
}
}russh/src/client/mod.rs calls it as stream.read_ssh_id() to read the server's banner. russh/src/server/mod.rs calls it as read.read_ssh_id() to read the client's banner. The function takes no direction parameter; the call sites pass none. The 256-byte buffer is the only constant the function defines for itself. The comment that references RFC 4253 §4.2 is the only mention of the spec in the function body. The comment reads as if the function knows it is implementing a permission. The function does not know whose.
The patch is one boolean and one call site
The fix in ssh_read.rs keeps the original function and wraps it in two:
pub async fn read_ssh_id(&mut self) -> Result<&[u8], Error> {
self.read_ssh_id_inner(true).await
}
pub async fn read_client_ssh_id(&mut self) -> Result<&[u8], Error> {
self.read_ssh_id_inner(false).await
}
async fn read_ssh_id_inner(&mut self, allow_pre_banner_lines: bool) -> Result<&[u8], Error> {
let ssh_id = self.id.as_mut().ok_or(Error::Inconsistent)?;
// ... loop, parse a line ...
if !allow_pre_banner_lines {
return Err(Error::Version);
}
ssh_id.pre_banner_lines += 1;
if ssh_id.pre_banner_lines > SSH_ID_MAX_PRE_BANNER_LINES {
return Err(Error::Version);
}
// ...
}In server/mod.rs, one call site moves:
let sshid = if let Some(t) = config.inactivity_timeout {
- tokio::time::timeout(t, read.read_ssh_id()).await??
+ tokio::time::timeout(t, read.read_client_ssh_id()).await??
} else {
- read.read_ssh_id().await?
+ read.read_client_ssh_id().await?
};The client's call site in client/mod.rs is untouched. The patch deletes no function. It adds one wrapper, one boolean, two constants (SSH_ID_MAX_LINE_LEN = 255 and SSH_ID_MAX_PRE_BANNER_LINES = 20), and updates exactly one call site. The qualifier on the function name is the fix.
The bound that wasn't there: pre-banner line count
The pre-patch path discards a non-SSH-2.0- line by resetting the buffer:
ssh_id.total = 0;
ssh_id.bytes_read = 0;No counter. No cap. The outer loop continues. The only termination conditions inside the function are (a) a line starting with SSH-2.0- arrives, or (b) the underlying read() returns zero, meaning the peer hung up. Neither fires when the attacker streams CRLF-terminated garbage indefinitely.
The outer caller in server/mod.rs wraps the function in tokio::time::timeout(config.inactivity_timeout, ...). The timeout is the only termination condition the attacker doesn't control. It is configurable; the default Config does not set it. A russh server compiled with default settings reads pre-banner garbage from a client until the operator notices.
The DoS primitive is direct. Open a TCP connection. Write garbage\r\n. Keep writing it. Never send SSH-2.0-. The connection holds a tokio task, a TCP socket, and a 256-byte buffer for as long as the attacker can keep typing. Scale to thousands of attacker connections and the russh server's slots are full of preliminaries that will never become handshakes. The patched cap of 20 preliminary lines puts a ceiling on the per-connection cost; the pre-patch cap was whatever the operator remembered to configure on inactivity_timeout.
The bound that wasn't there: line length
RFC 4253 §4.2's other constraint caps the identification string at 255 characters including CRLF. Pre-patch, russh's buffer is 256 bytes. A 254-character banner plus CRLF fits exactly. A longer banner does not fit; the underlying read() writes into buf[total..], where total == 256, an empty slice. AsyncReadExt::read returns Ok(0) into that empty slice, and the function returns Error::Disconnect.
The pre-patch test confirms the contract:
let data = ":".repeat(SSH_ID_BUF_SIZE + 1);
let mut read = SshRead::new(data.as_bytes());
let received = read.read_ssh_id().await;
assert!(matches!(received.err(), Some(Error::Disconnect)));That test passed. It was the author's locked-in contract for what happens when a peer sends a too-long banner. Disconnect is the error russh returns when read() signals end-of-stream, the canonical "peer hung up" condition. Logs and metrics that classify Disconnect as a transport-level event swallowed every attempt to send an oversized banner. The malformed input and a half-open socket produced the same error.
The patch flips the assertion:
- assert!(matches!(received.err(), Some(Error::Disconnect)));
+ assert!(matches!(received.err(), Some(Error::Version)));Error::Version is russh's specific error for the version exchange. The patch installs the new taxonomy and the test that locks it in within the same commit. The pre-patch test was the codified statement that an oversized banner is a transport problem. The post-patch test is the codified statement that an oversized banner is a protocol problem. Same input, two different categories. The category had been wrong since the test was written.
One parser, two roles, a direction-blind parser
The structural reason is simple. SSH's version exchange is asymmetric:
- The server MAY emit any number of preliminary lines before the canonical
SSH-2.0-string. - The client MUST emit only the canonical line.
A reader that handles both directions must implement both grammars and pick which one applies at each call site. A reader that implements one grammar has chosen which direction it serves. Russh's read_ssh_id implemented the looser grammar, the one written for clients reading servers, and the server inherited that grammar for free. This is the shape we call a Direction Blind Parser: one function reading bytes on behalf of two protocol roles that the spec does not treat as one.
The shape is not russh-specific. SMTP servers emit multi-line greetings; SMTP clients do not. DNS responder records carry a wider grammar than the queries that elicit them. HTTP/1.1 response headers allowed obs-fold long after request headers were narrowed against it, and several CVEs came out of clients that read the wider grammar on the request side. Whenever a protocol gives two roles different permissions and an implementation writes one parser for both, the parser implements the union of the two roles' permissions. The role that should have been stricter ships unbounded. Russh's banner phase is the version of that pattern where the spec asymmetry is two sentences long and the implementation is one function.
What the missing noun was
The function is named read_ssh_id. There are two SSH identification strings in an SSH handshake. The function did not say which one it read. The patch added the qualifier client_ to one of the two new wrappers and pointed the server at it. The qualifier had been missing since the file was created in the russh tree in 2022, and the same code path existed in the thrussh fork russh was carved from before that. RFC 4253 §4.2's permission is the only deliberate asymmetry between the SSH server and the SSH client at handshake time. CVE-2026-48108 is what shipped while it was implemented as if it were not: one function reading banners, called from both ends of an asymmetric handshake.
Patch: Eugeny/russh@22295fa
Advisory: GHSA-76r6-x97p-67vr
The handshake had been ambidextrous for four years.