1 http://www.openwall.com/lists/oss-security/2016/05/29/7
3 Date: Sun, 29 May 2016 15:03:10 -0500 (CDT)
4 From: Bob Friesenhahn <bfriesen@...ple.dallas.tx.us>
5 To: oss security list <oss-security@...ts.openwall.com>
6 Subject: CVE Request: GraphicsMagick and ImageMagick popen() shell vulnerability
9 All existing releases of GraphicsMagick and ImageMagick support a file
10 open syntax where if the first character of the file specification is
11 a '|', then the remainder of the filename is passed to the shell for
12 execution using the POSIX popen(3C) function. File opening is handled
13 by an OpenBlob() function in the source file blob.c. Unlike the
14 vulnerability described by CVE-2016-3714, this functionality is
15 supported by the core file opening function rather than a delegates
16 subsystem usually used to execute external programs.
18 The funtionality can be demonstrated as follows:
21 % convert '|echo Hello > hello.txt;' null:
25 The same weakness in the native SVG readers may be used to provoke
26 this problem. This example returns a valid image given a known file
27 (but an actual file is not necessary):
29 <?xml version="1.0" standalone="no"?>
30 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
31 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
32 <svg width="4in" height="3in" version="1.1"
33 xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
34 <desc>Illustrates how a shell command may be embedded in a SVG.
36 <image x="200" y="200" width="100px" height="100px"
37 xlink:href="|echo Hello > hello.txt; cat /usr/lib/firefox/browser/icons/mozicon128.png">
38 <title>My image</title>
46 image copy 200,200 100,100 "|echo Hello > hello.txt; cat /usr/lib/firefox/browser/icons/mozicon128.png"
49 Previously supplied recommended patches for GraphicsMagick do
50 successfully block this attack vector in SVG and MVG.
52 It is highly likely that there are many paths leading to a suitable
53 filename which may be executed outside of SVG and MVG since the
54 software is quite complex and powerful. The examples above are not
55 meant to suggest that other avenues to the same weakness are not
58 The simple solution to the problem is to disable the popen support
59 (HAVE_POPEN) in GraphicsMagick's magick/blob.c as is done by the
62 This issue was discovered by Bob Friesenhahn, of the GraphicsMagick
68 bfriesen@...ple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
69 GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
70 diff -r 33200fc645f6 magick/blob.c
71 --- a/magick/blob.c Sat Nov 07 14:49:16 2015 -0600
72 +++ b/magick/blob.c Sun May 29 14:12:57 2016 -0500
75 #define DefaultBlobQuantum 65541