
Cloud Vulnerability DB
A community-led vulnerabilities database
The yamux stream multiplexer in py-libp2p does not enforce per-stream receive-window limits on incoming DATA frames. An authenticated peer can send multiple DATA frames that individually pass the per-frame size guard but collectively exceed the stream's receive window, causing unbounded memory growth in the stream buffer. The receive window violation is logged as a warning and clamped to zero instead of being treated as a protocol error.
When yamux receives a DATA frame, the handle_incoming() method reads the frame body and appends it to stream_buffers[stream_id] unconditionally. It then deducts the frame length from the stream's recv_window. If recv_window becomes negative (indicating the sender exceeded the flow-control window), the code logs a warning and clamps recv_window to zero. It does not send a GO_AWAY or RST frame, does not reject the data, and does not close the connection. The go-yamux reference implementation treats the same condition as a protocol error (ErrRecvWindowExceeded) and terminates the session.
Affected method: Yamux.handle_incoming() at libp2p/stream_muxer/yamux/yamux.py:1542-1551
- stream_buffers[stream_id].extend(data): appends without aggregate limit
- recv_window -= len(data): goes negative for flow-control violations
- if recv_window < 0: clamps to 0 with WARNING only; no connection termination
Per-frame guard (from CVE-2026-73568 fix) at yamux.py:1265:
- if typ == TYPE_DATA and length > MAX_WINDOW_SIZE: rejects frames > 16 MB
- Uses strict >, so 16 MB frames pass (16 MB is not > 16 MB)
- Does not guard aggregate per-stream buffer growthAn authenticated peer (any participant with a valid key pair that completes the Noise/TLS handshake) can cause memory exhaustion on the target node. The attacker opens yamux streams and sends multiple 16 MB DATA frames per stream. Each frame passes the per-frame size guard, but the aggregate buffer grows without limit. Inbound stream creation has no semaphore limit (the stream backlog semaphore applies only to outbound streams). With 100 streams receiving 10 frames each, the node accumulates 16 GB of buffered data. This plausibly causes an OOM condition and process termination, affecting all connections.
Dependencies: Python 3.10+ with stdlib only (struct)
This PoC constructs raw yamux frames to illustrate the protocol-level attack.
In a real attack, frames are sent over an encrypted connection post-handshake.import struct
YAMUX_HEADER_FORMAT = "!BBHII"
TYPE_DATA = 0x0
TYPE_WINDOW_UPDATE = 0x1
FLAG_SYN = 0x1
DEFAULT_WINDOW_SIZE = 256 * 1024 # 256 KB
MAX_WINDOW_SIZE = 16 * 1024 * 1024 # 16 MB
def make_yamux_header(typ, flags, stream_id, length):
return struct.pack(YAMUX_HEADER_FORMAT, 0, typ, flags, stream_id, length)
stream_id = 1
# Step 1: SYN to open stream
syn = make_yamux_header(TYPE_WINDOW_UPDATE, FLAG_SYN, stream_id, 0)
print(f"SYN: {syn.hex()} (opens stream, recv_window={DEFAULT_WINDOW_SIZE})")
# Step 2: DATA at MAX_WINDOW_SIZE (passes per-frame guard)
data_hdr = make_yamux_header(TYPE_DATA, 0, stream_id, MAX_WINDOW_SIZE)
print(f"DATA: {data_hdr.hex()} (16 MB, passes guard: 16 MB is not > 16 MB)")
print(f" recv_window: {DEFAULT_WINDOW_SIZE} - {MAX_WINDOW_SIZE} = "
f"{DEFAULT_WINDOW_SIZE - MAX_WINDOW_SIZE} -> clamped to 0")
# Step 3: Second DATA (still accepted)
print(f"DATA: (same header, recv_window: 0 - {MAX_WINDOW_SIZE} -> clamped to 0)")
print(f" buffer = {MAX_WINDOW_SIZE * 2:,} bytes (32 MB), connection still open")
# Extrapolation
print(f"\n100 streams x 10 frames x 16 MB = "
f"{100 * 10 * MAX_WINDOW_SIZE / (1024**3):.1f} GB total")SYN: 000100010000000000000000 (opens stream, recv_window=262144)
DATA: 000000010000000001000000 (16 MB, passes guard)
recv_window: 262144 - 16777216 = -16515072 -> clamped to 0
DATA: (same header, recv_window: 0 - 16777216 -> clamped to 0)
buffer = 33,554,432 bytes (32 MB), connection still open
100 streams x 10 frames x 16 MB = 15.6 GB totallength field (up to MAX_WINDOW_SIZE = 16 MB) and the frame payload. The attacker also controls how many frames and streams are opened.length = MAX_WINDOW_SIZE. Each frame passes the per-frame guard at yamux.py:1265 (16 MB is not > 16 MB). _read_data_body() at yamux.py:1509 reads the frame body, and stream_buffers[stream_id].extend(data) at yamux.py:1542 appends it.length > MAX_WINDOW_SIZE but allows frames at exactly 16 MB. The per-stream recv_window check at yamux.py:1543-1551 detects the violation (recv_window goes negative) but only logs a warning and clamps the value to zero. No GO_AWAY, RST, or connection termination occurs. The inbound stream creation path has no semaphore or count limit (stream_backlog_semaphore at yamux.py:668 is outbound-only, acquired in open_stream() at yamux.py:880).stream_buffers, with no aggregate limit across frames or streams.The CVE-2026-73568 fix at yamux.py:1265 guards against individual oversized frames (length > MAX_WINDOW_SIZE) but does not address aggregate per-stream buffer growth. A 16 MB frame passes the guard because the comparison is strict greater-than. The receive-window deduction at yamux.py:1543-1551 detects the flow-control violation but treats it as a soft warning rather than a protocol error. In go-yamux, stream.go:readData() returns ErrRecvWindowExceeded when a frame exceeds recvWindow, causing session termination via goAway(goAwayProtoErr). py-libp2p's clamp-to-zero behavior is the specific deviation that enables this attack.
piplibp2p>= 0.3.0, <= 0.8.00.8.0 (PyPI)stream_buffers[stream_id].extend(data) has zero flow-control enforcement. In 0.7.0, recv_window tracking was added with the clamp-to-zero behavior. In 0.8.0, the per-frame MAX_WINDOW_SIZE guard was added (CVE-2026-73568 fix), but the per-stream aggregate buffer growth remains unbounded. Versions 0.1.x through 0.2.x used only mplex and do not include yamux.recv_window to become negative, treat it as a protocol error, send a GO_AWAY frame, and terminate the connection. This matches the go-yamux behavior (ErrRecvWindowExceeded). Additionally, consider adding an inbound stream count limit (analogous to the outbound stream_backlog_semaphore) to bound the number of concurrent attacker-controlled streams.Reported by zx (GitHub: @manus-pi).
Source: NVD
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."