Summary
HTTPX2 can fail to establish TLS for secure WebSocket connections routed through a SOCKS5 proxy because the underlying httpcore2 logic recognizes only HTTPS during the TLS upgrade decision. When affected clients connect through such a proxy, sensitive WebSocket handshake data and later frames may travel without encryption or certificate verification, allowing an attacker who can observe or control the proxy path to read, alter, or impersonate traffic.
Affected context
The issue occurs in HTTPX2 WebSocket clients that use a SOCKS5 proxy while connecting to a secure WebSocket origin identified by the wss scheme. It affects deployments using the vulnerable httpcore2 SOCKS proxy handling, where TLS is not initiated before the WebSocket handshake. Requests may expose query parameters, authorization headers, cookies, and subsequent frames on the proxy path.
Exploit preconditions
- Attack surface: WebSocket connections routed through a SOCKS5 proxy
- Required access: Ability to observe or influence traffic on the proxy or network path
- Trigger point: Opening a
wssconnection through the affected synchronous or asynchronous client path - Why exploitation is possible: The TLS upgrade condition recognizes
httpsbut notwss, so encrypted transport may not be established and certificate verification may be absent
Why this happens
The underlying bug is an incomplete scheme check in the SOCKS proxy connection logic. The implementation treats HTTPS as the signal for a TLS upgrade but does not apply equivalent handling to secure WebSocket origins using the wss scheme. This causes application data intended for encrypted transport to be sent over a cleartext proxy connection, mapping to CWE-319, Cleartext Transmission of Sensitive Information.
Potential impact
- An attacker may read WebSocket handshakes, headers, cookies, query parameters, and frames
- An attacker could modify messages or inject data into an active connection
- An attacker may impersonate the intended WebSocket server
- Credentials, session tokens, or application data could be exposed
- WebSocket-based workflows could be disrupted or manipulated
General mitigation guidance
Mitigation generally focuses on ensuring that secure WebSocket schemes always trigger TLS establishment and certificate verification before application data is exchanged. Secure-by-default client behavior should reject a connection when the requested confidentiality properties cannot be provided. Organizations can reduce input and transport trust by validating URL schemes, proxy behavior, and negotiated security state rather than relying solely on proxy configuration. TLS verification should remain enabled, sensitive connections should use trusted proxy paths, and client processes should run with only the network and credential privileges they require.
How teams detect issues like this
Static analysis and code review can look for scheme-condition branches that handle https but omit wss, as well as proxy connection paths that send protocol handshakes before TLS negotiation. Integration tests should exercise secure WebSocket connections through each supported proxy type and verify certificate validation and encrypted transport. Network monitoring and policy enforcement can flag WebSocket credentials or handshake data appearing in cleartext on proxy interfaces. Automated security review tools may help identify incomplete transport-security checks.

