Skip to content

Use-After-Free in RDPGFX_CMDID_RESETGRAPHICS

Moderate
akallabeth published GHSA-hvwj-vmg6-2f5h Aug 31, 2023

Package

FreeRDP

Affected versions

>= 3.0.0-beta1

Patched versions

3.0.0-beta3

Description

Summary

Use-After-Free in RDPGFX_CMDID_RESETGRAPHICS

Affected

FreeRDP based clients only. FreeRDP proxy not affected as image decoding is not done by proxy (data passthrough)

Details

BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context, UINT32 width,
UINT32 height)
{
if (!context)
return FALSE;
context->bgr = FALSE;
context->maxWidth = PLANAR_ALIGN(width, 4);
context->maxHeight = PLANAR_ALIGN(height, 4);
context->maxPlaneSize = context->maxWidth * context->maxHeight;
context->nTempStep = context->maxWidth * 4;
void* tmp = winpr_aligned_recalloc(context->planesBuffer, context->maxPlaneSize, 4, 32);
if (!tmp)
return FALSE;
context->planesBuffer = tmp;

If context->maxPlaneSize is 0, context->planesBuffer will be freed. However, without updating context->planesBuffer, this leads to a Use-After-Free (UAF) vulnerability.

PoC

  1. Send RDPGFX_CMDID_RESETGRAPHICS packet with height == 0 or width == 0
  2. Send RDPGFX_CMDID_RESETGRAPHICS packet again, crashed

Impact

Use-After-Free leading to unexpected behavior

Severity

Moderate

CVE ID

CVE-2023-39355

Weaknesses

No CWEs

Credits