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

CPU exhaustion in ReadRLEImage #518

Closed
jgj212 opened this issue Jun 22, 2017 · 3 comments
Closed

CPU exhaustion in ReadRLEImage #518

jgj212 opened this issue Jun 22, 2017 · 3 comments
Labels

Comments

@jgj212
Copy link
Contributor

jgj212 commented Jun 22, 2017

Version: ImageMagick 7.0.6-1 Q16 x86_64

$magick identify $FILE

          if ((number_planes >= 3) && (number_colormaps >= 3))    //line 512
            for (i=0; i < (ssize_t) number_pixels; i++)     //line 513, number_pixels can be controlled
              for (x=0; x < (ssize_t) number_planes; x++)   //line 514,  number_planes can be controlled   
              { 
                ValidateColormapValue(image,(ssize_t) (x*map_length+
                  (*p & mask)),&index,exception);
                *p=colormap[(ssize_t) index];
                p++;
              }
number_pixels=(MagickSizeType) image->columns*image->rows;  //line 326

image->rows is 16bit, image->columns is also 16bit. But number_pixels is 64bit, so it can be very large.

    image->columns=ReadBlobLSBShort(image);  //line 229
    image->rows=ReadBlobLSBShort(image);    //line 230
    number_planes=(size_t) ReadBlobByte(image);  //line 233

Because the count of loop can be controlled, so it can cause ImageMagick to spend a lot of time to process a crafted imagefile, even if the imagefile is very small.

Credit: ADLab of Venustech

@mikayla-grace
Copy link

Can you post an example exploit. We would expect that an exploit image file would return an EOF before a possible DOS.

@jgj212
Copy link
Contributor Author

jgj212 commented Jun 23, 2017

@mikayla-grace
Copy link

mikayla-grace commented Jun 23, 2017

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.

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

3 participants