Menu

#572 number_colors sanity check

v1.0_(example)
closed-rejected
None
5
2018-09-11
2018-09-10
Petr Gajdos
No

Hi,

this is inspired by CVE-2018-16645 for ImageMagick. Would be similar check worth to add to GraphicsMagick, to? See patch attached.

Thanks!

1 Attachments

Discussion

  • Petr Gajdos

    Petr Gajdos - 2018-09-10

    There seem to be similar issue in pict.c.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2018-09-10

    I don't see a need for any of these changes. There is a significant cost to setting the seekable_stream option because it prohibits reading directly from a file descriptor and requires copying all the input to a temporary file (or would requiring buffering all input to allocated memory). The AllocateImageColormap() function will not allocate more than 64k colormap entries in any build configuration (a 524k byte allocation in total) so this is not much of a DOS opportunity.

     
  • Petr Gajdos

    Petr Gajdos - 2018-09-10

    Indeed, I had not noticed there is a check against MaxColormapSize in AllocateImageColormap(). Thanks for your explanation, feel free to close.

     
    • Bob Friesenhahn

      Bob Friesenhahn - 2018-09-10

      On Mon, 10 Sep 2018, Petr Gajdos wrote:

      Indeed, I had not noticed there is a check against MaxColormapSize in AllocateImageColormap(). Thanks for your explanation, feel free to close.

      Individual checks to verify that the requested number of colors do not
      exceed the amount allowed by the file format are definitely still
      useful (e.g. 256 entries is still a lot less memory than 64k entries)
      since it is good to reject corrupt files. Some file formats are
      sloppy and provide a larger storage unit than is required and so a
      corrupt file is able to specify a large value.

      Bob

      Bob Friesenhahn
      bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
      GraphicsMagick Maintainer, http://www.GraphicsMagick.org/

       
  • Bob Friesenhahn

    Bob Friesenhahn - 2018-09-11

    I checked bmp.c and dib.c and see that they are already adding additional checks/constraints on the number of colors prior to attempting to allocate the colormap. I do not see the same in pict.c. It seems unlikely that PICT actually supports more than 256 colors.

     
  • Bob Friesenhahn

    Bob Friesenhahn - 2018-09-11
    • status: open --> closed-rejected
    • assigned_to: Bob Friesenhahn
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2018-09-11

    Due to existing checks/constaints, the severity of this issue is within reasonable bounds in GraphicsMagick and not a denial of service opportunity. There is no need for any code changes at this time.

     

Log in to post a comment.

MongoDB Logo MongoDB