Debian Codegraph @

www/security-policy.html

raw symbols ◀ ▶ SCIP
4 Debian patches touch this file
1
2
3
4 <!DOCTYPE html>
5 <html lang="en" data-bs-theme="dark">
6 <head>
7 <meta charset="utf-8" />
8 <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
9
10 <!-- Title and Description -->
11 <title>ImageMagick | Security Policy</title>
12 <meta name="description" content="ImageMagick is a powerful open-source software suite for creating, editing, converting, and manipulating images in over 200 formats. Ideal for developers, designers, and researchers." />
13
14 <!-- Canonical URL -->
15 <link rel="canonical" href="security-policy.html" />
16
17 <!-- Robots -->
18 <meta name="robots" content="index, follow" />
19
20 <!-- Theme Color -->
21 <meta name="theme-color" content="#000000" />
22
23 <!-- Verification Tags -->
24 <meta name="google-site-verification" content="_bMOCDpkx9ZAzBwb2kF3PRHbfUUdFj2uO8Jd1AXArz4" />
25
26 <!-- Favicon and Apple Icon -->
27 <link rel="shortcut icon" href="../images/wand.png" type="images/png" />
28 <link rel="apple-touch-icon" href="../images/wand.png" type="images/png" />
29
30 <!-- Preconnect for External Resources -->
31 <link rel="preconnect" href="../index.html" />
32
33 <!-- Stylesheets -->
34 <link rel="preload" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" as="style" crossorigin="anonymous" />
35 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" />
36
37 <!-- Accessibility Enhancement -->
38 <style>
39 html {
40 scroll-padding-top: 70px;
41 }
42 a.nav-link:hover,
43 a.dropdown-item:hover {
44 color: #ffc107 !important;
45 text-shadow: 0px 2px 4px rgba(255, 193, 7, 0.8);
46 }
47 .btn-outline-warning {
48 color: #cd7f32;
49 border-color: #cd7f32;
50 }
51 .navbar-brand {
52 color: #d4af37;
53 transition: color 0.3s ease, text-shadow 0.3s ease;
54 }
55 .navbar-brand:hover {
56 color: #e9c03d;
57 text-shadow: 0px 2px 4px rgba(203, 163, 120, 0.6);
58 }
59 </style>
60
61 <!-- Open Graph Meta Tags -->
62 <meta property="og:title" content="ImageMagick | Security Policy" />
63 <meta property="og:description" content="ImageMagick is a powerful open-source software suite for creating, editing, converting, and manipulating images in over 200 formats. Ideal for developers, designers, and researchers." />
64 <meta property="og:image" content="../images/logo.png" />
65 <meta property="og:logo" content="../images/logo.png" />
66 <meta property="og:url" content="../www/security-policy.html" />
67 <meta property="og:type" content="website" />
68 <meta property="og:site_name" content="ImageMagick" />
69 <meta property="og:locale" content="en_us" />
70
71 <!-- Twitter Card Meta Tags -->
72 <meta name="twitter:card" content="summary_large_image" />
73 <meta name="twitter:site" content="@imagemagick" />
74 <meta name="twitter:creator" content="@imagemagick" />
75 <meta name="twitter:title" content="ImageMagick | Security Policy" />
76 <meta name="twitter:description" content="ImageMagick is a powerful open-source software suite for creating, editing, converting, and manipulating images in over 200 formats. Ideal for developers, designers, and researchers." />
77 <meta name="twitter:image" content="../images/logo.png" />
78 <meta name="twitter:image:alt" content="ImageMagick logo and tag line" />
79
80 <!-- JSON-LD Structured Data -->
81 <script type="application/ld+json">
82 {
83 "@context": "https://schema.org",
84 "@type": "SoftwareApplication",
85 "name": "ImageMagick",
86 "url": "../www/security-policy.html",
87 "image": "../images/logo.png",
88 "description": "ImageMagick is a powerful open-source software suite for creating, editing, converting, and manipulating images in over 200 formats. Ideal for developers, designers, and researchers.",
89 "applicationCategory": "Multimedia",
90 "operatingSystem": "Windows, macOS, Linux, Unix",
91 "softwareVersion": "7.1.2-3",
92 "license": "../www/license.html",
93 "creator": {
94 "@type": "Organization",
95 "name": "ImageMagick Studio LLC",
96 "url": "https://imagemagick.org"
97 },
98 "keywords": [
99 "Security Policy",
100 "image processing software",
101 "image conversion tool",
102 "batch image editing",
103 "open-source image editor",
104 "ImageMagick command-line",
105 "resize images ImageMagick",
106 "crop and rotate images",
107 "ImageMagick tutorial",
108 "ImageMagick automation",
109 "ImageMagick for developers",
110 "ImageMagick CLI",
111 "ImageMagick filters and effects",
112 "ImageMagick scripting",
113 "ImageMagick API integration"
114 ],
115 "sameAs": [
116 "https://github.com/ImageMagick",
117 "https://x.com/imagemagick"
118 ],
119 "offers": {
120 "@type": "Offer",
121 "price": "0.00",
122 "priceCurrency": "USD"
123 }
124 }
125 </script>
126 <!-- Google Custom Search -->
127 </head>
128 <body>
129 <script>
130 function setTheme(theme) {
131 localStorage.setItem('theme', theme);
132 updateThemeIcon(theme);
133 document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? getSystemTheme() : theme);
134 }
135 function getSystemTheme() {
136 return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
137 }
138 function updateThemeIcon(theme) {
139 const iconMap = {
140 light: '☀️',
141 dark: '🌙',
142 auto: '🌓'
143 };
144 document.getElementById('currentThemeIcon').textContent = iconMap[theme] || '🌓';
145 }
146 document.addEventListener('DOMContentLoaded', () => {
147 const savedTheme = localStorage.getItem('theme') || 'auto';
148 setTheme(savedTheme);
149 });
150 </script>
151 <nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
152 <div class="container-fluid">
153 <a class="navbar-brand fw-bold" href="../index.html" title="$meta->sitename;">
154 ImageMagick </a>
155 <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">
156 <span class="navbar-toggler-icon"></span>
157 </button>
158
159 <div class="collapse navbar-collapse" id="magick-navbars">
160 <ul class="navbar-nav me-auto">
161 <li class="nav-item">
162 <a class="nav-link " href="download.html">Download</a>
163 </li>
164 <li class="nav-item">
165 <a class="nav-link " href="command-line-tools.html">Tools</a>
166 </li>
167 <li class="nav-item">
168 <a class="nav-link " href="command-line-processing.html">CLI</a>
169 </li>
170 <li class="nav-item">
171 <a class="nav-link " href="develop.html">Develop</a>
172 </li>
173 <li class="nav-item">
174 <a class="nav-link" rel="noopener noreferrer" target="_blank" href="https://github.com/ImageMagick/ImageMagick/discussions">Community</a>
175 </li>
176 <li class="nav-item ms-4">
177 <iframe src="https://github.com/sponsors/ImageMagick/button" title="Sponsor ImageMagick" height="35" width="107" style="border: 0;"></iframe>
178 </li>
179 </ul>
180 <ul class="navbar-nav ms-auto">
181 <li class="nav-item ms-3">
•182 </li>
183 <li class="nav-item dropdown ms-3">
184 <a class="nav-link dropdown-toggle" href="#" id="themeDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
185 <span id="currentThemeIcon">🌓</span>
186 </a>
187 <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="themeDropdown">
188 <li><a class="dropdown-item" href="#" onclick="setTheme('light')">☀️ Light</a></li>
189 <li><a class="dropdown-item" href="#" onclick="setTheme('dark')">🌙 Dark</a></li>
190 <li><a class="dropdown-item" href="#" onclick="setTheme('auto')">🌓 Auto</a></li>
191 </ul>
192 </li>
193 </ul>
194 </div>
195 </div>
196 </nav>
197
198 <div class="col-lg-8 mx-auto text-body-secondary pt-5 pt-lg-5">
199 <header class="d-flex align-items-center pb-3 mb-5 border-bottom">
200 <div class="mt-3 ms-3">
201 <a href="../index.html" class="text-decoration-none">
202 <h1 class="fs-2 mb-1">Security Policy</h1>
203 </a>
204 <h2 class="fs-5 text-muted">ImageMagick</h2>
205 </div>
206 </header>
207
208 <main role="main" class="container">
209 <div>
210 <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>
211
212 <p class="text-info">It is strongly recommended to establish a security policy suitable for your local environment before utilizing ImageMagick.</p>
213
214 <p class="lead">The default policy is open, which is useful for ImageMagick installations running in a secure environment, such as in a Docker container or behind a firewall.</p>
215
216 <p>ImageMagick is a tool that allows you to manipulate images. While it offers a range of features and capabilities, there is often a trade-off between security and convenience. 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>
217
218 <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="https://imagemagick.org/source/policy-open.xml">policy.xml</a> configuration file.</p>
219
220 <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>
221
•222 <p>To help you get started, as of version 7.1.1-16, ImageMagick provides security polices that you can select when installing ImageMagick.</p> Choose from:
223
224 <ul>
225 <dt><a href="https://imagemagick.org/source/policy-open.xml">open</a></dt>
226 <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>
227 <dt><a href="https://imagemagick.org/source/policy-limited.xml">limited</a></dt>
•228 <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>
229 <dt><a href="https://imagemagick.org/source/policy-secure.xml">secure</a></dt>
•230 <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>
231 <dt><a href="https://imagemagick.org/source/policy-websafe.xml">websafe</a></dt>
232 <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>
233 </ul>
234 <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>
235
236 <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>
237
238 <h2><a class="anchor" id="example"></a>Example Security Policy</h2>
239
240 <p>Here is an example security policy:</p>
241
242 <pre class="pre-scrollable p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;?xml version="1.0" encoding="UTF-8"?>
243 &lt;!DOCTYPE policymap [
244 &lt;!ELEMENT policymap (policy)*>
245 &lt;!ATTLIST policymap xmlns CDATA #FIXED "">
246 &lt;!ELEMENT policy EMPTY>
247 &lt;!ATTLIST policy xmlns CDATA #FIXED "">
248 &lt;!ATTLIST policy domain NMTOKEN #REQUIRED>
249 &lt;!ATTLIST policy name NMTOKEN #IMPLIED>
250 &lt;!ATTLIST policy pattern CDATA #IMPLIED>
251 &lt;!ATTLIST policy rights NMTOKEN #IMPLIED>
252 &lt;!ATTLIST policy stealth NMTOKEN #IMPLIED>
253 &lt;!ATTLIST policy value CDATA #IMPLIED>
254 ]>
255 &lt;!--
256 Creating a security policy that fits your specific local environment
257 before making use of ImageMagick is highly advised. You can find guidance on
258 setting up this policy at ../www/security-policy.html,
259 and it's important to verify your policy using the validation tool located
260 at https://imagemagick-secevaluator.doyensec.com/.
261
262
263 Web-safe ImageMagick security policy:
264
265 This security protocol designed for web-safe usage focuses on situations
266 where ImageMagick is applied in publicly accessible contexts, like websites.
267 It deactivates the capability to read from or write to any image formats
268 other than web-safe formats like GIF, JPEG, and PNG. Additionally, this
269 policy prohibits the execution of image filters and indirect reads, thereby
270 thwarting potential security breaches. By implementing these limitations,
271 the web-safe policy fortifies the safeguarding of systems accessible to
272 the public, reducing the risk of exploiting ImageMagick's capabilities
273 for potential attacks.
274 -->
275 &lt;policymap>
276 &lt;!-- Set maximum parallel threads. -->
277 &lt;policy domain="resource" name="thread" value="2"/>
278 &lt;!-- Set maximum time in seconds or neumonics, e.g. "2 minutes". When this
279 limit is exceeded, an exception is thrown and processing stops. -->
280 &lt;policy domain="resource" name="time" value="60"/>
281 &lt;!-- Set maximum number of open pixel cache files. When this limit is
282 exceeded, any subsequent pixels cached to disk are closed and reopened
283 on demand. -->
284 &lt;policy domain="resource" name="file" value="768"/>
285 &lt;!-- Set maximum amount of memory in bytes to allocate for the pixel cache
286 from the heap. When this limit is exceeded, the image pixels are cached
287 to memory-mapped disk. -->
288 &lt;policy domain="resource" name="memory" value="256MiB"/>
289 &lt;!-- Set maximum amount of memory map in bytes to allocate for the pixel
290 cache. When this limit is exceeded, the image pixels are cached to
291 disk. -->
292 &lt;policy domain="resource" name="map" value="512MiB"/>
293 &lt;!-- Set the maximum width * height of an image that can reside in the pixel
294 cache memory. Images that exceed the area limit are cached to disk. -->
295 &lt;policy domain="resource" name="area" value="16KP"/>
296 &lt;!-- Set maximum amount of disk space in bytes permitted for use by the pixel
297 cache. When this limit is exceeded, the pixel cache is not be created
298 and an exception is thrown. -->
299 &lt;policy domain="resource" name="disk" value="1GiB"/>
300 &lt;!-- Set the maximum length of an image sequence. When this limit is
301 exceeded, an exception is thrown. -->
302 &lt;policy domain="resource" name="list-length" value="16"/>
303 &lt;!-- Set the maximum width of an image. When this limit is exceeded, an
304 exception is thrown. -->
305 &lt;policy domain="resource" name="width" value="4KP"/>
306 &lt;!-- Set the maximum height of an image. When this limit is exceeded, an
307 exception is thrown. -->
308 &lt;policy domain="resource" name="height" value="4KP"/>
309 &lt;!-- Periodically yield the CPU for at least the time specified in
310 milliseconds. -->
311 &lt;policy domain="resource" name="throttle" value="2"/>
312 &lt;!-- Dynamically yield the CPU relative to the system load average. -->
313 &lt;policy domain="resource" name="dynamic-throttle" value="false"/>
314 &lt;!-- Do not create temporary files in the default shared directories, instead
315 specify a private area to store only ImageMagick temporary files. -->
316 &lt;!-- <policy domain="resource" name="temporary-path" value="/magick/tmp"/> -->
317 &lt;!-- Force memory initialization by memory mapping select memory
318 allocations. -->
319 &lt;policy domain="cache" name="memory-map" value="anonymous"/>
320 &lt;!-- Ensure all image data is fully flushed and synchronized to disk. -->
321 &lt;policy domain="cache" name="synchronize" value="true"/>
322 &lt;!-- Replace passphrase for secure distributed processing -->
323 &lt;!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> -->
324 &lt;!-- Do not permit any delegates to execute. -->
325 &lt;policy domain="delegate" rights="none" pattern="*"/>
326 &lt;!-- Do not permit any image filters to load. -->
327 &lt;policy domain="filter" rights="none" pattern="*"/>
328 &lt;!-- Don't read/write from/to stdin/stdout. -->
329 &lt;policy domain="path" rights="none" pattern="-"/>
330 &lt;policy domain="path" rights="none" pattern="fd:*"/>
331 &lt;!-- don't read sensitive paths. -->
332 &lt;policy domain="path" rights="none" pattern="/etc/*"/>
333 &lt;!-- Indirect reads are not permitted. -->
334 &lt;policy domain="path" rights="none" pattern="@*"/>
335 &lt;!-- Deny all image modules and specifically exempt reading or writing
336 web-safe image formats. -->
337 &lt;policy domain="module" rights="none" pattern="*" />
338 &lt;policy domain="module" rights="read | write" pattern="{GIF,JPEG,PNG,WEBP}" />
339 &lt;!-- This policy sets the number of times to replace content of certain
340 memory buffers and temporary files before they are freed or deleted. -->
341 &lt;policy domain="system" name="shred" value="1"/>
342 &lt;!-- Enable the initialization of buffers with zeros, resulting in a minor
343 performance penalty but with improved security. -->
344 &lt;policy domain="system" name="memory-map" value="anonymous"/>
345 &lt;!-- Set the maximum amount of memory in bytes that is permitted for
346 allocation requests. -->
347 &lt;policy domain="system" name="max-memory-request" value="256MiB"/>
348 &lt;/policymap></code></pre>
349
350 <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>
351
352 <p>Starting with ImageMagick 7.0.1-8, you can prevent the use of any delegate or all delegates (by setting the pattern to "*"). Prior to these releases, you can use the domain of <samp>coder</samp> and set rights to none and the glob pattern to HTTPS to prevent 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. <samp>caption:@myCaption.txt</samp>), you'll need to disable this path policy.</p>
353
354 <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 <samp>[Pp][Nn][Gg]</samp>.</p>
355
356 <p>Here is what you can expect when you restrict the HTTPS coder, for example:</p>
357
358 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary">$ magick ../images/wizard.png wizard.jpg
359 convert: attempt to perform an operation not allowed by the security policy `HTTPS'
360 convert: no images defined `wizard.jpg'</pre>
361
362 <p>As of ImageMagick version 7.0.4-7, you can conveniently deny access to all delegates and coders except for a small subset of proven web-safe image types. For example,</p>
363
364 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="delegate" rights="none" pattern="*" />
365 &lt;policy domain="module" rights="none" pattern="*" />
366 &lt;policy domain="module" rights="read | write" pattern="{GIF,JPEG,PNG,WEBP}" /></samp></pre>
367
368 <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>
369 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="coder" rights="write" pattern="{PDF,PS,PS2,PS3,XPS}" /></samp></pre>
370
371 <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>
372 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="system" name="memory-map" value="anonymous"/>
373 &lt;policy domain="cache" name="memory-map" value="anonymous"/>
374 &lt;policy domain="system" name="shred" value="1"/></samp></pre>
375 <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>
376
377 <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>
378 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="system" name="max-memory-request" value="256MiB"/> </samp></pre>
379
380 <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>
381 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="resource" name="list-length" value="64"/></samp></pre>
382
383 <p>Note, numeric values in policies are floating-point with an optional SI prefix (e.g., 10MiB).</p>
384
385 <p>For additional details about resource limits and the policy configuration file, read <a href="../www/resources.html">Resources</a> and <a href="../www/architecture.html">Architecture</a>.</p>
386
387 <p>As of ImageMagick 7.0.6-0, you can programmatically set the ImageMagick security policy with SetMagickSecurityPolicy() (MagickCore) or MagickSetSecurityPolicy() (MagickWand).</p>
388
389 <p>As of ImageMagick version 7.0.8-11, you can set a <samp>module</samp> security policy. For example, to prevent Postscript or PDF interpretation, use:</p>
390 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="module" rights="none" pattern="{ps,pdf,xps}/></samp></pre>
391
392 <p>As of ImageMagick version 7.0-10-52, you can set a <samp>font</samp> policy. Specify a path to a Unicode font that ImageMagick defaults to whenever the user does not specify a font preference:</p>
393 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="system" name="font" value="/usr/share/fonts/arial-unicode.ttf"/></samp></pre>
394
395 <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>
396 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>&lt;policy domain="path" rights="none" pattern="c:\\\\*"/></samp></pre>
397
398 <p>You can verify your policy changes are in effect with this command:</p>
399
400 <pre class="pre-scrollable p-3 mb-2 text-body-secondary bg-body-tertiary">$ magick identify -list policy
401 Path: ImageMagick-7/policy.xml
402 Policy: Cache
403 name: memory-map
404 value: anonymous
405 Policy: Cache
406 name: synchronize
407 value: true
408 Policy: Resource
409 name: list-length
410 value: 32
411 Policy: Resource
412 name: time
413 value: 120
414 Policy: Resource
415 name: thread
416 value: 2
417 Policy: Resource
418 name: file
419 value: 768
420 Policy: Resource
421 name: disk
422 value: 1GiB
423 Policy: Resource
424 name: map
425 value: 512MiB
426 Policy: Resource
427 name: memory
428 value: 256MiB
429 Policy: Resource
430 name: area
431 value: 16KP
432 Policy: Resource
433 name: height
434 value: 8KP
435 Policy: Resource
436 name: width
437 value: 8KP
438 Policy: Resource
439 name: temporary-path
440 value: /opt/tmp
441 Policy: Coder
442 rights: Write
443 pattern: {HTTP,HTTPS,MVG,PS,PDF}
444 Policy: Filter
445 rights: None
446 pattern: *
447 Policy: Path
448 rights: None
449 pattern: @*
450 Policy: System
451 name: font
452 value: ImageMagick-7/arial-unicode.ttf
453
454 Path: [built-in]
455 Policy: Undefined
456 rights: None</pre>
457 <p>Notice the <samp>shared-secret</samp> policy is not listed due to the <samp>stealth</samp> property.</p>
458
459 <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="../index.html">imagemagick-secevaluator.doyensec.com</a>.</p>
460
461 <h2><a class="anchor" id="synchronize"></a>Pixel Cache Synchronize Policy</h2>
462
•463 <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>
464
465
466 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary">
467 &lt;policy domain="cache" name="synchronize" value="True"/>
468 </pre>
469
470 <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>
471
472 <h2><a class="anchor" id="zero-configuration"></a>Zero Configuration Security Policy</h2>
473
474 <p>A zero configuration build of ImageMagick does not permit external configuration files. To define your security policy, you must instead edit the <samp>MagickCore/policy-private.h</samp> source module, add your policy statements, and then build the ImageMagick distribution. Here is an example zero configuration security policy:</p>
475
476 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>static const char
477 *ZeroConfigurationPolicy = \
478 "&lt;policymap> \
479 &lt;policy domain=\"coder\" rights=\"none\" pattern=\"MVG\"/> \
480 &lt;/policymap>";</samp></pre>
481
482 <h2><a class="anchor" id="other"></a>Other Security Considerations</h2>
483
484 <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>
485
•486 <p>There are several ways to keep ImageMagick safer:</p>
487 <ol>
488 <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>
489
490 <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>
491
492 <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>
493
494 <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>
495
496 <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>
497
498 <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>
499
500 <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>
501 </ol>
502
503 </div>
504 <a aria-label="About ImageMagick" class="btn btn-outline-warning mt-3" href="../index.html">About ImageMagick</a>
505 </main><!-- /.container -->
506 <footer class="text-center pt-5 my-5 text-body-secondary border-top">
507 <div class="container-fluid">
508 <a href="security-policy.html">Security</a> •
509 <a href="../www/news.html">News</a>
510
511 <a href="#"><img class="d-inline" id="wand" alt="And Now a Touch of Magick" width="16" height="16" src="../images/wand.ico" /></a>
512
513 <a href="../www/links.html">Related</a> •
514 <a href="../www/sitemap.html">Sitemap</a>
•515 <br />
516 <a href="../www/support.html">Sponsor</a> •
517 <a href="../www/cite.html">Cite</a> •
518 <a href="http://pgp.mit.edu/pks/lookup?op=get&amp;search=0x89AB63D48277377A">Public Key</a> •
519 <a href="../www/https://imagemagick.org/script/contact.php">Contact Us</a>
•520 <br />
521 <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"><title>GitHub</title><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"/></svg></a> •
522 <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"><title>Twitter</title><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"/></svg></a>
•523 <br />
524 <small>Copyright © 1999 ImageMagick Studio LLC</small>
525 </div>
526 </footer>
527 </div>
528
529 <!-- Javascript assets -->
530 <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script>
531 ~
532 </body>
533 </html>
534 <!-- Magick Cache 3rd October 2025 23:49 -->