Read the docs

Heap buffer overflow in FreeRDP routing token handling

Priority LOW 38Published · Updated

Key facts

Attack vector
—
Privileges required
—
User interaction
—
Attack complexity
—
Impact type
—
Confidentiality · integrity · availability
—
Fix status
Fixed

No CVSS vector from any source. Fix status from GitHub.

Summary

FreeRDP through 3.30.0 is affected. A malicious RDP server or man-in-the-middle can send a Server Redirection PDU with an oversized LB_LOAD_BALANCE_INFO routing token, which nego_send_negotiation_request copies into a fixed 512-byte heap buffer. The overflow occurs during connection negotiation, before any security handshake completes, so an unauthenticated remote attacker can trigger it. Builds with assertions enabled abort, and other builds can have memory corrupted.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

Description from the GitHub advisory

# Heap buffer overflow in nego_send_negotiation_request via oversized LB_LOAD_BALANCE_INFO routing token **Reported by:** Feng Xue and XGPT of ThreatBook ## Affected versions - master @ 20f98bd90a93a11e302975ccdedd4c203f4a644a - stable-3.0 (verified present at tag 3.9.0; line numbers below are master) ## Summary A malicious RDP server (or MITM) can drive a connecting FreeRDP client into a heap buffer overflow with attacker-controlled content and length during connection negotiation, before any security protocol handshake completes. `nego_send_negotiation_request` allocates a fixed 512-byte stream (`libfreerdp/core/nego.c:1119`) and writes the routing token into it with `Stream_Write` (`nego.c:1134`). The only length gate in the function (`if (length > UINT16_MAX) goto fail;`, `nego.c:1190`) runs **after** the write and only rejects tokens larger than 64 KB. The token is taken verbatim from the `LB_LOAD_BALANCE_INFO` field of a Server Redirection PDU. Unlike the sibling fields of the same PDU (`TargetNetAddress` capped at 80, `Username` at 512, `Domain` at 52, `redirection.c:694-704`), `LB_LOAD_BALANCE_INFO` is read with no upper bound (`redirection.c:714-725`), copied into settings without truncation (`redirection.c:604-609`), and re-transmitted on redirect by `nego_set_routing_token` (`nego.c:1964-1977`). Trigger: server sends a Server Redirection PDU whose `LB_LOAD_BALANCE_INFO` is >= 492 bytes (with `LB_TARGET_NET_ADDRESS` left empty so the client reconnects to the attacker). On the second connection the token overflows the 512-byte stream. The Server Redirection PDU is not signed and is accepted by multiple dispatch paths regardless of connection state (`rdp.c:1779-1780`, `1728-1738`, `1461-1462`). ## Impact - Assert-disabled builds (Debian/Ubuntu packaging sets `-DWITH_VERBOSE_WINPR_ASSERT=OFF` + `-DNDEBUG`): the `WINPR_ASSERT` inside `Stream_Write` (stream.h:1192) is compiled out; the memcpy performs a real heap overflow of attacker-controlled content. Reproduced with ASan: `heap-buffer-overflow WRITE of size 1000 into a 512-byte region` (0 bytes after the region), symbolized stack `__asan_memcpy <- Stream_Write (stream.h:1193) <- nego_send_negotiation_request (nego.c:726) <- rdp_client_connect (connection.c:458) <- rdp_client_redirect (connection.c:715) <- rdp_check_fds (rdp.c:2310)`; allocation stack `Stream_New (nego.c:1119)`. Plain Release build aborts in glibc (`free(): invalid next size (normal)`). - Assert-enabled builds (upstream CMake default `WITH_VERBOSE_WINPR_ASSERT=ON`): the assert fires before the memcpy -> unauthenticated remote abort (client DoS). - Reachable with the client's default security settings (verified with default NLA enabled): the routing token is written into the X.224 Connection Request before any security handshake. - Boundary behavior measured: tokens of 492-501 bytes overflow by 1+ bytes (trailing CRLF / 8-byte RDP_NEG_DATA appended after the token body); tokens >= 502 overflow by the full amount; tokens <= 491 send cleanly (control: no crash). RCE assessment: the overflow provides a write primitive (controlled content and length), but the overflow condition is mutually exclusive with successful transmission (token length >= 492 <=> stream size > 512), so it is a one-shot corruption, and we found no leak primitive. We rate this high severity (pre-auth remote heap corruption / client crash), not critical. ## Reproduction ```bash # 1. Malicious server (Python 3, stdlib only), generates TLS with bundled # self-signed cert.pem/key.pem, listens on 127.0.0.1:3391 TOKEN_LEN=1000 python3 malicious_rdp_server.py # 2. ASan-instrumented xfreerdp (build with -DNDEBUG -fsanitize=address) xfreerdp /v:127.0.0.1 /port:3391 /cert:ignore /u:test /p:test # Control (no crash): TOKEN_LEN=50 ``` Expected: with `TOKEN_LEN=1000` the client aborts — assert build: `winpr_int_assert (Stream_GetRemainingCapacity(_s) >= _n) stream.h:1192`; NDEBUG+ASan build: `heap-buffer-overflow WRITE of size 1000 into 512-byte region`. With `TOKEN_LEN=50` the client reconnects cleanly (the server sees the second X.224 CR). Files: `malicious_rdp_server.py`, `cert.pem`, `key.pem` (trigger-only; no exploit code). ## Suggested fix 1. Validate `RoutingTokenLength` before the write in `nego_send_negotiation_request`, or allocate the stream from the actual token length. 2. Add an upper bound for `LB_LOAD_BALANCE_INFO` in `redirection.c` (consistent with the caps on the sibling fields of the same PDU). [poc.zip](https://github.com/user-attachments/files/31204461/poc.zip)

Why it matters now

Fix Fixed FreeRDP: 3.31.0

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP<= 3.30.03.31.0Patch availableGHSA-r9pv-ffph-6gg6
  • FreeRDP Vendor— Affected <= 3.30.0 Fixed in 3.31.0 Patch available GHSA-r9pv-ffph-6gg6

Remediation

Upgrade FreeRDP to version 3.31.0 or later.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

  • Fix · GHSA-r9pv-ffph-6gg6 FreeRDP Fixed in 3.31.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-r9pv-ffph-6gg6

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences