Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Bob Friesenhahn <bfriesen-5sZYcfUBRGG5emyz223a33NtEUiqdi9I <at> public.gmane.org>
Subject: CVE Request: GraphicsMagick and ImageMagick popen() shell vulnerability via filename
Newsgroups: gmane.comp.security.oss.general
Date: Sunday 29th May 2016 20:03:10 UTC (about 1 year ago)
All existing releases of GraphicsMagick and ImageMagick support a file
open syntax where if the first character of the file specification is
a '|', then the remainder of the filename is passed to the shell for
execution using the POSIX popen(3C) function.  File opening is handled
by an OpenBlob() function in the source file blob.c.  Unlike the
vulnerability described by CVE-2016-3714, this functionality is
supported by the core file opening function rather than a delegates
subsystem usually used to execute external programs.

The funtionality can be demonstrated as follows:

   % rm -f hello.txt
   % convert '|echo Hello > hello.txt;' null:
   % ls hello.txt
   hello.txt

The same weakness in the native SVG readers may be used to provoke
this problem.  This example returns a valid image given a known file 
(but an actual file is not necessary):

   
   http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
   http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
   Illustrates how a shell command may be embedded in a SVG.
   
   
   My image
   
   

Or in MVG:

   push graphic-context
   viewbox 0 0 640 480
   image copy 200,200 100,100 "|echo Hello > hello.txt; cat
/usr/lib/firefox/browser/icons/mozicon128.png"
   pop graphic-context

Previously supplied recommended patches for GraphicsMagick do 
successfully block this attack vector in SVG and MVG.

It is highly likely that there are many paths leading to a suitable 
filename which may be executed outside of SVG and MVG since the 
software is quite complex and powerful.  The examples above are not 
meant to suggest that other avenues to the same weakness are not 
available.

The simple solution to the problem is to disable the popen support 
(HAVE_POPEN) in GraphicsMagick's magick/blob.c as is done by the 
attached patch.

This issue was discovered by Bob Friesenhahn, of the GraphicsMagick
project.

Bob
-- 
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
 
CD: 4ms