Vulnerability DatabaseGHSA-xx4q-fj82-qjp5

GHSA-xx4q-fj82-qjp5: 
Python vulnerability analysis and mitigation

Summary

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.

Root Cause

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 growth

Impact

An 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.

Proof of Concept

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 total

Attack Chain

  1. Exposure: The attacker completes a standard libp2p connection (TCP + Noise/TLS + yamux negotiation). Any peer with a valid ed25519 key pair can authenticate; no authorization beyond identity is required.
  2. Control: The attacker controls the yamux DATA frame length field (up to MAX_WINDOW_SIZE = 16 MB) and the frame payload. The attacker also controls how many frames and streams are opened.
  3. Path: The attacker sends a SYN frame (TYPE_WINDOW_UPDATE + FLAG_SYN) to open a new inbound stream. The SYN handler at yamux.py:1275-1294 creates the stream unconditionally (no inbound semaphore). The attacker then sends DATA frames with 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.
  4. Guard: The per-frame size guard (CVE-2026-73568 fix) at yamux.py:1265 rejects frames with 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).
  5. Primitive: The attacker accumulates 16 MB per DATA frame in stream_buffers, with no aggregate limit across frames or streams.
  6. Result: With 100 inbound streams each receiving 10 frames of 16 MB, the node accumulates approximately 16 GB of buffered data, plausibly causing an OOM condition and denial of service to all peers.

Bypass Evidence

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.

Affected Versions

  • Ecosystem: pip
  • Package: libp2p
  • Confirmed affected range: >= 0.3.0, <= 0.8.0
  • Latest release checked: 0.8.0 (PyPI)
  • Fix status: not fixed Yamux was first shipped in version 0.3.0. In 0.3.0, 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.

Suggested Fix

Enforce the receive-window invariant on the receive side: when an incoming DATA frame would cause 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

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-3r6w-7pcg-c4x2HIGH7.5
  • Python logoPython
  • ag2
NoYesNov 22, 2026
GHSA-xx4q-fj82-qjp5MEDIUM6.5
  • Python logoPython
  • libp2p
NoNoNov 22, 2026
GHSA-224h-jmfq-qc67MEDIUM5.9
  • Python logoPython
  • ag2
NoYesNov 22, 2026
GHSA-8r36-g3rm-mf85MEDIUMN/A
  • Python logoPython
  • pymaxim
NoYesNov 22, 2026
GHSA-7xgg-5cm6-g46fMEDIUMN/A
  • Python logoPython
  • pymaxim
NoYesNov 22, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management