oss-sec mailing list archives

Re: ImageMagick Is On Fire -- CVE-2016-3714


From: Bob Friesenhahn <bfriesen () simple dallas tx us>
Date: Tue, 3 May 2016 20:42:30 -0500 (CDT)

On Tue, 3 May 2016, Seth Arnold wrote:

On Wed, May 04, 2016 at 12:05:16AM +0000, Brandon Dees wrote:
is it appropriate to ask if the same issues are present in GraphicsMagick
as well?

I haven't investigated deeply but it seems very plausible to me:
Here's the delegates.xml work-alike:
https://sourceforge.net/p/graphicsmagick/code/ci/default/tree/config/delegates.mgk.in

This appears to be executed via:
https://sourceforge.net/p/graphicsmagick/code/ci/default/tree/magick/delegate.c
which tries to escape arguments using UnixShellTextEscape(). This function
appears to replace \`"$ chars with backslash-escaped versions. I'm not
sure this is a safe mechanism either.

Please provide me with a working exploit.

Be aware that this quoting method is only used for the few delegates.mgk rules which require shell-like syntax to work. Otherwise the external program is run using execvp() without a shell.

I am aware that the handling for Microsoft Windows is not quite secure and in fact Windows concatentates all the spawnvp() vector arguments into one long string and each program parses command line arguments using its own algorithm without a secure quoting mechanism so command-line programs can never possibly be secured.

In order to achieve the best security with GraphicsMagick (with some possible loss of function due to missing file formats), please define this environment variable:

  MAGICK_CODER_STABILITY=PRIMARY

Use 'gm convert -list formats' and check the second column of output to see what formats are classified as Primary, Stable, and Unstable. Primary formats are considered common and trustworthy.

There is also a way that C/C++ programs using the libraries can bless the files which will be accessed before the access occurs (not yet controlled by a configuration file).

Thanks,

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


Current thread: