Skip to main content
Menu
Advisories

Signed/Unsigned Conversion in SocksInitRequestDecoder Leads to Auth-Scheme Bypass and Protocol Desynchronization

GHSA-C7HC-M259-XHCRPublished Updated GitHub

Description

SocksInitRequestDecoder is the legacy SOCKS5 handshake decoder in the io.netty.handler.codec.socks package (shipped in the netty-codec-socks jar). It handles the initial client greeting that declares which authentication methods the client supports (RFC 1928 §3). Any Netty application that explicitly adds new SocksInitRequestDecoder() to its channel pipeline is affected.

The defect — signed readByte() for an unsigned protocol field. At SocksInitRequestDecoder.java:49, the decoder reads the NMETHODS octet using ByteBuf.readByte(), which returns a signed Java byte in the range [-128, 127]. The SOCKS5 protocol defines this field as an unsigned octet with valid values 1–255. Wire values 0x80–0xFF (representing 128–255 offered authentication methods, all spec-legal) sign-extend to −128 through −1 in Java. The guard at line 51, if (authSchemeNum > 0), evaluates to false for all of these values, causing the decoder to take the else branch at line 57 (authSchemes = Collections.emptyList()) and emit a successful SocksInitRequest with an empty authentication-scheme list — consuming zero of the N method bytes that follow.

Affected versions

References

GitHub · netty/netty