Xi: avoid integer truncation in length check of ProcXIChangeProperty

This fixes an OOB read and the resulting information disclosure.

Length calculation for the request was clipped to a 32-bit integer. With
the correct stuff->num_items value the expected request size was
truncated, passing the REQUEST_FIXED_SIZE check.

The server then proceeded with reading at least stuff->num_items bytes
(depending on stuff->format) from the request and stuffing whatever it
finds into the property. In the process it would also allocate at least
stuff->num_items bytes, i.e. 4GB.

The same bug exists in ProcChangeProperty and ProcXChangeDeviceProperty,
so let's fix that too.

CVE-2022-46344, ZDI-CAN 19405

This vulnerability was discovered by:
Jan-Niklas Sohn working with Trend Micro Zero Day Initiative

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Acked-by: Olivier Fourdan <ofourdan@redhat.com>
(cherry picked from commit 8f454b793e)
This commit is contained in:
Peter Hutterer 2022-11-29 13:26:57 +10:00
parent 40f431de8a
commit 8a1fa008b2
2 changed files with 4 additions and 3 deletions

View File

@ -890,7 +890,7 @@ ProcXChangeDeviceProperty(ClientPtr client)
REQUEST(xChangeDevicePropertyReq); REQUEST(xChangeDevicePropertyReq);
DeviceIntPtr dev; DeviceIntPtr dev;
unsigned long len; unsigned long len;
int totalSize; uint64_t totalSize;
int rc; int rc;
REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq); REQUEST_AT_LEAST_SIZE(xChangeDevicePropertyReq);
@ -1130,7 +1130,7 @@ ProcXIChangeProperty(ClientPtr client)
{ {
int rc; int rc;
DeviceIntPtr dev; DeviceIntPtr dev;
int totalSize; uint64_t totalSize;
unsigned long len; unsigned long len;
REQUEST(xXIChangePropertyReq); REQUEST(xXIChangePropertyReq);

View File

@ -205,7 +205,8 @@ ProcChangeProperty(ClientPtr client)
WindowPtr pWin; WindowPtr pWin;
char format, mode; char format, mode;
unsigned long len; unsigned long len;
int sizeInBytes, totalSize, err; int sizeInBytes, err;
uint64_t totalSize;
REQUEST(xChangePropertyReq); REQUEST(xChangePropertyReq);