Non-Atomic wStream Reference Count in Asynchronous RDPDR IRP Processing Causes Remote Memory Leak
Key facts
- Attack vector
- Network
- Privileges required
- None
- User interaction
- None
- Attack complexity
- Low
- Impact type
- —
- Confidentiality · integrity · availability
- None · None · High
- Fix status
- Fixed
Attack profile from CVSS 3.1 · GHSA-9p9c-p3g6-fg7j. Fix status from GitHub.
Summary
### Summary A malicious RDP server can trigger a reference-count race in FreeRDP's asynchronous RDPDR IRP processing. The RDPDR worker and a device worker can release the same input wStream concurrently, but wStream::count is a plain DWORD and Stream_Release() performs a non-atomic read-modify-write. If both workers read count == 2 before either stores its result, both write count == 1. The stream never reaches zero and remains permanently present in the stream pool's used list for the lifetime of the connection. ThreadSanitizer found the race through the smartcard IRP path during fuzzing. Deterministic validation using the same end-to-end fuzzer input produced used_streams=1 in 5 out of 5 forced-collision executions, while the identical input produced used_streams=0 in 5 out of 5 control executions. The confirmed impact is a remotely triggerable connection-lifetime memory leak. Repeated IRPs can accumulate leaked stream objects and their attacker-influenced buffers, resulting in memory-exhaustion denial of service. ### Details The issue was reproduced on FreeRDP 3.32.3-dev0 at commit b2403bb99fba33acc817ffd4042b64e077d59076. When rdpdr_process_irp() creates an IRP, irp_new() retains the input stream for the asynchronous device worker: Stream_AddRef(s); irp->input = s; The RDPDR worker releases its reference immediately after rdpdr_process_receive() returns: error = rdpdr_process_receive(rdpdr, data); Stream_Release(data); The device worker later completes or discards the IRP, and irp_free() releases the second reference: if (irp->input) Stream_Release(irp->input); These releases execute on different threads. Stream_Release() updates the reference count without an atomic primitive or lock: if (s->count > 0) s->count--; if (s->count == 0) StreamPool_ReleaseOrReturn(...); The corresponding Stream_AddRef() operation is also non-atomic, although the confirmed execution races between the two releases. The observed lost-update interleaving is: RDPDR worker: load count = 2 device worker: load count = 2 RDPDR worker: store count = 1 device worker: store count = 1 Neither worker observes zero, so StreamPool_ReleaseOrReturn() is never called. The stream remains in the pool's used array until the entire pool is destroyed. The attached TSan report shows the natural race between rdpdr_virtual_channel_client_thread() and smartcard_thread_func(). The attached minimized input exercises the real RDPDR queue, IRP creation, smartcard queue, and asynchronous completion path. For deterministic validation, a fuzz-only scheduler point was placed between the existing count load and store. It only delays both real Stream_Release() calls until they have loaded count == 2. With the same input: control, five executions: used_streams=0 forced collision, five executions: used_streams=1 An additional attached standalone test repeatedly demonstrates the same lost decrement using the real WinPR wStream and StreamPool implementation. Although the validated route uses smartcard redirection, the vulnerable ownership pattern is in the common RDPDR IRP layer and can affect other asynchronous redirected devices that retain an input stream. Intended Behavior The stream reference count should remain correct when references are released from different RDPDR and device-worker threads. The final release must return the stream to its pool or free it. Actual Behavior Concurrent non-atomic decrements can overwrite each other and leave the reference count at one. The stream and its backing buffer remain in the pool's used list until connection teardown, allowing repeated server-controlled IRPs to consume increasing client memory. ### Impact Memory leaking or double free of a stream accessed from multiple threads ### Fix https://github.com/FreeRDP/FreeRDP/pull/13918 ### Reported by Jaeyeong Lee by mail
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.2 | 3.33.0 | Patch available | GHSA-9p9c-p3g6-fg7j |
- FreeRDP (c) Vendor— Affected <= 3.32.2 Fixed in 3.33.0 Patch available GHSA-9p9c-p3g6-fg7j
Remediation
- Fix · GHSA-9p9c-p3g6-fg7j FreeRDP (c) Fixed in 3.33.0 Advisory →
Timeline
- 2026-11-12 Threatist record created from GHSA-9p9c-p3g6-fg7j
References
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences