Debian Codegraph @

www/security-policy/index.html

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 4 — not the installed (fully patched) source.
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 src="https://localhost/cse.js?cx=8720b81722164487b"></script>
118 <script async 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
230 <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>
231
232 <ul>
233 <dt><a href="../source/policy-open.xml">open</a></dt>
234 <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>
235 <dt><a href="../source/policy-limited.xml">limited</a></dt>
236 <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.</dt>
237 <dt><a href="../source/policy-secure.xml">secure</a></dt>
238 <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.</dt>
239 <dt><a href="../source/policy-websafe.xml">websafe</a></dt>
240 <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>
241 </ul>
242 <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>
243
244 <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>
245
246 <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>
247
248 <h2><a class="anchor" id="example"></a>Example Security Policy</h2>
249
250 <p>Here is an example security policy:</p>
251
252 <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"?>
253 &lt;!DOCTYPE policymap [
254 &lt;!ELEMENT policymap (policy)*>
255 &lt;!ATTLIST policymap xmlns CDATA #FIXED "">
256 &lt;!ELEMENT policy EMPTY>
257 &lt;!ATTLIST policy xmlns CDATA #FIXED "">
258 &lt;!ATTLIST policy domain NMTOKEN #REQUIRED>
259 &lt;!ATTLIST policy name NMTOKEN #IMPLIED>
260 &lt;!ATTLIST policy pattern CDATA #IMPLIED>
261 &lt;!ATTLIST policy rights NMTOKEN #IMPLIED>
262 &lt;!ATTLIST policy stealth NMTOKEN #IMPLIED>
263 &lt;!ATTLIST policy value CDATA #IMPLIED>
264 ]>
265 &lt;!--
266 Creating a security policy that fits your specific local environment
267 before making use of ImageMagick is highly advised. You can find guidance on
268 setting up this policy at https://imagemagick.org/security-policy/,
269 and it's important to verify your policy using the validation tool located
270 at https://imagemagick-secevaluator.doyensec.com/. We also strongly
271 recommend that all users validate their security assumptions by testing their
272 configurations after making any policy changes. This helps ensure that the
273 intended restrictions are functioning as expected in their specific
274 deployment environment.
275
276
277 Web-safe ImageMagick security policy:
278
279 This security protocol designed for web-safe usage focuses on situations
280 where ImageMagick is applied in publicly accessible contexts, like websites.
281 It deactivates the capability to read from or write to any image formats
282 other than web-safe formats like GIF, JPEG, and PNG. Additionally, this
283 policy prohibits the execution of image filters and indirect reads, thereby
284 thwarting potential security breaches. By implementing these limitations,
285 the web-safe policy fortifies the safeguarding of systems accessible to
286 the public, reducing the risk of exploiting ImageMagick's capabilities
287 for potential attacks.
288 -->
289 &lt;policymap>
290 &lt;!-- Set maximum parallel threads. -->
291 &lt;policy domain="resource" name="thread" value="2"/>
292 &lt;!-- Set maximum time in seconds or neumonics, e.g. "2 minutes". When this
293 limit is exceeded, an exception is thrown and processing stops. -->
294 &lt;policy domain="resource" name="time" value="60"/>
295 &lt;!-- Set maximum number of open pixel cache files. When this limit is
296 exceeded, any subsequent pixels cached to disk are closed and reopened
297 on demand. -->
298 &lt;policy domain="resource" name="file" value="768"/>
299 &lt;!-- Set maximum amount of memory in bytes to allocate for the pixel cache
300 from the heap. When this limit is exceeded, the image pixels are cached
301 to memory-mapped disk. -->
302 &lt;policy domain="resource" name="memory" value="256MiB"/>
303 &lt;!-- Set maximum amount of memory map in bytes to allocate for the pixel
304 cache. When this limit is exceeded, the image pixels are cached to
305 disk. -->
306 &lt;policy domain="resource" name="map" value="512MiB"/>
307 &lt;!-- Set the maximum width * height of an image that can reside in the pixel
308 cache memory. Images that exceed the area limit are cached to disk. -->
309 &lt;policy domain="resource" name="area" value="16KP"/>
310 &lt;!-- Set maximum amount of disk space in bytes permitted for use by the pixel
311 cache. When this limit is exceeded, the pixel cache is not be created
312 and an exception is thrown. -->
313 &lt;policy domain="resource" name="disk" value="1GiB"/>
314 &lt;!-- Set the maximum length of an image sequence. When this limit is
315 exceeded, an exception is thrown. -->
316 &lt;policy domain="resource" name="list-length" value="16"/>
317 &lt;!-- Set the maximum width of an image. When this limit is exceeded, an
318 exception is thrown. -->
319 &lt;policy domain="resource" name="width" value="4KP"/>
320 &lt;!-- Set the maximum height of an image. When this limit is exceeded, an
321 exception is thrown. -->
322 &lt;policy domain="resource" name="height" value="4KP"/>
323 &lt;!-- Periodically yield the CPU for at least the time specified in
324 milliseconds. -->
325 &lt;policy domain="resource" name="throttle" value="2"/>
326 &lt;!-- Dynamically yield the CPU relative to the system load average. -->
327 &lt;policy domain="resource" name="dynamic-throttle" value="false"/>
328 &lt;!-- Do not create temporary files in the default shared directories, instead
329 specify a private area to store only ImageMagick temporary files. -->
330 &lt;!-- <policy domain="resource" name="temporary-path" value="/magick/tmp"/> -->
331 &lt;!-- Force memory initialization by memory mapping select memory
332 allocations. -->
333 &lt;policy domain="cache" name="memory-map" value="anonymous"/>
334 &lt;!-- Ensure all image data is fully flushed and synchronized to disk. -->
335 &lt;policy domain="cache" name="synchronize" value="true"/>
336 &lt;!-- Replace passphrase for secure distributed processing -->
337 &lt;!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> -->
338 &lt;!-- Do not permit any external delegates to execute. -->
339 &lt;policy domain="delegate" rights="none" pattern="*"/>
340 &lt;!-- Do not permit any image filters to load. -->
341 &lt;policy domain="filter" rights="none" pattern="*"/>
342 &lt;!-- Don't read/write from/to stdin/stdout. -->
343 &lt;policy domain="path" rights="none" pattern="-"/>
344 &lt;policy domain="path" rights="none" pattern="[Ff][Dd]:*"/>
345 &lt;!-- Sensitive paths are not permitted. -->
346 &lt;policy domain="path" rights="none" pattern="/etc/*"/>
347 &lt;!-- Relative paths are not permitted. -->
348 &lt;policy domain="path" rights="none" pattern="*../*"/>
349 &lt;!-- Indirect reading is not permitted. -->
350 &lt;policy domain="path" rights="none" pattern="@*"/>
351 &lt;!-- Deny all image modules and specifically exempt reading or writing
352 web-safe image formats. -->
353 &lt;policy domain="module" rights="none" pattern="*" />
354 &lt;policy domain="module" rights="read | write" pattern="{GIF,JPEG,PNG,WEBP}" />
355 &lt;!-- This policy sets the number of times to replace content of certain
356 memory buffers and temporary files before they are freed or deleted. -->
357 &lt;policy domain="system" name="shred" value="1"/>
358 &lt;!-- Enable the initialization of buffers with zeros, resulting in a minor
359 performance penalty but with improved security. -->
360 &lt;policy domain="system" name="memory-map" value="anonymous"/>
361 &lt;!-- Set the maximum amount of memory in bytes that is permitted for
362 allocation requests. -->
363 &lt;policy domain="system" name="max-memory-request" value="256MiB"/>
364 &lt;!-- If the basename of path is a symbolic link, the open fails -->
365 &lt;policy domain="system" name="symlink" rights="none" pattern="follow"/>
366 &lt;!-- Blocks all SVG entity‑substitution attempts by denying the svg:substitute-entities define -->
367 &lt;policy domain="system" name="svg" rights="none" pattern="substitute-entities"/>
368 &lt;/policymap></code></pre>
369
370 <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>
371
372 <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>
373
374 <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>
375
376 <p>Here is what you can expect when you restrict the HTTPS coder, for example:</p>
377
378 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><samp>$ magick https://imagemagick.org/image/wizard.png wizard.jpg
379 convert: attempt to perform an operation not allowed by the security policy `HTTPS'
380 convert: no images defined `wizard.jpg'</samp></pre>
381
382 <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>
383
384 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="delegate" rights="none" pattern="*" />
385 &lt;policy domain="module" rights="none" pattern="*" />
386 &lt;policy domain="module" rights="read | write" pattern="{GIF,JPEG,PNG,WEBP}" /></code></pre>
387
388 <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>
389 <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>
390
391 <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>
392 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="system" name="memory-map" value="anonymous"/>
393 &lt;policy domain="cache" name="memory-map" value="anonymous"/>
394 &lt;policy domain="system" name="shred" value="1"/></code></pre>
395 <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>
396
397 <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>
398 <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>
399
400 <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>
401 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="resource" name="list-length" value="64"/></code></pre>
402
403 <p>Note, numeric values in policies are floating-point with an optional SI prefix (e.g., 10MiB).</p>
404
405 <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>
406
407 <p>As of ImageMagick 7.0.6-0, you can programmatically set the ImageMagick security policy with SetMagickSecurityPolicy() (MagickCore) or MagickSetSecurityPolicy() (MagickWand).</p>
408
409 <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>
410 <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>
411
412 <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>
413 <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>
414
415 <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>
416 <pre class="p-3 mb-2 text-body-secondary bg-body-tertiary"><code>&lt;policy domain="path" rights="none" pattern="c:\\\\*"/></code></pre>
417
418 <p>You can verify your policy changes are in effect with this command:</p>
419
420 <pre class="overflow-auto p-3 mb-2 text-body-secondary bg-body-tertiary" style="max-height:75svh;"><samp>$ magick identify -list policy
421 Path: ImageMagick-7/policy.xml
422 Policy: Cache
423 name: memory-map
424 value: anonymous
425 Policy: Cache
426 name: synchronize
427 value: true
428 Policy: Resource
429 name: list-length
430 value: 32
431 Policy: Resource
432 name: time
433 value: 120
434 Policy: Resource
435 name: thread
436 value: 2
437 Policy: Resource
438 name: file
439 value: 768
440 Policy: Resource
441 name: disk
442 value: 1GiB
443 Policy: Resource
444 name: map
445 value: 512MiB
446 Policy: Resource
447 name: memory
448 value: 256MiB
449 Policy: Resource
450 name: area
451 value: 16KP
452 Policy: Resource
453 name: height
454 value: 8KP
455 Policy: Resource
456 name: width
457 value: 8KP
458 Policy: Resource
459 name: temporary-path
460 value: /opt/tmp
461 Policy: Module
462 rights: Write
463 pattern: {HTTP,HTTPS,MVG,PS,PDF}
464 Policy: Filter
465 rights: None
466 pattern: *
467 Policy: Path
468 rights: None
469 pattern: @*
470 Policy: System
471 name: font
472 value: ImageMagick-7/arial-unicode.ttf
473
474 Path: [built-in]
475 Policy: Undefined
476 rights: None</samp></pre>
477 <p>Notice the <code>shared-secret</code> policy is not listed due to the <code>stealth</code> property.</p>
478
479
480 <h2><a class="anchor" id="synchronize"></a>Pixel Cache Synchronize Policy</h2>
481
482 <p>When writing image pixels to disk, ImageMagick first preallocates the disk file, which is faster than fully populating the file with zeros. To improve performance even further, the file is memory-mapped on disk. This can result in an increase in performance of up to 5 times, but there is a possibility that the disk file may run out of free space as it is populated, causing the operating system (OS) to throw a SIGBUS signal which prevents ImageMagick from continuing. To prevent a SIGBUS signal from occurring, use this security policy:</p>
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 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 &nbsp;
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 &nbsp;
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>