Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-19529

Buffer Overflow in windowscodecs - JpegDecoder_Initialize

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • RosDlls

    Description

      The vulnerable JpegDecoder_Initialize function in file jpegformat.c (https://github.com/reactos/reactos/blob/master/dll/win32/windowscodecs/jpegformat.c#L301) is used to decompress jpegs and create a raw bitmap version of the image.

      In JpegDecoder_Initialize, the values for cinfo.output_width and cinfo.output_height are retrieved directly from a jpeg file's header.

      cinfo.output_width and cinfo.output_height can be manipulated by editing the header of the jpeg file being processed. They are two bytes each in the image's header so their values can range from 0x0000 to 0xFFFF. These variables are multiplied with bpp.

      When these three values are multiplied together they can exceed the limit of a 32-bit unsigned integer, leading to an integer overflow vulnerability. This product is used to set the size of the image_data buffer, which will store the decompressed jpeg (https://github.com/reactos/reactos/blob/master/dll/win32/windowscodecs/jpegformat.c#L393). When the sizing arguments overflow, the buffer becomes too small to store the decompressed data.

      The program writes the decompressed image to the buffer using the pjpeg_read_scanlines function. The function ends up writing to out-of-bounds memory due to the buffer’s small size (https://github.com/reactos/reactos/blob/master/dll/win32/windowscodecs/jpegformat.c#L413). This causes data in memory adjacent to the buffer to be overwritten.

      An attacker is in control of the image's height, width, and contents. This allows an attacker to craft an exploit to overwrite data in memory with data they control.

      Attachments

        Activity

          People

            Unassigned Unassigned
            franco-bw franco-bw
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: