Debian Codegraph @

www/security-policy/index.html

raw symbols ◀ ▶ SCIP
4 Debian patches touch this file
1
2
3 <!DOCTYPE html>
4 <html lang="en" data-bs-theme="dark">
5
6
7 <head>
•8 <meta charset="utf-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
10 <title>ImageMagick | Security Policy</title>
•11 <meta name="description" content="Establish a security policy suitable for your local environment before utilizing ImageMagick." />
12 <link rel="canonical" href="index.html" />
13 <meta name="robots" content="index, follow" />
14 <meta name="theme-color" content="#000000" />
15 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
•16 <link rel="shortcut icon" href="../image/wand.png" type="image/png" />
17 <link rel="apple-touch-icon" href="../image/wand.png" type="image/png" />
18 <link rel="preconnect" href="https://localhost/" />
19 <link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" as="style" crossorigin="anonymous" />
20 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" crossorigin="anonymous" />
21 <!-- Accessibility Enhancement -->
22 <style>
23 html {
24 scroll-padding-top: 70px;
25 }
26
27 a.nav-link:hover,
28 a.dropdown-item:hover {
29 color: #ffc107 !important;
30 text-shadow: 0px 2px 4px rgba(255, 193, 7, 0.8);
31 }
32
33 .btn-outline-warning {
34 color: #cd7f32;
35 border-color: #cd7f32;
36 }
37
38 .navbar-brand {
39 color: #d4af37;
40 transition: color 0.3s ease, text-shadow 0.3s ease;
41 }
42
43 .navbar-brand:hover {
44 color: #e9c03d;
45 text-shadow: 0px 2px 4px rgba(203, 163, 120, 0.6);
46 }
47
48 :root {
49 --bs-code-color: revert;
50 }
51 </style>
52 <!-- Open Graph Meta Tags -->
•53 <meta property="og:title" content="ImageMagick | Security Policy" />
54 <meta property="og:description" content="Establish a security policy suitable for your local environment before utilizing ImageMagick." />
•55 <meta property="og:image" content="https://imagemagick.org/image/logo.png" />
56 <meta property="og:logo" content="https://imagemagick.org/image/logo.png" />
57 <meta property="og:url" content="https://imagemagick.org/security-policy/" />
•58 <meta property="og:type" content="website" />
59 <meta property="og:site_name" content="ImageMagick" />
60 <meta property="og:locale" content="en_us" />
61 <!-- Twitter Card Meta Tags -->
•62 <meta name="twitter:card" content="summary_large_image" />
63 $site=strtolower("ImageMagick");
•64 <meta name="twitter:site" content="@imagemagick" />
65 <meta name="twitter:creator" content="@imagemagick" />
66 <meta name="twitter:title" content="ImageMagick | Security Policy" />
•67 <meta name="twitter:description" content="$this- />description" />
68 <meta name="twitter:image" content="https://imagemagick.org/image/logo.png" />
•69 <meta name="twitter:image:alt" content="ImageMagick logo and tag line" />
70 <!-- JSON-LD Structured Data -->
71 <script type="application/ld+json">
72 {
73 "@context": "https://schema.org",
74 "@type": "SoftwareApplication",
75 "name": "ImageMagick",
76 "url": "ImageMagick | Security Policy",
77 "image": "https://imagemagick.org/image/logo.png",
78 "description": "$this->description",
79 "applicationCategory": "Multimedia",
80 "operatingSystem": "Windows, macOS, Linux, Unix",
81 "softwareVersion": "7.1.2-27",
82 "license": "https://imagemagick.org/license/",
83 "creator": {
84 "@type": "Organization",
85 "name": "ImageMagick Studio LLC",
86 "url": "https://imagemagick.org"
87 },
88 "keywords": [
89 "".ucfirst($title)."",
90 "image processing software",
91 "image conversion tool",
92 "batch image editing",
93 "open-source image editor",
94 "ImageMagick command-line",
95 "resize images ImageMagick",
96 "crop and rotate images",
97 "ImageMagick tutorial",
98 "ImageMagick automation",
99 "ImageMagick for developers",
100 "ImageMagick CLI",
101 "ImageMagick filters and effects",
102 "ImageMagick scripting",
103 "ImageMagick API integration"
104 ],
105 "sameAs": [
106 "https://github.com/ImageMagick",
107 "https://x.com/imagemagick"
108 ],
109 "offers": {
110 "@type": "Offer",
111 "price": "0.00",
112 "priceCurrency": "USD"
113 }
114 }
115 </script>
116 <!-- Google Custom Search -->
•117 <script async="true" src="https://localhost/cse.js?cx=8720b81722164487b"></script>
118 <script async="true" src="https://localhost/pagead/js/adsbygoogle.js?client=ca-pub-3129977114552745" crossorigin="anonymous"></script>
119 </head>
120
121 <body>
122 <script>
123 function setTheme(theme) {
124 localStorage.setItem('theme', theme);
125 updateThemeIcon(theme);
126 document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? getSystemTheme() : theme);
127 }
128 function getSystemTheme() {
129 return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
130 }
131 function updateThemeIcon(theme) {
132 const iconMap = {
133 light: '☀️',
134 dark: '🌙',
135 auto: '🌓'
136 };
137 document.getElementById('currentThemeIcon').textContent = iconMap[theme] || '🌓';
138 }
139 document.addEventListener('DOMContentLoaded', () => {
140 const savedTheme = localStorage.getItem('theme') || 'auto';
141 setTheme(savedTheme);
142 });
143 </script>
144 <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
145 <div class="container-fluid">
146 <a class="navbar-brand fw-bold" href="../index-2.html" title="ImageMagick">ImageMagick</a>
147 <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#magick-navbars" aria-controls="magick-navbars" aria-expanded="false" aria-label="Toggle navigation">
148 <span class="navbar-toggler-icon"></span>
149 </button>
150
151 <div class="collapse navbar-collapse" id="magick-navbars">
152 <ul class="navbar-nav me-auto">
153 <li class="nav-item">
•154 <a class="nav-link" href="../download/index.html">Download</a>
155 </li>
156 <li class="nav-item">
•157 <a class="nav-link" href="../command-line-tools/index.html">Tools</a>
158 </li>
159 <li class="nav-item">
•160 <a class="nav-link" href="../command-line-processing/index.html">CLI</a>
161 </li>
162 <li class="nav-item">
•163 <a class="nav-link" href="../develop/index.html">Develop</a>
164 </li>
165 <li class="nav-item">
166 <a class="nav-link" rel="noopener noreferrer" target="_blank" href="https://github.com/ImageMagick/ImageMagick/discussions">Community</a>
167 </li>
168 </ul>
169 <ul class="navbar-nav ms-auto">
170 <li class="nav-item ms-3">
171 <form class="d-flex form-inline" action="https://imagemagick.org/security-policy/">
•172 <input class="form-control me-2" type="text" name="q" placeholder="Search site..." aria-label="Search" />
173 <button class="btn btn-outline-warning" type="submit" name="sa">Search</button>
174 </form>
175 </li>
176 <li class="nav-item dropdown ms-3">
177 <a class="nav-link dropdown-toggle" href="#" id="themeDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
178 <span id="currentThemeIcon">🌓</span>
179 </a>
180 <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="themeDropdown">
181 <li><a class="dropdown-item" href="#" onclick="setTheme('light')">☀️ Light</a></li>
182 <li><a class="dropdown-item" href="#" onclick="setTheme('dark')">🌙 Dark</a></li>
183 <li><a class="dropdown-item" href="#" onclick="setTheme('auto')">🌓 Auto</a></li>
184 </ul>
185 </li>
186 </ul>
187 </div>
188 </div>
189 </nav>
190
191 <div class="col-lg-8 mx-auto text-body-secondary pt-5 pt-lg-5">
192 <header class="d-flex align-items-center pb-3 mb-5 border-bottom">
193 <div class="mt-3 ms-3">
194 <a href="../index-2.html" class="text-decoration-none">
195 <h1 class="fs-2 mb-1 display-5">Security Policy</h1>
196 </a>
197 <h2 class="fs-5 text-muted h4">ImageMagick</h2>
198 </div>
199 </header>
200
201 <main role="main" class="container">
202 <div class="row g-5">
203 <div class="col-md-9">
204 <div>
205 <p class="text-center"><a href="#policy">Security Policy </a> • <a href="#example">Example Security Policy</a> • <a href="#synchronize">Pixel Cache Synchronize Policy</a> • <a href="#zero-configuration">Zero Configuration Security Policy</a> • <a href="#other">Other Security Considerations</a></p>
206
207 <div class="alert alert-success" role="alert">
208 <h4 class="alert-heading">ImageMagick Security Policy</h4>
209 <p>Establish a security policy suitable for your local environment before utilizing ImageMagick. ImageMagick’s security model is “everything allowed unless denied,” and the last matching policy wins. Be careful when adding new rules: any later policy can override earlier denies or allows. Place broad deny rules first, followed by specific exceptions, and review ordering to avoid accidental authorization.</p>
210 </div>
211
212 <p class="lead">ImageMagick is intentionally open by default, and that design choice reflects its primary use in controlled environments such as Docker containers or other sandboxed deployments.</p>
213 <p>Security always involves balancing protection against potential vulnerabilities with the practical need to get work done. In ImageMagick, the security policy is the mechanism that lets you tune that balance. It acts as the control point between strict lockdown and operational convenience, allowing you to decide which features, coders, and operations are permitted in your environment.</p>
214 <p>A well‑designed policy can:</p>
215 <ul>
216 <li>Limit or disable high‑risk coders and operations.</li>
217 <li>Constrain resource usage to prevent abuse.</li>
218 <li>Define exactly what types of input ImageMagick is allowed to process.</li>
219 <li>Adapt the system to your threat model rather than forcing a one‑size‑fits‑all configuration.</li>
220 </ul>
221 <p>This flexibility is intentional. ImageMagick ships in an open state so it can be embedded into controlled environments, containers, pipelines, or isolated servers, where administrators can then tighten the policy to match their needs. <strong class="text-warning">The more untrusted input you expect to handle, the more restrictive your policy should be</strong>.</p>
222
223 <p>To ensure optimal security, you can restrict ImageMagick to only reading or writing web-safe image formats like GIF, JPEG, and PNG. Alternatively, you can customize the security policy to fit the needs of your local environment or organizational policies. This policy can include details such as memory usage limits, allowed paths for reading and writing, limits on the number of images in a sequence, maximum workflow runtime, allowed disk space for image pixels, a secret passphrase for remote connections, and which coders are permitted or denied. By customizing the security policy, you can help secure your environment and ensure that ImageMagick is a responsible member of your local system, such as by preventing overloading with large images.</p>
224
225 <p>It is important to set limits on ImageMagick's resource usage to prevent potentially harmful situations. For example, if you accidentally download an image from the internet that has been crafted to generate a very large image (e.g., 20000 by 20000 pixels), ImageMagick may try to allocate the necessary resources (such as memory and disk space) and your system may deny the request or cause the program to exit. Alternatively, your computer may become temporarily slow or unresponsive, or ImageMagick may be forced to abort. To avoid such situations, you can set limits in the <a href="../source/policy-open.xml">policy.xml</a> configuration file.</p>
226
227 <p>Keep in mind that what is considered reasonable for one environment may not be suitable for another. For example, you may have ImageMagick sandboxed in a secure environment, while someone else may use it to process images on a publicly accessible website. Or, ImageMagick may be running on a host with a lot of memory, while another instance is running on a device with limited resources. In the case of the host with large memory, it may make sense to allow large image processing, but not on the device with limited resources. If you are using ImageMagick on a public website, you may want to increase security by disabling certain coders such as MVG or HTTPS.</p>
228
229 <p>To help you get started, as of version 7.1.1-16, ImageMagick provides security polices that you can select when installing ImageMagick. Choose from:</p>
230
231 <ul>
232 <dt><a href="../source/policy-open.xml">open</a></dt>
233 <dd>The default policy for ImageMagick installations is the open security policy. This policy is designed for usage in secure settings like those protected by firewalls or within Docker containers. Within this framework, ImageMagick enjoys broad access to resources and functionalities. This policy provides convenient and adaptable options for image manipulation. However, it's important to note that it might present security vulnerabilities in less regulated conditions. Thus, organizations should thoroughly assess the appropriateness of the open policy according to their particular use case and security prerequisites. </dd>
234 <dt><a href="../source/policy-limited.xml">limited</a></dt>
•235 <dd>The primary objective of the limited security policy is to find a middle ground between convenience and security. This policy involves the deactivation of potentially hazardous functionalities, like specific coders such as SVG or HTTP. Furthermore, it establishes several constraints on the utilization of resources like memory, storage, and processing duration, all of which are adjustable. This policy proves advantageous in situations where there's a need to mitigate the potential threat of handling possibly malicious or demanding images, all while retaining essential capabilities for prevalent image formats.</dd>
236 <dt><a href="../source/policy-secure.xml">secure</a></dt>
•237 <dd>This stringent security policy prioritizes the implementation of rigorous controls and restricted resource utilization to establish a profoundly secure setting while employing ImageMagick. It deactivates conceivably hazardous functionalities, including specific coders like SVG or HTTP. The policy promotes the tailoring of security measures to harmonize with the requirements of the local environment and the guidelines of the organization. This protocol encompasses explicit particulars like limitations on memory consumption, sanctioned pathways for reading and writing, confines on image sequences, the utmost permissible duration of workflows, allocation of disk space intended for image data, and even an undisclosed passphrase for remote connections. By adopting this robust policy, entities can elevate their overall security stance and alleviate potential vulnerabilities.</dd>
238 <dt><a href="../source/policy-websafe.xml">websafe</a></dt>
239 <dd> This security protocol designed for web-safe usage focuses on situations where ImageMagick is applied in publicly accessible contexts, like websites. It deactivates the capability to read from or write to any image formats other than web-safe formats like GIF, JPEG, and PNG. Additionally, this policy prohibits the execution of image filters and indirect reads, thereby thwarting potential security breaches. By implementing these limitations, the web-safe policy fortifies the safeguarding of systems accessible to the public, reducing the risk of exploiting ImageMagick's capabilities for potential attacks.</dd>
240 </ul>
241 <p>Under Linux, select the policy with the <code>--with-security-policy={open, limited, secure, websafe}</code> configure script option. Under Windows, the choice is presented when you run the configure app.</p>
242
243 <p>We encourage you to review each rule in your <code>policy.xml</code> configuration file. Adjust the parameters according to your organization's requirements. You can modify the allowed image formats, set specific paths, and restrict certain operations based on your security needs. Remember that customizing the security policy is a delicate balance between functionality and security. Overly restrictive policies might hinder legitimate image processing tasks, while overly permissive policies can introduce vulnerabilities.</p>
244
245 <p>Doyensec provides a policy evaluator tool that can assist you in designing and auditing your security policy. The tool is found at <a href="https://imagemagick-secevaluator.doyensec.com/">imagemagick-secevaluator.doyensec.com</a>.</p>
246
247 <h2><a class="anchor" id="example"></a>Example Security Policy</h2>
248
249 <p>Here is an example security policy:</p>
250
251 <pre class="overflow-auto p-3 mb-2 text-body-secondary bg-body-tertiary" style="max-height:75svh;"><code>&lt;?xml version="1.0" encoding="UTF-8"?>
252 &lt;!DOCTYPE policymap [
253 &lt;!ELEMENT policymap (policy)*>
254 &lt;!ATTLIST policymap xmlns CDATA #FIXED "">
255 &lt;!ELEMENT policy EMPTY>
256 &lt;!ATTLIST policy xmlns CDATA #FIXED "">
257 &lt;!ATTLIST policy domain NMTOKEN #REQUIRED>
258 &lt;!ATTLIST policy name NMTOKEN #IMPLIED>
259 &lt;!ATTLIST policy pattern CDATA #IMPLIED>
260 &lt;!ATTLIST policy rights NMTOKEN #IMPLIED>
261 &lt;!ATTLIST policy stealth NMTOKEN #IMPLIED>
262 &lt;!ATTLIST policy value CDATA #IMPLIED>
263 ]>
264 &lt;!--
265 Creating a security policy that fits your specific local environment
266 before making use of ImageMagick is highly advised. You can find guidance on
267 setting up this policy at https://imagemagick.org/security-policy/,
268 and it's important to verify your policy using the validation tool located
269 at https://imagemagick-secevaluator.doyensec.com/. We also strongly
270 recommend that all users validate their security assumptions by testing their
271 configurations after making any policy changes. This helps ensure that the
272 intended restrictions are functioning as expected in their specific
273 deployment environment.
274
275
276 Web-safe ImageMagick security policy:
277
278 This security protocol designed for web-safe usage focuses on situations
279 where ImageMagick is applied in publicly accessible contexts, like websites.
280 It deactivates the capability to read from or write to any image formats
281 other than web-safe formats like GIF, JPEG, and PNG. Additionally, this
282 policy prohibits the execution of image filters and indirect reads, thereby
283 thwarting potential security breaches. By implementing these limitations,
284 the web-safe policy fortifies the safeguarding of systems accessible to
285 the public, reducing the risk of exploiting ImageMagick's capabilities
286 for potential attacks.
287 -->
288 &lt;policymap>
289 &lt;!-- Set maximum parallel threads. -->
290 &lt;policy domain="resource" name="thread" value="2"/>
291 &lt;!-- Set maximum time in seconds or neumonics, e.g. "2 minutes". When this
292 limit is exceeded, an exception is thrown and processing stops. -->
293 &lt;policy domain="resource" name="time" value="60"/>
294 &lt;!-- Set maximum number of open pixel cache files. When this limit is
295 exceeded, any subsequent pixels cached to disk are closed and reopened
296 on demand. -->
297 &lt;policy domain="resource" name="file" value="768"/>
298 &lt;!-- Set maximum amount of memory in bytes to allocate for the pixel cache
299 from the heap. When this limit is exceeded, the image pixels are cached
300 to memory-mapped disk. -->
301 &lt;policy domain="resource" name="memory" value="256MiB"/>
302 &lt;!-- Set maximum amount of memory map in bytes to allocate for the pixel
303 cache. When this limit is exceeded, the image pixels are cached to
304 disk. -->
305 &lt;policy domain="resource" name="map" value="512MiB"/>
306 &lt;!-- Set the maximum width * height of an image that can reside in the pixel
307 cache memory. Images that exceed the area limit are cached to disk. -->
308 &lt;policy domain="resource" name="area" value="16KP"/>
309 &lt;!-- Set maximum amount of disk space in bytes permitted for use by the pixel
310 cache. When this limit is exceeded, the pixel cache is not be created
311 and an exception is thrown. -->
312 &lt;policy domain="resource" name="disk" value="1GiB"/>
313 &lt;!-- Set the maximum length of an image sequence. When this limit is
314 exceeded, an exception is thrown. -->
315 &lt;policy domain="resource" name="list-length" value="16"/>
316 &lt;!-- Set the maximum width of an image. When this limit is exceeded, an
317 exception is thrown. -->
318 &lt;policy domain="resource" name="width" value="4KP"/>
319 &lt;!-- Set the maximum height of an image. When this limit is exceeded, an
320 exception is thrown. -->
321 &lt;policy domain="resource" name="height" value="4KP"/>
322 &lt;!-- Periodically yield the CPU for at least the time specified in
323 milliseconds. -->
324 &lt;policy domain="resource" name="throttle" value="2"/>
325 &lt;!-- Dynamically yield the CPU relative to the system load average. -->
326 &lt;policy domain="resource" name="dynamic-throttle" value="false"/>
327 &lt;!-- Do not create temporary files in the default shared directories, instead
328 specify a private area to store only ImageMagick temporary files. -->
329 &lt;!-- <policy domain="resource" name="temporary-path" value="/magick/tmp"/> -->
330 &lt;!-- Force memory initialization by memory mapping select memory
331 allocations. -->
332 &lt;policy domain="cache" name="memory-map" value="anonymous"/>
333 &lt;!-- Ensure all image data is fully flushed and synchronized to disk. -->
334 &lt;policy domain="cache" name="synchronize" value="true"/>
335 &lt;!-- Replace passphrase for secure distributed processing -->
336 &lt;!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> -->
337 &lt;!-- Do not permit any external delegates to execute. -->
338 &lt;policy domain="delegate" rights="none" pattern="*"/>
339 &lt;!-- Do not permit any image filters to load. -->
340 &lt;policy domain="filter" rights="none" pattern="*"/>
341 &lt;!-- Don't read/write from/to stdin/stdout. -->
342 &lt;policy domain="path" rights="none" pattern="-"/>
343 &lt;policy domain="path" rights="none" pattern="[Ff][Dd]:*"/>
344 &lt;!-- Sensitive paths are not permitted. -->
345 &lt;policy domain="path" rights="none" pattern="/etc/*"/>
346 &lt;!-- Relative paths are not permitted. -->
347 &lt;policy domain="path" rights="none" pattern="*../*"/>
348 &lt;!-- Indirect reading is not permitted. -->
349 &lt;policy domain="path" rights="none" pattern="@*"/>
350 &lt;!-- Deny all image modules and specifically exempt reading or writing
351 web-safe image formats. -->
352 &lt;policy domain="module" rights="none" pattern="*" />
353 &lt;policy domain="module" rights="read | write" pattern="{GIF,JPEG,PNG,WEBP}" />
354 &lt;!-- This policy sets the number of times to replace content of certain
355 memory buffers and temporary files before they are freed or deleted. -->
356 &lt;policy domain="system" name="shred" value="1"/>
357 &lt;!-- Enable the initialization of buffers with zeros, resulting in a minor
358 performance penalty but with improved security. -->
359 &lt;policy domain="system" name="memory-map" value="anonymous"/>
360 &lt;!-- Set the maximum amount of memory in bytes that is permitted for
361 allocation requests. -->
362 &lt;policy domain="system" name="max-memory-request" value="256MiB"/>
363 &lt;!-- If the basename of path is a symbolic link, the open fails -->
364 &lt;policy domain="system" name="symlink" rights="none" pattern="follow"/>
365 &lt;!-- Blocks all SVG entity‑substitution attempts by denying the svg:substitute-entities define -->
366 &lt;policy domain="system" name="svg" rights="none" pattern="substitute-entities"/>
367 &lt;/policymap></code></pre>
368
369 <p>To prevent one session from consuming all available memory when processing multiple sessions at the same time, large images are cached to disk with this policy. If an image exceeds the pixel cache disk limit, the program will exit. Additionally, a time limit has been set to prevent any processing tasks from running for too long. If an image has a width or height larger than 8192 pixels, or if an image sequence has more than 32 frames, processing will stop and an exception will be thrown.</p>
370
371 <p>Starting with ImageMagick 7.0.1-8, you can prevent the use of any external delegate or all external delegates (by setting the pattern to "*"). Prior to these releases, you can use the domain of <code>coder</code> and set rights to none and the glob pattern to HTTPS to prevent external delegate usage. Additionally, users are prevented from executing any image filters and from performing indirect reads. If you want to, for example, read text from a file (e.g. <code>caption:@myCaption.txt</code>), you'll need to disable this path policy.</p>
372
373 <p>Policy <a href="https://en.wikipedia.org/wiki/Glob_(programming)">glob patterns</a>, before ImageMagick 7.1.1-16, are <em>case sensitive</em>. To get expected behavior, coders and modules must be upper-case (e.g. "EPS" not "eps") or use a case-insensitive pattern such as <code>[Pp][Nn][Gg]</code>.</p>
374
375 <p>Here is what you can expect when you restrict the HTTPS coder, for example:</p>
376
377 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>$ magick https://imagemagick.org/image/wizard.png wizard.jpg
378 convert: attempt to perform an operation not allowed by the security policy `HTTPS'
379 convert: no images defined `wizard.jpg'</samp></pre>
380
381 <p>As of ImageMagick version 7.0.4-7, you can conveniently deny access to all external delegates and coders except for a small subset of proven web-safe image types. For example,</p>
382
383 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="delegate" rights="none" pattern="*" />
384 &lt;policy domain="module" rights="none" pattern="*" />
385 &lt;policy domain="module" rights="read | write" pattern="{GIF,JPEG,PNG,WEBP}" /></code></pre>
386
387 <p>The module policy enables or disables a complete module for both read or write. To just read or write an image format, use the coder policy instead. For example, we disable reading just a few Postscript related formats, however, you can still write them:</p>
388 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="coder" rights="write" pattern="{PDF,PS,PS2,PS3,XPS}" /></code></pre>
389
390 <p>As of ImageMagick 7.0.7-0, you can allocate the pixel cache and some internal buffers with anonymous memory mapping rather than from heap. As a consequence, the pixels are initialized to zero resulting in a minor performance penalty. You can also jumble the contents of certain memory buffers (requires version 7.1.0-38) and temporary files before they are freed or deleted. The shred value is the number of times to replace content with random data. For example,</p>
391 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="system" name="memory-map" value="anonymous"/>
392 &lt;policy domain="cache" name="memory-map" value="anonymous"/>
393 &lt;policy domain="system" name="shred" value="1"/></code></pre>
394 <p>For performance reasons, the first pass is fast by repeating the random sequence as necessary to overwrite the contents of the buffer or file. Subsequent passes are an order of magnitude slower, but generate cryptographically strong random bytes for the length of the buffer or file.</p>
395
396 <p>Some image processing algorithms (e.g. wavelet transform) might consume a substantial amount of memory to complete. ImageMagick maintains a separate memory pool for these large resource requests and as of 7.0.6-1 permits you to set a maximum request limit. If the limit is exceeded, the allocation is instead memory-mapped on disk. Here we limit the maximum memory request by policy:</p>
397 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="system" name="max-memory-request" value="256MiB"/> </code></pre>
398
399 <p>As of ImageMagick version 7.0.4-23, you can limit the maximum number of images in a sequence. For example, to limit an image sequence to at most 64 frames, use:</p>
400 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="resource" name="list-length" value="64"/></code></pre>
401
402 <p>Note, numeric values in policies are floating-point with an optional SI prefix (e.g., 10MiB).</p>
403
404 <p>For additional details about resource limits and the policy configuration file, read <a href="../resources/index.html">Resources</a> and <a href="../architecture/index.html">Architecture</a>.</p>
405
406 <p>As of ImageMagick 7.0.6-0, you can programmatically set the ImageMagick security policy with SetMagickSecurityPolicy() (MagickCore) or MagickSetSecurityPolicy() (MagickWand).</p>
407
408 <p>As of ImageMagick version 7.0.8-11, you can set a <code>module</code> security policy. For example, to prevent Postscript or PDF interpretation, use:</p>
409 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="module" rights="none" pattern="{ps,pdf,xps}/></code></pre>
410
411 <p>As of ImageMagick version 7.0-10-52, you can set a <code>font</code> policy. Specify a path to a Unicode font that ImageMagick defaults to whenever the user does not specify a font preference:</p>
412 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="system" name="font" value="/usr/share/fonts/arial-unicode.ttf"/></code></pre>
413
414 <p>Note, in file path glob patterns, use the backslash character (\) to escape characters that would otherwise be interpreted as special characters. For example:</p>
415 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="path" rights="none" pattern="c:\\\\*"/></code></pre>
416
417 <p>You can verify your policy changes are in effect with this command:</p>
418
419 <pre class="overflow-auto p-3 mb-2 text-body-secondary bg-body-tertiary" style="max-height:75svh;"><samp>$ magick identify -list policy
420 Path: ImageMagick-7/policy.xml
421 Policy: Cache
422 name: memory-map
423 value: anonymous
424 Policy: Cache
425 name: synchronize
426 value: true
427 Policy: Resource
428 name: list-length
429 value: 32
430 Policy: Resource
431 name: time
432 value: 120
433 Policy: Resource
434 name: thread
435 value: 2
436 Policy: Resource
437 name: file
438 value: 768
439 Policy: Resource
440 name: disk
441 value: 1GiB
442 Policy: Resource
443 name: map
444 value: 512MiB
445 Policy: Resource
446 name: memory
447 value: 256MiB
448 Policy: Resource
449 name: area
450 value: 16KP
451 Policy: Resource
452 name: height
453 value: 8KP
454 Policy: Resource
455 name: width
456 value: 8KP
457 Policy: Resource
458 name: temporary-path
459 value: /opt/tmp
460 Policy: Module
461 rights: Write
462 pattern: {HTTP,HTTPS,MVG,PS,PDF}
463 Policy: Filter
464 rights: None
465 pattern: *
466 Policy: Path
467 rights: None
468 pattern: @*
469 Policy: System
470 name: font
471 value: ImageMagick-7/arial-unicode.ttf
472
473 Path: [built-in]
474 Policy: Undefined
475 rights: None</samp></pre>
476 <p>Notice the <code>shared-secret</code> policy is not listed due to the <code>stealth</code> property.</p>
477
478
479 <h2><a class="anchor" id="synchronize"></a>Pixel Cache Synchronize Policy</h2>
480
•481 <p>When writing image pixels to disk, ImageMagick firsts preallocates the disk file, which is much faster than fully populating the file with zeros. To further increase performance, we memory-map the file on disk. With memory-mapping, we get an increase in performance (up to 5x), however, there remains a possibility that as the disk file is populated, it may run out of free space. The OS then throws a SIGBUS signal which prevents ImageMagick from continuing. To prevent a SIGBUS, use this security policy:</p>
482
483
484 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary">
485 &lt;policy domain="cache" name="synchronize" value="True"/>
486 </pre>
487
488 <p>Set to True to ensure all image data is fully flushed and synchronized to disk. There is a performance penalty, however, the benefits include ensuring a valid image file in the event of a system crash and early reporting if there is not enough disk space for the image pixel cache.</p>
489
490 <h2><a class="anchor" id="zero-configuration"></a>Zero Configuration Security Policy</h2>
491
492 <p>A zero configuration build of ImageMagick does not permit external configuration files. To define your security policy, you must instead edit the <code>MagickCore/policy-private.h</code> source module, add your policy statements, and then build the ImageMagick distribution. Here is an example zero configuration security policy:</p>
493
494 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>static const char
495 *ZeroConfigurationPolicy = \
496 "&lt;policymap> \
497 &lt;policy domain=\"module\" rights=\"none\" pattern=\"MVG\"/> \
498 &lt;/policymap>";</code></pre>
499
500 <h2><a class="anchor" id="other"></a>Other Security Considerations</h2>
501
502 <p>If you spot a vulnerability in ImageMagick, first determine if the vulnerability can be mitigated by the security policy. ImageMagick, by default, is open. Use the security policy to add constraints to meet the requirements of your local security governance. If you feel confident that the security policy does not address the vulnerability, post the vulnerability as a <a href="https://github.com/ImageMagick/ImageMagick/security/advisories/new">security advisory</a>. Most vulnerabilities are reviewed and resolved within 48 hours.</p>
503
•504 <p>There are several ways to keep ImageMagick safer:</p>
505 <ol>
506 <li>Use web-safe image formats: Limiting ImageMagick to only reading or writing web-safe image formats like GIF, JPEG, and PNG can help increase security.</li>
507
508 <li>Customize the security policy: You can customize the security policy to fit the needs of your local environment or organizational policies. This policy can cover aspects such as memory usage, allowable paths for reading and writing, the number of images allowed in a sequence, the maximum time a workflow can run, the amount of disk space allowed for image pixels, a secret passphrase for remote connections, and which coders are permitted or denied.</li>
509
510 <li>Set limits on resource usage: You can set limits on resources such as memory usage, disk space, and workflow runtime to prevent potentially harmful situations.</li>
511
512 <li>Use sandboxing: Sandboxing is a security technique that allows you to run a program in a restricted environment to prevent it from accessing sensitive information or making changes to the system.</li>
513
514 <li>Disable potentially dangerous coders: If you are using ImageMagick on a public website, you may want to increase security by disabling certain coders such as MVG or HTTPS.</li>
515
516 <li>Review <a href="../source/delegates.xml">delegates.xml</a> and disable by policy any that are not suitable in your environment. For those that remain, use <code>configure --with--frozenpaths=yes</code> to ensure that every delegate program uses an <strong>absolute pathname</strong>, for example <code>/usr/bin/gs</code> instead of <code>gs</code>, so that delegate resolution is deterministic and not dependent on the environment’s <code>PATH</code>.</li>
517
518 <li>Prevent execution of image filters and indirect reads: You can prevent users from executing image filters and performing indirect reads to increase security.</li>
519
520 <li>Use a current version of ImageMagick: It is important to use a current version of ImageMagick to take advantage of the latest security fixes and updates.</li>
521 </ol>
522
523 </div>
524
525 </div>
526 <div class="col-md-3">
527 <div class="container text-center my-3">
528 <a href="../image/wizard.png" rel="noopener noreferrer" target="_blank">
•529 <img alt="The Tao of the Spiritual Warrior" class="img-fluid img-thumbnail" height="1468" loading="lazy" src="../image/wizard.png" width="1104" />
530 </a>
531 <p class="mt-2"><iframe src="https://github.com/sponsors/ImageMagick/button" title="Sponsor ImageMagick" height="35" width="107" style="border: 0;"></iframe></p>
532 </div>
533 <div class="container text-center my-3">
•534 <script async="true" src="https://localhost/pagead/js/adsbygoogle.js?client=ca-pub-3129977114552745"
535 crossorigin="anonymous"></script>
536 <!-- Banner Ad -->
537 <ins class="adsbygoogle"
538 style="display:block"
539 data-ad-client="ca-pub-3129977114552745"
540 data-ad-slot="1083537442"
541 data-ad-format="auto"
542 data-full-width-responsive="true"></ins>
543 <script>
544 (adsbygoogle = window.adsbygoogle || []).push({});
545 </script>
546 </div>
547 </div>
548 </div>
549 <a aria-label="About ImageMagick" class="btn btn-outline-warning mt-3" href="../index-2.html">About ImageMagick</a>
550 </main><!-- /.container -->
551 <footer class="text-center pt-5 my-5 text-body-secondary border-top">
552 <div class="container-fluid">
553 <a href="index.html">Security</a> •
554 <a href="../news/index.html">News</a>
•555
556 <a href="#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../image/wand.ico" /></a>
557
558 <a href="../links/index.html">Related</a> •
559 <a href="../sitemap/index.html">Sitemap</a>
•560 <br />
561 <a href="../support/index.html">Sponsor</a> •
562 <a href="../cite/index.html">Cite</a> •
563 <a href="http://pgp.mit.edu/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
564 <a href="https://github.com/ImageMagick/ImageMagick/discussions">Contact Us</a>
•565 <br />
566 <a href="https://github.com/imagemagick/imagemagick" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><svg xmlns="http://www.w3.org/2000/svg" class="navbar-nav-svg" viewBox="0 0 512 499.36" width="2%" height="2%" role="img" focusable="false">
567 <title>GitHub</title>
568 <path fill="currentColor" fill-rule="evenodd" d="M256 0C114.64 0 0 114.61 0 256c0 113.09 73.34 209 175.08 242.9 12.8 2.35 17.47-5.56 17.47-12.34 0-6.08-.22-22.18-.35-43.54-71.2 15.49-86.2-34.34-86.2-34.34-11.64-29.57-28.42-37.45-28.42-37.45-23.27-15.84 1.73-15.55 1.73-15.55 25.69 1.81 39.21 26.38 39.21 26.38 22.84 39.12 59.92 27.82 74.5 21.27 2.33-16.54 8.94-27.82 16.25-34.22-56.84-6.43-116.6-28.43-116.6-126.49 0-27.95 10-50.8 26.35-68.69-2.63-6.48-11.42-32.5 2.51-67.75 0 0 21.49-6.88 70.4 26.24a242.65 242.65 0 0 1 128.18 0c48.87-33.13 70.33-26.24 70.33-26.24 14 35.25 5.18 61.27 2.55 67.75 16.41 17.9 26.31 40.75 26.31 68.69 0 98.35-59.85 120-116.88 126.32 9.19 7.9 17.38 23.53 17.38 47.41 0 34.22-.31 61.83-.31 70.23 0 6.85 4.61 14.81 17.6 12.31C438.72 464.97 512 369.08 512 256.02 512 114.62 397.37 0 256 0z" />
569 </svg></a> •
570 <a href="https://twitter.com/imagemagick" rel="noopener noreferrer" target="_blank" aria-label="Twitter"><svg xmlns="http://www.w3.org/2000/svg" class="navbar-nav-svg" viewBox="0 0 300 300" width="2%" height="2%" role="img" focusable="false">
571 <title>Twitter</title>
572 <path d="M178.57 127.15 290.27 0h-26.46l-97.03 110.38L89.34 0H0l117.13 166.93L0 300.25h26.46l102.4-116.59 81.8 116.59h89.34M36.01 19.54H76.66l187.13 262.13h-40.66" />
573 </svg></a>
•574 <br />
575 <small>Copyright © 1999 ImageMagick Studio LLC</small>
576 </div>
577 </footer>
578 <div style="visibility: hidden;">
579 <div class="gcse-search"></div>
580 </div>
581 </div>
582
583 <!-- Javascript assets -->
584 <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
585 </body>
586
587
588 </html>