Read the docs

FreeRDP rdpecam client crashes on a SampleRequest for an idle stream

Priority LOW 39CWE-401Published · Updated

Key facts

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

Attack profile from CVSS 3.1 · GHSA-m33m-4qxh-hq76. Fix status from GitHub. Impact type from CWE-401.

Summary

FreeRDP up to and including 3.33.0 uses a stream lock in the rdpecam client's camera device code that may not be initialized when a sample request arrives for a stream that is not started. This leads to a NULL pointer dereference (CWE-476). A server that a client connects to can crash the client with a short message on a camera device channel, which affects availability only.

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

Description from the GitHub advisory

Affected: FreeRDP 3.32.2 and master as of 2026-10-29 (61ad26c1), `channels/rdpecam/client/camera_device_main.c` (line numbers of 3.32.2; master is 10 to 12 lines later). 1. `ecam_dev_create` allocates the `CameraDevice` with `calloc`. `streams[i].lock` is only initialized in `ecam_dev_process_start_streams_request` (l. 465) and deleted in `ecam_dev_stop_stream` (l. 330). `ecam_dev_process_sample_request` enters it (l. 569) for any valid stream index. On a zeroed `CRITICAL_SECTION`, WinPR's `EnterCriticalSection` takes `LockCount` from 0 to 1, finds no owner, and calls `sem_wait(NULL)` (`critical.c` l. 139). With `NDEBUG` and `WITH_VERBOSE_WINPR_ASSERT=OFF`, the dynamic channel thread crashes; with assertions on, the client aborts. This happens on a `SampleRequest` (0x11) before any `StartStreamsRequest`, or after one refused before l. 465 (unannounced media type, encoder init failure, no memory). 2. After a `StopStreamsRequest` that left a frame pending (`haveSample` stays set), a `SampleRequest` reaches `ecam_dev_prepare_sample_response`, which calls `Stream_ResetPosition` on the freed, NULL `sampleRespBuffer` (l. 144): NULL dereference. 3. A `StartStreamsRequest` that fails after l. 465 leaks the lock's semaphore, since `ecam_dev_stop_stream` only deletes it for a streaming stream. Impact: the server the client connects to can crash the client with a 3-byte PDU on a camera device channel, at every connection that redirects a camera (availability only). Reproduction (ASan/UBSan, `-DNDEBUG`): the real `camera_device_main.c` with WinPR `critical.c`, `interlocked.c` and `stream.c`; the device made by `ecam_dev_create`, its channel opened, a MediaTypeListRequest, then `{0x02, 0x11, 0x00}`. Result: SEGV at address 0 in `sem_wait`, from `ecam_dev_process_sample_request` (l. 569). The stop case gives a SEGV in `Stream_ResetPosition` (l. 144); the HAL-refused start gives a 32-byte leak. Fix (patch below, against 3.32.2; it applies to master with offsets): initialize each stream lock once in `ecam_dev_create` (deleted on its error paths) and delete it in `ecam_dev_destroy`; answer a `SampleRequest` on a stream that is not streaming with a `SampleErrorResponse` (`CAM_ERROR_CODE_NotInitialized`), as MS-RDPECAM 2.2.3.13 requires, keeping the channel open. Only server requests on the dynamic channel thread start and stop a stream, so `streaming` is read there without the lock. Found while reviewing an Android client built on FreeRDP 3.32.2. ```diff diff --git a/channels/rdpecam/client/camera_device_main.c b/channels/rdpecam/client/camera_device_main.c index e99474b..86bd87b 100644 --- a/channels/rdpecam/client/camera_device_main.c +++ b/channels/rdpecam/client/camera_device_main.c @@ -326,8 +326,6 @@ static void ecam_dev_stop_stream(CameraDevice* dev, size_t streamIndex) stream->streaming = FALSE; stream->captureRunning = FALSE; dev->ihal->StopStream(dev->ihal, dev->deviceId, 0); - - DeleteCriticalSection(&stream->lock); } Stream_Free(stream->sampleRespBuffer, TRUE); @@ -462,14 +460,6 @@ static UINT ecam_dev_process_start_streams_request(CameraDevice* dev, stream->lastSampleRequestTime = GetTickCount64(); stream->haveSample = FALSE; - if (!InitializeCriticalSectionEx(&stream->lock, 0, 0)) - { - WLog_ERR(TAG, "InitializeCriticalSectionEx failed"); - ecam_dev_stop_stream(dev, streamIndex); - ecam_channel_send_error_response(dev->ecam, hchannel, CAM_ERROR_CODE_OutOfMemory); - return ERROR_INVALID_DATA; - } - stream->pendingSample = Stream_New(nullptr, 4ull * mediaType.Width * mediaType.Height); if (!stream->pendingSample) { @@ -566,6 +556,19 @@ static UINT ecam_dev_process_sample_request(CameraDevice* dev, GENERIC_CHANNEL_C BOOL startCapture = FALSE; CAM_MEDIA_TYPE_DESCRIPTION mediaType = WINPR_C_ARRAY_INIT; + /* MS-RDPECAM 2.2.3.13: each Sample Request gets a Sample Response or a Sample Error Response. + * A stream never started, refused or stopped has no sample to give. Only the requests of the + * server, handled on this thread, start and stop a stream while the channel is open. */ + if (!stream->streaming) + { + WLog_WARN(TAG, + "Sample request for stream %" PRIu8 + ", which is not started: sample error response", + streamIndex); + return ecam_dev_send_sample_error_response(dev, hchannel, streamIndex, + CAM_ERROR_CODE_NotInitialized); + } + EnterCriticalSection(&stream->lock); /* need to save channel because responses are asynchronous and coming from capture thread */ @@ -983,6 +986,17 @@ static UINT ecam_dev_on_new_channel_connection(IWTSListenerCallback* pListenerCa return CHANNEL_RC_OK; } +/** + * Deletes the locks of the first nStreams streams of a device, which ecam_dev_create initialized + */ +static void ecam_dev_delete_locks(CameraDevice* dev, size_t nStreams) +{ + WINPR_ASSERT(dev); + + for (size_t i = 0; i < nStreams; i++) + DeleteCriticalSection(&dev->streams[i].lock); +} + /** * Function description * @@ -1010,10 +1024,25 @@ CameraDevice* ecam_dev_create(CameraPlugin* ecam, const char* deviceId, dev->ecam = ecam; dev->ihal = ecam->ihal; strncpy(dev->deviceId, deviceId, sizeof(dev->deviceId) - 1); + + /* The lock of each stream lives as long as the device: a request of the server can take it + * before the stream starts, or after it stopped */ + for (size_t i = 0; i < ECAM_DEVICE_MAX_STREAMS; i++) + { + if (!InitializeCriticalSectionEx(&dev->streams[i].lock, 0, 0)) + { + ecam_dev_delete_locks(dev, i); + free(dev); + WLog_ERR(TAG, "InitializeCriticalSectionEx failed"); + return nullptr; + } + } + dev->hlistener = (GENERIC_LISTENER_CALLBACK*)calloc(1, sizeof(GENERIC_LISTENER_CALLBACK)); if (!dev->hlistener) { + ecam_dev_delete_locks(dev, ECAM_DEVICE_MAX_STREAMS); free(dev); WLog_ERR(TAG, "calloc failed"); return nullptr; @@ -1026,6 +1055,7 @@ CameraDevice* ecam_dev_create(CameraPlugin* ecam, const char* deviceId, &dev->hlistener->iface, &dev->listener)) { free(dev->hlistener); + ecam_dev_delete_locks(dev, ECAM_DEVICE_MAX_STREAMS); free(dev); WLog_ERR(TAG, "CreateListener failed"); return nullptr; @@ -1059,5 +1089,6 @@ void ecam_dev_destroy(CameraDevice* dev) for (size_t i = 0; i < ECAM_DEVICE_MAX_STREAMS; i++) ecam_dev_stop_stream(dev, i); + ecam_dev_delete_locks(dev, ECAM_DEVICE_MAX_STREAMS); free(dev); } ```

Why it matters now

Fix Fixed FreeRDP (c): 3.33.1

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—FreeRDP (c)<= 3.33.03.33.1Patch availableGHSA-m33m-4qxh-hq76
  • FreeRDP (c) Vendor— Affected <= 3.33.0 Fixed in 3.33.1 Patch available GHSA-m33m-4qxh-hq76

Remediation

Upgrade FreeRDP to version 3.33.1, which fixes the issue.

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

  • Fix · GHSA-m33m-4qxh-hq76 FreeRDP (c) Fixed in 3.33.1 Advisory →

Timeline

  1. 2026-11-17 Threatist record created from GHSA-m33m-4qxh-hq76

References

Sources

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