Skip to main content
Menu
Advisories

SOCKS4/5 Proxy Encoder Null Byte and Credential Injection

GHSA-CC6X-FFM5-83WFPublished Updated GitHub

Description

Security Vulnerability Report: SOCKS4/5 Proxy Encoder Null Byte and Credential Injection in Netty

1. Vulnerability Summary

FieldValue
ProductNetty
Version4.2.12.Final (and all prior versions with codec-socks)
Componentio.netty.handler.codec.socksx.v4.Socks4ClientEncoder / io.netty.handler.codec.socksx.v5.Socks5ClientEncoder
Vulnerability TypeCWE-626: Null Byte Interaction Error / CWE-20: Improper Input Validation
ImpactDomain Spoofing / SOCKS4 UserId Truncation / Authentication Data Injection
CVSS 3.1 Score7.5 (High)
CVSS 3.1 VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

2. Affected Components

SOCKS5:

  • Socks5ClientEncoder — domain address field accepts null bytes
  • Socks5ClientEncoder — password auth request accepts null bytes and CRLF in username/password

SOCKS4:

  • Socks4ClientEncoder — userid field accepts embedded null bytes (creates ambiguous null-terminated string)
  • Socks4ClientEncoder — SOCKS4a domain field accepts embedded null bytes (domain truncation)

3. Vulnerability Description

3.1 SOCKS5 Domain Null Byte Injection

SOCKS5 domain addresses are encoded as 1-byte length + domain string. Null bytes within the domain string are accepted without validation:

Encoded: [05 01 00 03] [11] evil\0.example.com [01 BB]
                        ↑len=17         ↑null byte in domain

Different SOCKS5 proxy implementations handle embedded null bytes differently:

  • Some truncate at null → connect to evil instead of evil\0.example.com
  • Some process the full string → connect to the intended host
  • This differential behavior enables domain spoofing

3.2 SOCKS5 Auth Credential Injection

SOCKS5 password authentication (RFC 1929) uses 1-byte length + string for username and password. Null bytes and CRLF characters are accepted:

Encoded: [01] [0B] admin\0root [10] pass\r\ninjected
              ↑len  ↑null       ↑len ↑CRLF

If the SOCKS5 proxy uses null-terminated string processing, the username becomes admin (truncated), and the password may be similarly truncated or misinterpreted.

3.3 SOCKS4 UserId Null Byte Truncation

SOCKS4 uses null-terminated strings for userid. An embedded null byte creates two null bytes in the packet — the embedded one and the protocol terminator. This makes the packet structurally ambiguous:

Standard:  [header 8 bytes] [userid] [00]
Injected:  [header 8 bytes] [admin] [00] [injected-userid] [00]
                                     ↑ proxy stops here ↑ trailing data

The trailing data after the first null byte may be interpreted as:

  • Start of SOCKS4a domain (if IP is 0.0.0.x)
  • Garbage data (protocol confusion)

3.4 SOCKS4a Domain Null Byte Truncation

SOCKS4a appends a null-terminated domain after the userid. An embedded null creates the same ambiguity:

Standard:  [header] [userid\0] [domain\0]
Injected:  [header] [user\0]   [evil\0.example.com\0]
                                     ↑ proxy connects to "evil"

5. Impact Analysis

Impact CategoryDescription
Domain SpoofingNull byte truncation connects to evil instead of evil.example.com
Auth BypassNull byte in username truncates to shorter name, potentially matching a different account
Protocol ConfusionExtra null bytes in SOCKS4 packets create ambiguous protocol framing
SSRFCombined with domain spoofing, can redirect proxy connections to internal hosts

7. References

Affected versions

References

GitHub · netty/netty