Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 930532 - gnustep-base/gnustep-gui: Buffer Overflow in _initBitmapFromJPEG
Summary: gnustep-base/gnustep-gui: Buffer Overflow in _initBitmapFromJPEG
Status: UNCONFIRMED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: Normal major (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B2 [ebuild/upstream]
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-24 02:55 UTC by Franco Belman
Modified: 2024-04-24 08:02 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Franco Belman 2024-04-24 02:55:12 UTC
The vulnerable _initBitmapFromJPEG function in file NSBitmapImageRep+JPEG.m (gnustep/libs-gui/blob/master/Source/NSBitmapImageRep%2BJPEG.m#L412) is used to decompress jpegs and create a raw bitmap version of the image.

In _initBitmapFromJPEG, 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 cinfo.output_components.

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 imgbuffer, which will store the decompressed jpeg (gnustep/libs-gui/blob/master/Source/NSBitmapImageRep%2BJPEG.m#L486). When the sizing arguments overflow, the array becomes too small to store the decompressed data.

The program writes the decompressed image to the buffer using the jpeg_read_scanlines function. The function ends up writing to out-of-bounds memory due to the buffer’s small size (gnustep/libs-gui/blob/master/Source/NSBitmapImageRep%2BJPEG.m#L498). 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.
Comment 1 Hans de Graaff gentoo-dev Security 2024-04-24 05:54:36 UTC
Do you have a reference for this issue (e.g. upstream bug report, CVE, etc)?
Comment 2 Franco Belman 2024-04-24 08:02:35 UTC
(In reply to Hans de Graaff from comment #1)
> Do you have a reference for this issue (e.g. upstream bug report, CVE, etc)?

I do not have a reference for this issue at the moment.