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

memory exhausted in ReadWEBPImage #641

Closed
jgj212 opened this issue Aug 2, 2017 · 7 comments
Closed

memory exhausted in ReadWEBPImage #641

jgj212 opened this issue Aug 2, 2017 · 7 comments
Labels

Comments

@jgj212
Copy link
Contributor

jgj212 commented Aug 2, 2017

Version: ImageMagick 7.0.6-5 Q16 x86_64

Here is the critical code


static Image *ReadWEBPImage(const ImageInfo *image_info,
  ExceptionInfo *exception)
{
  ....

  length=(size_t) (ReadWebPLSBWord(header+4)+8);   //265, length can be controlled from file data
  if (length < 12)
    ThrowReaderException(CorruptImageError,"CorruptImage");
  stream=(unsigned char *) AcquireQuantumMemory(length,sizeof(*stream)); //length can be from 0 to 4G, this will cause memory exhausted on some condition even if the webp image file is very small

  if (stream == (unsigned char *) NULL)
    ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");

   ...
}

Credit: ADLab of Venustech

@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.

@njdoyle
Copy link
Contributor

njdoyle commented Aug 2, 2017

The fix breaks reading all WebP images. Line 266 in the new code sets webp_image to null and then we immediately try to dereference it on line 269.

@bastien-roucaries
Copy link

Create two CVE: one for the original issue and one for the null dereference
http://cveform.mitre.org/

@bastien-roucaries
Copy link

And post CVE number here

@dlemstra
Copy link
Member

dlemstra commented Aug 2, 2017

He has a remark about the fix that we applied that has not been released to the public yet. Why do we need a CVE for that?

@bastien-roucaries
Copy link

No if not yet public but mark clearly in changelog and commit that the fix is in fact two fix. Better will be to revert and redo and post here the correct fix

@fgeek
Copy link

fgeek commented Sep 7, 2017

Please use CVE-2017-14137 for the "ReadWEBPImage in coders/webp.c in ImageMagick 7.0.6-5 has an issue where memory allocation is excessive because it depends only on a length field in a header." issue.

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

6 participants