-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory exhaustion in ReadXWDImage #471
Comments
Thanks for reporting this. Can you help us figure out what the limit for ncolors should be? I found the following documentation: http://www.fileformat.info/format/xwd/egff.htm
But it does not provide a hard limit for the number of colors. |
@dlemstra from the document, EntryNumber can not bigger than filesize/sizeof(X11COLORMAP) |
This is CVE-2017-11166 |
It does not seems to be corrected for V6 |
This is the IM6 commit: 5964475 |
ImageMagick 7.0.5-6
$magick identify $FILE
When identify XWD file, imagemagick will allocate memory to store data in function ReadXWDImage in coders\xwd.c, line 325
//////////////////////////////////
colors=(XColor *) AcquireQuantumMemory(length,sizeof(*colors)); // can be controlled
\\\\\\\\\\\\\\\\\\
length can be controlled, as it is assigned as follow(line 324):
//////////////////////////////////
length=(size_t) header.ncolors;
\\\\\\\\\\\\\\\\\\
header.ncolors are diretly from XWD file without checking( line 224)
//////////////////////////////////
count=ReadBlob(image,sz_XWDheader,(unsigned char *) &header); // can be controlled by modify XWD file
\\\\\\\\\\\\\\\\\\
header is a instance of struct _xwd_file_header as follow:
//////////////////////////////////
typedef struct _xwd_file_header {
/* header_size = SIZEOF(XWDheader) + length of null-terminated
* window name. */
CARD32 header_size B32;
} XWDFileHeader;
\\\\\\\\\\\\\\\\\\
So, modifying the ncolors can cause ImageMagick to allocate a anysize amount of memory, this may cause a memory exhaustion
Reproducer: https://github.com/jgj212/poc/blob/master/ImageMagick-7.0.5-6-memory-exhaustion.XWD
Credit: ADLab of Venustech
The text was updated successfully, but these errors were encountered: