Read the docs

Out-of-bounds write in FreeRDP static virtual channel handling

Priority MEDIUM 48CWE-191Published · Updated

Key facts

Attack vector
Network
Privileges required
Low
User interaction
None
Attack complexity
High
Impact type
Code execution
Confidentiality · integrity · availability
High · High · High
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-9jcm-x588-gh26. Fix status from GitHub. Impact type from CWE-191 and the CVSS impact.

Summary

FreeRDP versions 3.28.0 through 3.30.0 are affected. A static virtual-channel message larger than the fixed buffer of ChannelPduTracker leaves the tracker's offset unchanged, which causes an integer underflow when the next poll computes the remaining size. A remote attacker with low privileges and no user interaction can then write attacker-controlled bytes past the tracker buffer into the same heap allocation (CWE-787). The overwrite occurs only in builds with WinPR assertions disabled and NDEBUG defined.

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

Description from the GitHub advisory

# FreeRDP #13102 security impact: SHOW_PROTOCOL live-pointer overwrite Discovery credit: Bynario Atlas CVSS v3.1 (standalone root cause): `CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H` (7.5, High) CWE(s): `CWE-787` (Out-of-bounds Write), `CWE-191` (Integer Underflow) ## Summary > Disclosure note: This finding was identified and validated by Bynario Atlas, an AI automated pipeline. The technical claims and supporting evidence were manually reviewed before submission. The reachable trigger was fixed on master by commit `40d9202cd95551600c07437ce6bd5ecd7d31e57b` while addressing public functional issue #13102. No released tag contains that fix, and #13102 does not describe the memory-safety consequence. This report documents that consequence so the project can assess a security advisory for affected releases; it is not asserting that the validated trigger remains reachable on current master. FreeRDP 3.28.0 through 3.30.0 can queue a static virtual-channel message larger than `ChannelPduTracker`'s fixed buffer. The tracker's oversized-message error preserves its offset. A following zero-capacity read reports bytes without consuming them, and the tracker incorrectly adds that reported count. The next poll underflows the remaining-size calculation and copies attacker-controlled bytes beyond the tracker buffer into later fields of the same heap allocation. On assertion-enabled builds, the same input aborts the process. On builds where WinPR assertions are disabled and `NDEBUG` is defined, the assertions compile out and the write proceeds. That configuration was used by the validation build; exposure of any distribution package must be confirmed from its exact build flags or binary. ## Affected versions and preconditions - Source-confirmed in FreeRDP 3.28.0, 3.29.0, and 3.30.0; runtime-tested on FreeRDP 3.30.0. - Introduced by server-side `CHANNEL_OPTION_SHOW_PROTOCOL` tracking in commit `2e1113794d125269f30fc7acf4d0f3d898d74d52`. - Fixed on unreleased master by commit `40d9202cd95551600c07437ce6bd5ecd7d31e57b`, which caps and splits queued channel payloads. - That commit is attached to public functional issue #13102; the issue does not describe the memory-corruption or security consequence reported here. - No released tag contains the fix as of 2026-08-22. - The out-of-bounds write requires `channel_pdu_tracker.c` to be built with `NDEBUG` and without `WITH_VERBOSE_WINPR_ASSERT`. Other builds reach a remote assertion abort instead. - `WITH_VERBOSE_WINPR_ASSERT` defaults to `ON`. However, FreeRDP's `docs/README.building` recommends `OFF` for stable builds and gives this release-build example: ```text cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DWITH_VERBOSE_WINPR_ASSERT=OFF ... ``` `Release` supplies `NDEBUG`, so FreeRDP's documented stable-build recipe is an assertion-disabled configuration that reaches the overwrite. - Distribution exposure is not inferred from package name or build type; confirm the exact translation-unit flags or inspect the installed binary. ## Technical Analysis ### Background `ChannelPduTracker` assembles static virtual-channel packets in a fixed buffer. The relevant sizes come from `winpr/include/winpr/wtsapi.h` (the non-Windows branch; on Windows they come from the platform SDK's `pchannel.h`): ```text CHANNEL_CHUNK_LENGTH = 1600 (wtsapi.h:51) sizeof(CHANNEL_PDU_HEADER) = 8 (two UINT32 fields) (wtsapi.h:87-88) CHANNEL_PDU_LENGTH = 1608 (CHANNEL_CHUNK_LENGTH + sizeof(CHANNEL_PDU_HEADER), and therefore of type size_t) (wtsapi.h:53) ``` The tracker's private structure, `libfreerdp/utils/channel_pdu_tracker.c:27-34`, is: ```c struct ChannelPduTracker { HANDLE vc; wStream* currentPacket; char buffer[CHANNEL_PDU_LENGTH]; size_t offset; wLog* log; }; ``` On an LP64 target `buffer` begins at struct offset 16 and ends at 1624, which is already 8-aligned, so no padding precedes `offset`. Therefore `&buffer[1608]` is `&tracker->offset` and `&buffer[1616]` is `&tracker->log`. That is why the overwrite below lands on the `log` pointer. Before the master fix, `WTSProcessChannelData()` handled a channel with `CHANNEL_OPTION_SHOW_PROTOCOL` by prepending an eight-byte header and queuing the entire received SVC chunk without enforcing the 1600-byte payload limit. ### Vulnerability The tracker calculates the next read size from its logical offset, in `ChannelPduTracker_poll()`: ```c WINPR_ASSERT(tracker->offset <= CHANNEL_PDU_LENGTH); const ULONG readSz = WINPR_ASSERTING_INT_CAST(ULONG, CHANNEL_PDU_LENGTH - tracker->offset); if (!WTSVirtualChannelRead(tracker->vc, INFINITE, &tracker->buffer[tracker->offset], readSz, &sz)) return nullptr; tracker->offset += sz; WINPR_ASSERT(tracker->offset <= CHANNEL_PDU_LENGTH); ``` With `NDEBUG` and `WITH_VERBOSE_WINPR_ASSERT=OFF`, `WINPR_ASSERT` compiles out (`winpr/include/winpr/assert-api.h:29-39`) and `WINPR_ASSERTING_INT_CAST` degrades to a plain cast (`winpr/include/winpr/cast.h:111-122`), so every checking construct in that fragment disappears and only the arithmetic remains. `FreeRDP_WTSVirtualChannelRead()` has special size-query behavior: when `BufferSize == 0`, it reports all remaining bytes through `pBytesRead` but copies and consumes nothing. `ChannelPduTracker_poll()` does not distinguish that report from a completed read. For one 1608-byte SVC payload, the queued message is 1616 bytes including the channel header: ```text poll 1: request 1608, copy 1608, tracker offset = 1608 header.length is oversized; return without resetting tracker poll 2: request 0, WTS reports 8, copies 0, consumes 0 tracker incorrectly advances offset to 1616 poll 3: CHANNEL_PDU_LENGTH - offset is 1608 - 1616, which wraps in size_t to SIZE_MAX - 7, then truncates through the ULONG (uint32_t, winpr/wtypes.h) cast to a readSz of 0xFFFFFFF8 WTS has 8 bytes still queued, which is under that buffer size, so it copies them to &buffer[1616] ``` As shown by the structure above, `buffer + 1616` is the tracker's `log` field. The final eight payload bytes therefore replace a live pointer, and the same error path immediately uses it for logging. This is out of bounds relative to `buffer[]`, but remains inside the `ChannelPduTracker` allocation; AddressSanitizer does not classify the single-fragment overwrite as a heap-buffer-overflow. ### Reachability The server-side RDPDR channel opens with `CHANNEL_OPTION_SHOW_PROTOCOL` and uses `ChannelPduTracker` in a polling loop. Once a client joins the `rdpdr` static virtual channel, one 1608-byte SVC fragment is sufficient: the partially consumed queue head leaves the manual-reset channel event signalled, so the polling loop immediately performs the second and third reads. No RDPDR device handshake is needed before the tracker processes the raw channel message. The primitive was reproduced over ordinary TCP against FreeRDP 3.30.0 embedded in GNOME Remote Desktop 51.beta. A normally authenticated control isolated the FreeRDP defect. ## Reproduction 1. Build FreeRDP 3.30.0 with `WITH_VERBOSE_WINPR_ASSERT=OFF` and `NDEBUG`. 2. Start a FreeRDP server exposing the RDPDR static virtual channel. 3. Connect a test client and join `rdpdr`. The client must raise `FreeRDP_VCChunkSize` (8192 was used here): a stock client defaults it to `CHANNEL_CHUNK_LENGTH`, and `freerdp_channel_send()` splits at that value, so it cannot emit a single oversized chunk. The server applies no receive-side cap, which is why the oversized chunk is accepted. 4. Send one 1608-byte SVC payload as a single fragment; no follow-up channel traffic is required. 5. In a layout-aware control, place an inert marker in the final eight payload bytes and verify that the tracker's `log` pointer receives that value and is dereferenced by the next logging check. This intra-object overwrite is the primary single-fragment verification; it is not an ASan finding. 6. Rebuild with verbose WinPR assertions enabled and repeat; the process aborts before the out-of-bounds write. Appendix A contains a compact queue-layer proof using the real FreeRDP channel and tracker implementations. The full network client is about 1,400 lines because it must implement RDP negotiation, MCS, GCC, static-channel joining, and channel framing; inlining it would obscure the eight-byte trigger. That client, the exact build recipe, packet trace, separate extended ASan output, and raw over-TCP evidence are available privately on request. ## Impact ### Observed The over-TCP test replaced the live `log` pointer with a client-chosen value and the server dereferenced that exact value. A controlled component test reached an attacker-selected indirect logging callback. Every executed run used an assertion-disabled build; an assertion-enabled build was not run, and the remote-abort outcome below is derived from source rather than observed. ### Inferred On assertion-disabled builds, the pointer overwrite can support code execution when the attacker can predict or disclose a suitable in-process object and call target. Without that knowledge, reliable outcomes include a controlled invalid-pointer dereference and service crash. On assertion-enabled builds, remote process termination is deterministic. ## Remediation Suggestions - Consider publishing a security advisory for FreeRDP 3.28.0 through 3.30.0 that identifies commit `40d9202cd95551600c07437ce6bd5ecd7d31e57b` as the fix and records the first fixed tag once available. Until that tag is available, affected users can apply the commit or build from current master. - In `ChannelPduTracker_poll()`, enforce `offset <= CHANNEL_PDU_LENGTH` with runtime error handling, not assertions alone. - Never add `pBytesRead` when `BufferSize == 0`; alternatively, forbid a zero-size read in the tracker. - Reset or discard tracker state after an oversized or malformed channel PDU. - Reject any read result greater than the supplied buffer size. - Add release-build tests with assertions compiled out, including oversized SHOW_PROTOCOL messages and repeated polling after errors. The primary source-level fix already exists on master in commit `40d9202cd95551600c07437ce6bd5ecd7d31e57b`. Its essential change is to split every SHOW_PROTOCOL payload before queueing it, so no tracker message can exceed `CHANNEL_PDU_LENGTH`: ```c while (size) { const UINT32 payloadLen = (size > CHANNEL_CHUNK_LENGTH) ? CHANNEL_CHUNK_LENGTH : (UINT32)size; size -= payloadLen; const CHANNEL_PDU_HEADER header = { .length = payloadLen, .flags = flags_for_this_fragment, }; if (!wts_queue_receive_data(channel, (const BYTE*)&header, sizeof(header), data, payloadLen)) return FALSE; data += payloadLen; } ``` That is an abbreviated excerpt: the upstream commit also recomputes `CHANNEL_FLAG_FIRST` and `CHANNEL_FLAG_LAST` for the split fragments and should be used rather than copying this excerpt verbatim. Independent runtime bounds and reset/discard handling in `ChannelPduTracker_poll()` remain advisable as defense in depth; that additional hardening was not implemented or tested here. ## Appendix A: Compact queue-layer proof This LP64 component PoC is a compact adaptation of the validated harness. Save it at the FreeRDP 3.30.0 source root and build it as an internal test with `WITH_VERBOSE_WINPR_ASSERT=OFF` and `NDEBUG`. It drives the real `WTSProcessChannelData()` and `ChannelPduTracker_poll()` implementations. A valid `wLog` pointer is used as the chosen value so the third poll survives; the full network harness and build glue are available on request. This exact appendix was compiled and run against FreeRDP 3.30.0 on 2026-08-23 with `WITH_VERBOSE_WINPR_ASSERT=OFF` and `NDEBUG`. It produced offsets 1608, 1616, and 1624, and confirmed that `tracker->log` equalled the chosen pointer. A fresh run of this exact source produced the following output (addresses replaced with stable labels): ```text poll 1: offset=1608 log=<original-log> poll 2: offset=1616 log=<original-log> poll 3: offset=1624 log=<chosen-log> chosen=<chosen-log> overwritten=<chosen-log> ``` ```c #ifndef NDEBUG #define NDEBUG 1 #endif #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "libfreerdp/core/server.c" #include "libfreerdp/utils/channel_pdu_tracker.c" int main(void) { if (sizeof(void*) != 8) return 77; /* The demonstrated structure layout is LP64. */ if (!WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi())) return 1; rdpPeerChannel* channel = calloc(1, sizeof(*channel)); if (!channel) return 1; channel->vcm = (WTSVirtualChannelManager*)channel; /* non-NULL; unused here */ channel->channelId = 1; channel->channelType = RDP_PEER_CHANNEL_TYPE_SVC; channel->channelFlags = CHANNEL_OPTION_SHOW_PROTOCOL; channel->queue = MessageQueue_New(NULL); if (!channel->queue) return 1; ChannelPduTracker* tracker = ChannelPduTracker_new((HANDLE)channel); if (!tracker) return 1; BYTE payload[1608] = { 0 }; wLog* chosen = WLog_Get("poc.chosen-log"); memcpy(payload + sizeof(payload) - sizeof(chosen), &chosen, sizeof(chosen)); if (!WTSProcessChannelData(channel, channel->channelId, payload, sizeof(payload), CHANNEL_FLAG_FIRST, sizeof(payload))) return 1; BOOL ok = FALSE; for (size_t poll = 0; poll < 3; poll++) { wStream* packet = ChannelPduTracker_poll(tracker, &ok); if (packet) Stream_Release(packet); printf("poll %zu: offset=%zu log=%p\n", poll + 1, tracker->offset, (void*)tracker->log); } printf("chosen=%p overwritten=%p\n", (void*)chosen, (void*)tracker->log); return tracker->log == chosen ? 0 : 2; } ```

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.28.0, <= 3.30.03.31.0Patch availableGHSA-9jcm-x588-gh26
  • FreeRDP Vendor— Affected >= 3.28.0, <= 3.30.0 Fixed in 3.31.0 Patch available GHSA-9jcm-x588-gh26

Remediation

Upgrade FreeRDP to version 3.31.0, which fixes the flaw.

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

  • Fix · GHSA-9jcm-x588-gh26 FreeRDP Fixed in 3.31.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-9jcm-x588-gh26

References

Sources

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