Skip to content
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

Null Pointer Dereference vulnerability triggered by malformed image files #710

Closed
kirit1193 opened this issue Aug 31, 2017 · 3 comments
Closed
Labels

Comments

@kirit1193
Copy link

A Null-Pointer Dereference issues is present in the QueueAuthenticPixelCacheNexus function within the ImageMagick/MagickCore/cache.c file. The vulnerable code is as follows:

for (i=0; i < (ssize_t)image->rows; i++)
   {
   q=QueueAuthenticPixels(image,0,i,image->columns,1,exception);
   for (j=0; j < (ssize_t)image->columns; j++)
      {
      if (GetPixelRed(image,q) == ScaleCharToQuantum(1))
         {
         <some code>
      }

Here, the variable q is getting the output of the function QueueAuthenticPixels. This function, in turn calls:

pixels=QueueAuthenticPixelCacheNexus(image,x,y,columns,rows,MagickFalse,cache_info->nexus_info[id],exception);
return(pixels);

The QueueAuthenticPixelCacheNexus function performs a series of asserts are explicitly returns NULL:

assert(image != (const Image *) NULL);
assert(image->signature == MagickCoreSignature);
assert(image->cache != (Cache) NULL);
cache_info=(CacheInfo *) GetImagePixelCache(image,clone,exception);
if (cache_info == (Cache) NULL)
   return((Quantum *) NULL);

Once this NULL is returned back to the original function via return(pixels);, q gets the NULL value.

It gets used in a function call: GetPixelRed(image,q)

It is finally de-referenced in GetPixelRed in the following line:

return(pixel[image->channel_map[RedPixelChannel].offset]);

Modifying the code to:

if (q != NULL)
   GetPixelRed(image,q);

Would avoid this vulnerability.

@urban-warrior
Copy link
Member

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.

@dlemstra dlemstra added the bug label Aug 31, 2017
@fgeek
Copy link

fgeek commented Sep 1, 2017

Please use CVE-2017-14060 for this issue.

@kirit1193
Copy link
Author

Thanks @fgeek!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants