Two verified findings, attacker = malicious (or compromised/MITM'd) server the jsch client talks to. PoC (evil SFTP server + evil HTTP proxy): https://gist.github.com/afldl/e8ff53bdfaa4b783dbe4085b7ff0ec31 . Analysis LLM-assisted, human-verified with real TCP sockets driving the unmodified library. Both sites unchanged on current master (checked 2026-08-24).
1. SFTP: SSH_FXP_DATA declared length is trusted for allocation - ChannelSftp.java:1436
A malicious SFTP server (full SSH2 handshake: curve25519-sha256 + ssh-ed25519 + aes128-ctr) replies to SSH_FXP_READ with a SSH_FXP_DATA whose 4-byte length prefix declares 0x7FFFFFFF while only 17 bytes follow. The InputStream path does rest_byte = new byte[foo] with foo = 0x7FFFFFFF - 17: java -Xmx128m dies with OutOfMemoryError: Java heap space at ChannelSftp$2.read (ChannelSftp.java:1436) (exit 42; server log confirms declared=2147483647, actual=17). An honest declared == actual == 17 reply reads through normally. Every application using sftp.get()/the InputStream API against an untrusted server is affected.
2. ProxyHTTP: response status line accumulates without bound - ProxyHTTP.java:106
A malicious HTTP proxy accepts the CONNECT, then streams non-CR bytes forever; sb.append((char) foo) builds the status line without any length cap: java -Xmx128m dies with OutOfMemoryError at ProxyHTTP.connect (ProxyHTTP.java:106) after consuming ~37 MB. An honest HTTP/1.0 200 + SSH banner connects normally.
Suggested fixes: (1) validate the FXP_DATA length against the remaining packet bytes before allocating (and/or cap at a sane buffer size, falling back to chunked reads); (2) cap the status-line StringBuilder (status lines are bounded by RFC 9110's recommended 8 KB; reply 502/close beyond).
Reproducers (evil servers, Java harnesses, logs) in the gist.
(Note: originally found in com.jcraft/jsch, which appears unmaintained - reporting here since this fork is the actively maintained continuation.)
Two verified findings, attacker = malicious (or compromised/MITM'd) server the jsch client talks to. PoC (evil SFTP server + evil HTTP proxy): https://gist.github.com/afldl/e8ff53bdfaa4b783dbe4085b7ff0ec31 . Analysis LLM-assisted, human-verified with real TCP sockets driving the unmodified library. Both sites unchanged on current master (checked 2026-08-24).
1. SFTP:
SSH_FXP_DATAdeclared length is trusted for allocation -ChannelSftp.java:1436A malicious SFTP server (full SSH2 handshake: curve25519-sha256 + ssh-ed25519 + aes128-ctr) replies to
SSH_FXP_READwith aSSH_FXP_DATAwhose 4-byte length prefix declares0x7FFFFFFFwhile only 17 bytes follow. The InputStream path doesrest_byte = new byte[foo]withfoo = 0x7FFFFFFF - 17:java -Xmx128mdies withOutOfMemoryError: Java heap spaceatChannelSftp$2.read (ChannelSftp.java:1436)(exit 42; server log confirms declared=2147483647, actual=17). An honestdeclared == actual == 17reply reads through normally. Every application usingsftp.get()/the InputStream API against an untrusted server is affected.2. ProxyHTTP: response status line accumulates without bound -
ProxyHTTP.java:106A malicious HTTP proxy accepts the
CONNECT, then streams non-CR bytes forever;sb.append((char) foo)builds the status line without any length cap:java -Xmx128mdies withOutOfMemoryErroratProxyHTTP.connect (ProxyHTTP.java:106)after consuming ~37 MB. An honestHTTP/1.0 200+ SSH banner connects normally.Suggested fixes: (1) validate the FXP_DATA length against the remaining packet bytes before allocating (and/or cap at a sane buffer size, falling back to chunked reads); (2) cap the status-line StringBuilder (status lines are bounded by RFC 9110's recommended 8 KB; reply 502/close beyond).
Reproducers (evil servers, Java harnesses, logs) in the gist.
(Note: originally found in
com.jcraft/jsch, which appears unmaintained - reporting here since this fork is the actively maintained continuation.)