]> git.pld-linux.org Git - packages/GraphicsMagick.git/blob - CVE-2016-5118.patch
CVE-2016-5118 fix
[packages/GraphicsMagick.git] / CVE-2016-5118.patch
1 http://www.openwall.com/lists/oss-security/2016/05/29/7
2
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
7  via filename
8
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.
17
18 The funtionality can be demonstrated as follows:
19
20    % rm -f hello.txt
21    % convert '|echo Hello > hello.txt;' null:
22    % ls hello.txt
23    hello.txt
24
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):
28
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.
35    </desc>
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>
39    </image>
40    </svg>
41
42 Or in MVG:
43
44    push graphic-context
45    viewbox 0 0 640 480
46    image copy 200,200 100,100 "|echo Hello > hello.txt; cat /usr/lib/firefox/browser/icons/mozicon128.png"
47    pop graphic-context
48
49 Previously supplied recommended patches for GraphicsMagick do 
50 successfully block this attack vector in SVG and MVG.
51
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 
56 available.
57
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 
60 attached patch.
61
62 This issue was discovered by Bob Friesenhahn, of the GraphicsMagick
63 project.
64
65 Bob
66 -- 
67 Bob Friesenhahn
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
73 @@ -68,6 +68,7 @@
74  */
75  #define DefaultBlobQuantum  65541
76  
77 +#undef HAVE_POPEN
78  
79  /*
80    Enum declarations. 
This page took 0.071656 seconds and 3 git commands to generate.