Heap buffer overflow in FreeRDP RAIL server order length handling
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.28.0 has a server-side RAIL channel flaw in rail_server_handle_messages(), where the code subtracts the RAIL header length from a peer-supplied orderLength without first checking that it is large enough. A value smaller than the header length underflows the body size used for stream capacity and for WTSVirtualChannelRead(), which leads to a heap buffer overflow. A malicious or compromised RDP client can trigger it by sending a crafted RAIL PDU to the server.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
## Reporter / credit: Bin Luo, University of Electronic Science and Technology of China (UESTC), [email protected] Target: - Repository: `FreeRDP/FreeRDP` - Latest release reproduced: `3.28.0` - Reproduction commit: `5370fb26fbf034ecd11d3026b6ad639b5fff493f` - Latest public master checked: `46848765f2a1134f8652f8760eefb5e85d64a9b8` - Affected component: server-side RAIL channel handling ## Title FreeRDP RAIL server orderLength underflow can cause heap-buffer-overflow ## Summary FreeRDP `3.28.0` contains a server-side memory-safety issue in `channels/rail/server/rail_main.c:rail_server_handle_messages()`. A malicious or compromised RDP client can send a RAIL PDU header with an `orderLength` smaller than the fixed RAIL header length. The code subtracts `RAIL_PDU_HEADER_LENGTH` from this peer-controlled value without first checking that the length is at least the header size. This underflows the body length used for both stream-capacity handling and `WTSVirtualChannelRead()`. I reproduced this against supported release `3.28.0` in Docker. AddressSanitizer reports a heap-buffer-overflow, and an O2 release build aborts with heap corruption. ## Technical details In `rail_server_handle_messages()`: ```c if ((status = rail_read_pdu_header(s, &orderType, &orderLength)) != CHANNEL_RC_OK) return status; if (!Stream_EnsureRemainingCapacity(s, orderLength - RAIL_PDU_HEADER_LENGTH)) return CHANNEL_RC_NO_MEMORY; if (!WTSVirtualChannelRead(priv->rail_channel, 0, Stream_Pointer(s), orderLength - RAIL_PDU_HEADER_LENGTH, &bytesReturned)) return ERROR_INTERNAL_ERROR; ``` `orderLength` is a peer-controlled `UINT16`. For values `0..3`, `orderLength - RAIL_PDU_HEADER_LENGTH` underflows to a very large unsigned size. `Stream_EnsureRemainingCapacity()` checks: ```c if (Stream_GetPosition(s) + size > Stream_Capacity(s)) return Stream_EnsureCapacity(s, Stream_Capacity(s) + size); return TRUE; ``` With the underflowed size, `Stream_GetPosition(s) + size` can wrap and the function may return success without expanding the default 4096-byte `input_stream`. The subsequent `WTSVirtualChannelRead()` still receives the underflowed size. The WinPR static-channel read path copies channel data into the caller-provided buffer: ```c if (numBytesToRead > (pChannel->header->length - pChannel->readOffset)) numBytesToRead = (pChannel->header->length - pChannel->readOffset); CopyMemory(lpBuffer, &(pChannel->chunk[pChannel->readOffset]), numBytesToRead); ``` So the RAIL caller must validate the length before passing the destination pointer and requested size. ## Reproduction The local reproducer includes upstream `channels/rail/rail_common.c` and `channels/rail/server/rail_main.c` from FreeRDP `3.28.0`, and stubs the WTS channel boundary to provide a malformed RAIL message: - `orderType = TS_RAIL_ORDER_CLIENTSTATUS` - `orderLength = 0` - available channel body after the header: `8192` bytes - initial RAIL input stream capacity: `4096` bytes Local artifacts: - Harness: `E:\vul-tower\audit_freerdp_20260706\docker_repro\freerdp_rail_server_orderlength_harness.c` - ASan build log: `E:\vul-tower\audit_freerdp_20260706\docker_repro\rail_server_orderlength_asan_build.log` - ASan run log: `E:\vul-tower\audit_freerdp_20260706\docker_repro\rail_server_orderlength_asan_run.txt` - Release build log: `E:\vul-tower\audit_freerdp_20260706\docker_repro\rail_server_orderlength_release_build.log` - Release run log: `E:\vul-tower\audit_freerdp_20260706\docker_repro\rail_server_orderlength_release_run.txt` ASan result: ```text ERROR: AddressSanitizer: heap-buffer-overflow WRITE of size 8192 #2 WTSVirtualChannelRead docker_repro/freerdp_rail_server_orderlength_harness.c:26 #3 harness_rail_server_handle_messages .../channels/rail/server/rail_main.c:1591 0x521000006100 is located 0 bytes after 4096-byte region allocated by Stream_New .../winpr/libwinpr/utils/stream.c:101 ``` Release result: ```text free(): invalid next size (normal) Aborted (core dumped) ``` ## Impact The confirmed impact is server-side heap memory corruption and process termination when a malformed RAIL channel message is processed. I am not claiming demonstrated remote code execution. Threat model: - malicious or compromised RDP client; - FreeRDP server/proxy/shadow deployment with RAIL channel reachability. Suggested weakness classification: - CWE-191: Integer Underflow - CWE-787: Out-of-bounds Write Suggested severity: - Moderate to High, depending on FreeRDP's server-side RAIL exposure assumptions. - Conservative CVSS framing can be availability-focused because the reproduced release impact is process abort / heap corruption. ## Suggested fix direction Reject short RAIL PDUs before subtracting: ```c if (orderLength < RAIL_PDU_HEADER_LENGTH) return ERROR_INVALID_DATA; ``` Then compute the body length once and use that validated value for both capacity handling and `WTSVirtualChannelRead()`. It may also be worth using an overflow-safe capacity helper for `Stream_GetPosition(s) + size` patterns.
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/c++) | <=3.28.0 | 3.29.0 | Patch available | GHSA-qmvw-52ph-q5pv |
- FreeRDP (c/c++) Vendor— Affected <=3.28.0 Fixed in 3.29.0 Patch available GHSA-qmvw-52ph-q5pv
Remediation
FreeRDP 3.29.0 fixes this issue, so upgrade to that version or later.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-qmvw-52ph-q5pv FreeRDP (c/c++) Fixed in 3.29.0 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-qmvw-52ph-q5pv
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences