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 in the IdentifyImage function within ImageMagick/MagickCore/identify.c #706

Closed
kirit1193 opened this issue Aug 29, 2017 · 2 comments
Labels

Comments

@kirit1193
Copy link

A Null Pointer De-reference vulnerability is occurring due to the vulnerable code in the IdentifyImage function within ImageMagick/MagickCore/identify.c

The vulnerable code is as follows:

p=(const Quantum *) NULL;	
          for (y=0; y < (ssize_t) image->rows; y++)	
          {	
            p=GetVirtualPixels(image,0,y,image->columns,1,exception);	
            if (p == (const Quantum *) NULL)	
              break;	
            for (x=0; x < (ssize_t) image->columns; x++)	
              <code doesn’t reach here if p=NULL>
          }	

It is seen that p is being explicitly checked whether it is NULL and if it is, it breaks out of the for loop. Now the subsequent for loop modifies the value of p but due to the break statement, this doesn't occur.

Eventually, p is being used as an argument here in the GetPixelInfoPixel function:

GetPixelInfoPixel(image,p,&pixel);

Looking at the definition, p is passed into const Quantum *magick_restrict pixel, which is the 2nd argument. This is being explicitly de-referenced here:

pixel_info->red=(MagickRealType) pixel[image->channel_map[RedPixelChannel].offset];

There should be a check to verify if a pointer is NULL or not before any operations are performed on it, if it depends on user-input:

if (p != NULL) {
    <perform_operations>
}
@mikayla-grace
Copy link

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 @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.

@dlemstra dlemstra added the bug label Aug 29, 2017
@nohmask
Copy link

nohmask commented Sep 8, 2017

This was assigned CVE-2017-13768.

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