• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3
4
5<!DOCTYPE html>
6<html lang="en">
7<head>
8    <title>ImageMagick: Security Policy</title>
9  <meta charset="utf-8" />
10  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
11  <meta name="viewport" content="width=device-width, initial-scale=1" />
12  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
13  <meta name="application-name" content="ImageMagick"/>
14  <meta name="description" content="ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves."/>
15  <meta name="application-url" content="http://www.imagemagick.org"/>
16  <meta name="generator" content="PHP"/>
17  <meta name="keywords" content="security, policy, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert"/>
18  <meta name="rating" content="GENERAL"/>
19  <meta name="robots" content="INDEX, FOLLOW"/>
20  <meta name="generator" content="ImageMagick Studio LLC"/>
21  <meta name="author" content="ImageMagick Studio LLC"/>
22  <meta name="revisit-after" content="2 DAYS"/>
23  <meta name="resource-type" content="document"/>
24  <meta name="copyright" content="Copyright (c) 1999-2016 ImageMagick Studio LLC"/>
25  <meta name="distribution" content="Global"/>
26  <meta name="magick-serial" content="P131-S030410-R485315270133-P82224-A6668-G1245-1"/>
27  <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
28  <link rel="icon" href="../images/wand.png"/>
29  <link rel="shortcut icon" href="../images/wand.ico"/>
30  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Roboto:900,400,400italic,700,700italic,300,300italic|Open+Sans:300italic,400italic,700italic,300,400,600,700">
31  <link rel="stylesheet" href="css/magick.css"/>
32</head>
33<body>
34<div class="main">
35<div class="magick-masthead">
36  <div class="container">
37    <script async="async" src="http://localhost/pagead/js/adsbygoogle.js"></script>    <ins class="adsbygoogle"
38         style="display:block"
39         data-ad-client="ca-pub-3129977114552745"
40         data-ad-slot="6345125851"
41         data-ad-format="auto"></ins>
42    <script>
43      (adsbygoogle = window.adsbygoogle || []).push({});
44    </script>
45    <nav class="magick-nav">
46      <a class="magick-nav-item " href="../index.html">Home</a>
47      <a class="magick-nav-item " href="binary-releases.html">Download</a>
48      <a class="magick-nav-item " href="command-line-tools.html">Tools</a>
49      <a class="magick-nav-item " href="command-line-processing.html">Command-line</a>
50      <a class="magick-nav-item " href="resources.html">Resources</a>
51      <a class="magick-nav-item " href="api.html">Develop</a>
52      <a class="magick-nav-item " href="http://www.imagemagick.org/script/search.php">Search</a>
53      <a class="magick-nav-item pull-right" href="https://www.imagemagick.org/discourse-server/">Community</a>
54    </nav>
55  </div>
56</div>
57<div class="container">
58<div class="magick-header">
59<p class="lead magick-description">ImageMagick includes a security policy configuration file, <code>policy.xml</code>. It is useful for limiting the resources consumed by ImageMagick and can help prevent a denial-of-service or other exploits.</p>
60
61<p>As an example, suppose you download an image from the internet and unbeknownst to you its been crafted to generate a 20000 by 20000 pixel image. ImageMagick attempts to allocate enough resources (memory, disk) and your system will likely deny the resource request and exit. However, its also possible that your computer might be temporarily sluggish or unavailable or ImageMagick may abort. To prevent such a scenario, you can set limits in the <code>policy.xml</code> configuration file. You may ask why ImageMagick does not already include reasonable limits? Simply because what is reasonable in your environment, might not be reasonable to someone else. We, for example, have access to a host with 1TB of memory whereas you may be running ImageMagick on an iPhone. If you utilize ImageMagick from a public website, you may want to increase security by preventing usage of the MVG or HTTPS coders. Only you can decide what are reasonable limits taking in consideration your environment. We provide this policy with reasonable limits and encourage you to use as a template for your own policy:</p>
62
63<pre class="pre-scrollable">
64&lt;policymap>
65  &lt;policy domain="resource" name="temporary-path" value="/tmp"/>
66  &lt;policy domain="resource" name="memory" value="256MiB"/>
67  &lt;policy domain="resource" name="map" value="512MiB"/>
68  &lt;policy domain="resource" name="width" value="8KP"/>
69  &lt;policy domain="resource" name="height" value="8KP"/>
70  &lt;policy domain="resource" name="area" value="128MB"/>
71  &lt;policy domain="resource" name="disk" value="1GiB"/>
72  &lt;policy domain="resource" name="file" value="768"/>
73  &lt;policy domain="resource" name="thread" value="2"/>
74  &lt;policy domain="resource" name="throttle" value="0"/>
75  &lt;policy domain="resource" name="time" value="120"/>
76  &lt;policy domain="system" name="precision" value="6"/>
77  &lt;policy domain="cache" name="shared-secret" stealth="true" value="replace with your secret phrase"/>
78  &lt;policy domain="coder" rights="none" pattern="MVG" />
79  &lt;policy domain="delegate" rights="none" pattern="HTTPS" />  <!--  prevent 'curl' program from reading HTTPS URL's -->
80  &lt;policy domain="path" rights="none" pattern="@*"/>  <!-- indirect reads not permitted -->
81&lt;/policymap>
82</pre>
83
84<p>Since we process multiple simultaneous sessions, we do not want any one session consuming all the available memory.With this policy, large images are cached to disk. If the image is too large and exceeds the pixel cache disk limit, the program exits. In addition, we place a time limit to prevent any run-away processing tasks. If any one image has a width or height that exceeds 8192 pixels, an exception is thrown and processing stops. As of ImageMagick 7.0.1-8 and 6.9.4-6, you can prevent the use of any delegate or all delegates (set the pattern to "*"). Note, prior to these releases, use a domain of <code>coder</code> to prevent delegate usage (e.g. <code>domain="coder" rights="none" pattern="HTTPS"</code>). The policy also prevents indirect reads. If you want to, for example, read text from a file (e.g. <code>caption:@myCaption.txt</code>), you'll need to remove this policy.</p>
85
86<p>Here is what you can expect when you restrict the HTTPS coder, for example:</p>
87
88<pre>
89$ convert https://www.imagemagick.org/images/wizard.png wizard.jpg
90convert: not authorized `HTTPS'
91convert: unable to open file: No such file or directory
92convert: no images defined `wizard.jpg'
93</pre>
94
95<p>You can verify your policy changes are in effect with this command:</p>
96
97<pre class="pre-scrollable">
98-> identify -list policy
99Path: ImageMagick/policy.xml
100  Policy: Resource
101    name: time
102    value: 120
103  Policy: Resource
104    name: throttle
105    value: 0
106  Policy: Resource
107    name: thread
108    value: 2
109  Policy: Resource
110    name: file
111    value: 768
112  Policy: Resource
113    name: disk
114    value: 1GiB
115  Policy: Resource
116    name: map
117    value: 512MiB
118  Policy: Resource
119    name: memory
120    value: 256MiB
121  Policy: Resource
122    name: area
123    value: 128MB
124  Policy: Resource
125    name: height
126    value: 8KP
127  Policy: Resource
128    name: width
129    value: 8KP
130  Policy: Resource
131    name: temporary-path
132    value: /tmp
133  Policy: System
134    name: precision
135    value: 6
136  Policy: Cache
137    name: shared-secret
138    value: My voice is my passport.  Verify me.
139  Policy: Path
140    rights: None
141    pattern: @*
142
143Path: [built-in]
144  Policy: Undefined
145    rights: None
146</pre>
147
148<p>For additional details about resource limits and the policy configuration file, read <a href="resources.html">Resources</a> and <a href="architecture.html">Architecture</a>.</p>
149</div>
150  <footer class="magick-footer">
151    <p><a href="support.html">Donate</a> •
152     <a href="sitemap.html">Sitemap</a> •
153    <a href="links.html">Related</a> •
154    <a href="security-policy.html">Security</a> •
155    <a href="architecture.html">Architecture</a>
156</p>
157    <p><a href="security-policy.html#">Back to top</a> •
158    <a href="http://pgp.mit.edu:11371/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
159    <a href="http://www.imagemagick.org/script/contact.php">Contact Us</a></p>
160        <p><small>©  1999-2016 ImageMagick Studio LLC</small></p>
161  </footer>
162</div><!-- /.container -->
163
164  <script src="https://localhost/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
165  <script src="../js/magick.html"></script>
166</div>
167</body>
168</html>
169