GHSA-7mj9-2mp8-4m2p: High severity pip/httpx2 vulnerability
Summary
httpcore2 does not start TLS for wss:// connections routed through a SOCKS5 proxy. The WebSocket opening handshake and all subsequent frames are sent in plaintext through the proxy path, despite the caller selecting the secure wss scheme.
The transport flaw affects httpcore2 releases before 2.10.0. HTTPX2 exposed this behavior through its public Client.websocket() and AsyncClient.websocket() APIs from 2.6.0 through 2.9.1.
Details
The synchronous and asynchronous SOCKS5 connection implementations upgrade the established proxy tunnel to TLS only when the remote origin scheme is https. The equivalent check does not include wss. After the SOCKS5 handshake succeeds, the raw stream is therefore passed directly to the HTTP/1.1 connection, which writes the WebSocket upgrade request without first performing a TLS handshake or verifying the destination certificate.
For example, an application using HTTPX2 2.6.0 through 2.9.1 may open an authenticated WebSocket through a SOCKS proxy:
python import httpx2
with httpx2.Client(proxy="socks5://proxy.example:1080") as client: with client.websocket( "wss://service.example/private?token=query-secret", headers={"Authorization": "Bearer header-secret"}, cookies={"session": "cookie-secret"}, ) as websocket: websocket.sendtext("private message")
On affected versions, the stream passing through the SOCKS proxy begins with a plaintext request such as:
text GET /private?token=query-secret HTTP/1.1 Host: service.example Authorization: Bearer header-secret Cookie: session=cookie-secret
Before HTTPX2 2.6.0, the same underlying httpcore2 behavior could be reached by integrations constructing a WebSocket upgrade request through the low-level transport API, but HTTPX2 did not yet provide its native WebSocket client API.
A normal secure WebSocket server will usually reject these plaintext bytes because it expects a TLS ClientHello. However, a malicious or compromised SOCKS proxy can accept the SOCKS connection, observe the plaintext handshake, return a forged 101 Switching Protocols response, and then read or modify WebSocket frames in both directions. An observer between the proxy and destination may also read the plaintext traffic.
RFC 6455 requires a client using a secure WebSocket connection to perform the TLS handshake before sending the WebSocket opening handshake. A wss URI promises confidentiality, integrity, and endpoint authentication through TLS.
Impact
An attacker able to control or observe the SOCKS proxy path can obtain URL query parameters, authorization headers, cookies, and application messages that the caller expected TLS to protect. Because no TLS handshake occurs, certificate verification also does not occur, allowing an attacker controlling the proxy to impersonate the WebSocket server and inject or alter messages.
Only wss:// connections routed through a SOCKS5 proxy are affected. Direct wss:// connections and ordinary https:// requests through SOCKS already start TLS correctly.
Mitigation
Upgrade HTTPX2 and httpcore2 to 2.10.0 or later. Patched versions start TLS for both https and wss origins in the synchronous and asynchronous SOCKS5 connection paths.
If upgrading is not immediately possible, do not route wss:// connections through a SOCKS proxy. Use a direct secure WebSocket connection or another transport that performs and verifies TLS to the WebSocket origin.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/httpx2to a version that resolves this vulnerability.Fixed in 2.10.0 - Upgrade
Upgrade
pip/httpcore2to a version that resolves this vulnerability.Fixed in 2.10.0 - Upgrade
Upgrade
httpcore2to a version that resolves this vulnerability.Fixed in 2.10.0 - Upgrade
Upgrade
HTTPX2to a version that resolves this vulnerability.Fixed in 2.10.0 - Compensating control
If upgrading is not immediately possible, do not route `wss://` connections through a SOCKS proxy.
- Compensating control
Use a direct secure WebSocket connection (or another transport) that performs and verifies TLS to the WebSocket origin instead of a SOCKS proxy path.
Event History
Frequently Asked Questions
Which applications are exposed to this issue?
Applications are affected when they open wss:// WebSocket connections through a SOCKS5 proxy. HTTPX2 exposes the behavior through Client.websocket() and AsyncClient.websocket() in versions 2.6.0 through 2.9.1, and the underlying httpcore2 issue affects releases before 2.10.0.
What conditions does an attacker need to exploit this?
The supplied CVSS vector rates the attack vector as adjacent and requires neither privileges nor user interaction. Exploitation concerns the SOCKS proxy path: TLS is not initiated after the SOCKS5 tunnel is established for a wss:// destination.
What data is exposed if an affected connection is used?
The WebSocket opening handshake and all subsequent WebSocket frames are sent in plaintext through the proxy path. The destination certificate is also not verified, so authenticated handshake data, including values such as query-string tokens or headers, may be exposed.
How can I determine whether my deployment is affected?
Check whether the application uses a SOCKS5 proxy together with wss:// URLs, especially through HTTPX2 Client.websocket() or AsyncClient.websocket(). Deployments using affected HTTPX2 versions or httpcore2 versions before 2.10.0 meet the vulnerable version criteria.
What can be done before upgrading?
Avoid routing wss:// WebSocket connections through a SOCKS5 proxy until the affected dependency is updated. The issue is addressed in httpcore2 2.10.0; HTTPX2 versions 2.6.0 through 2.9.1 are identified as exposing the vulnerable behavior.