# GHSA-3W8Q-H8JV-VVHW: Quadratic WebSocket fragment reassembly causes CPU denial of service

- Database: GitHub
- Severity: CVSS 5.3 (Medium)
- Published: 2026-12-04
- Modified: 2026-12-04

## Tracked as

- [CVE-2026-132651](https://cve.now/CVE-2026-132651.md): httpx2 denial of service in WebSocket fragment reassembly

## Affected versions

- httpx2 (PyPI): from 2.6.0, fixed in 2.18.0

## Description

### Summary

`WebSocketSession._background_receive()` and `AsyncWebSocketSession._background_receive()` reassembled fragmented WebSocket messages by concatenating each incoming continuation frame onto a running buffer with `partial_message_buffer += event.data`. For binary messages (`bytes`), every continuation frame reallocates and copies the entire accumulated buffer, making reassembly O(N^2) in the number of frames. A remote WebSocket server, or an on-path attacker on a non-TLS (`ws://`) connection, can split messages into tiny continuation frames to consume excessive client CPU.

### Details

In `httpx2/websockets/_api.py`, `wsproto` emits one `Message` event per incoming continuation frame with `message_finished=False`. Both the synchronous and asynchronous receive loops accumulated unfinished frames with:

```python
partial_message_buffer += event.data
```

Because `bytes` is immutable in Python, reassembling a binary message of `N` bytes delivered as `k`-byte continuation frames performs O(N^2 / k) byte copies. Although `httpx2 >= 2.10.0` enforces a per-message size cap (`max_message_size_bytes`, defaulting to 65,536 bytes), that guard only checks cumulative payload size and does not bound the number of frames or the quadratic copy work performed up to the limit. Versions `2.6.0` through `2.9.1` had no per-message size cap at all.

The receive loops start automatically whenever a session is opened with `client.websocket()` or `httpx2.websocket()`.

### Impact

Availability degradation (CPU denial of service) in applications that connect to an untrusted or compromised WebSocket endpoint, or over an unencrypted `ws://` link. Reassembly holds the GIL in the synchronous client and runs without yielding to the event loop in the asynchronous client, blocking other coroutines in the process.

With the default 64 KiB `max_message_size_bytes` cap in `>= 2.10.0`, per-message quadratic overhead is bounded (tens of milliseconds per maximally fragmented message) and must be repeated across messages or connections to sustain CPU load. Applications running `2.6.0` through `2.9.1`, or configuring a larger `max_message_size_bytes`, face substantially larger single-message CPU amplification. Confidentiality and integrity are not affected.

### Mitigation

Upgrade to `httpx2` `2.18.0` or later, which accumulates continuation-frame payloads in a list (ignoring empty fragments) and joins them once when the final frame arrives, making message reassembly linear in the received bytes.

If upgrading is not immediately possible, keep `max_message_size_bytes` small and restrict WebSocket connections to trusted `wss://` endpoints.

## References

- https://github.com/pydantic/httpx2/security/advisories/GHSA-3w8q-h8jv-vvhw

Page: https://cve.now/GHSA-3W8Q-H8JV-VVHW

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
