| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <!DOCTYPE policymap [ |
| 3 | <!ELEMENT policymap (policy)*> |
| 4 | <!ATTLIST policymap xmlns CDATA #FIXED ""> |
| 5 | <!ELEMENT policy EMPTY> |
| 6 | <!ATTLIST policy xmlns CDATA #FIXED ""> |
| 7 | <!ATTLIST policy domain NMTOKEN #REQUIRED> |
| 8 | <!ATTLIST policy name NMTOKEN #IMPLIED> |
| 9 | <!ATTLIST policy pattern CDATA #IMPLIED> |
| 10 | <!ATTLIST policy rights NMTOKEN #IMPLIED> |
| 11 | <!ATTLIST policy stealth NMTOKEN #IMPLIED> |
| 12 | <!ATTLIST policy value CDATA #IMPLIED> |
| 13 | ]> |
| 14 | <!-- |
| 15 | Creating a security policy that fits your specific local environment |
| 16 | before making use of ImageMagick is highly advised. You can find guidance on |
| 17 | setting up this policy at https://imagemagick.org/script/security-policy.php, |
| 18 | and it's important to verify your policy using the validation tool located |
| 19 | at https://imagemagick-secevaluator.doyensec.com/. We also strongly |
| 20 | recommend that all users validate their security assumptions by testing their configurations after making any policy changes. This helps ensure that the |
| 21 | intended restrictions are functioning as expected in their specific |
| 22 | deployment environment. |
| 23 | |
| 24 | |
| 25 | Secure ImageMagick security policy: |
| 26 | |
| 27 | This stringent security policy prioritizes the implementation of |
| 28 | rigorous controls and restricted resource utilization to establish a |
| 29 | profoundly secure setting while employing ImageMagick. It deactivates |
| 30 | conceivably hazardous functionalities, including specific coders like |
| 31 | SVG or HTTP. The policy promotes the tailoring of security measures to |
| 32 | harmonize with the requirements of the local environment and the guidelines |
| 33 | of the organization. This protocol encompasses explicit particulars like |
| 34 | limitations on memory consumption, sanctioned pathways for reading and |
| 35 | writing, confines on image sequences, the utmost permissible duration of |
| 36 | workflows, allocation of disk space intended for image data, and even an |
| 37 | undisclosed passphrase for remote connections. By adopting this robust |
| 38 | policy, entities can elevate their overall security stance and alleviate |
| 39 | potential vulnerabilities. |
| 40 | --> |
| 41 | <policymap> |
| 42 | <!-- Set maximum parallel threads. --> |
| 43 | <policy domain="resource" name="thread" value="2"/> |
| 44 | <!-- Set maximum time in seconds. When this limit is exceeded, an exception |
| 45 | is thrown and processing stops. --> |
| 46 | <policy domain="resource" name="time" value="120"/> |
| 47 | <!-- Set maximum number of open pixel cache files. When this limit is |
| 48 | exceeded, any subsequent pixels cached to disk are closed and reopened |
| 49 | on demand. --> |
| 50 | <policy domain="resource" name="file" value="768"/> |
| 51 | <!-- Set maximum amount of memory in bytes to allocate for the pixel cache |
| 52 | from the heap. When this limit is exceeded, the image pixels are cached |
| 53 | to memory-mapped disk. --> |
| 54 | <policy domain="resource" name="memory" value="768MiB"/> |
| 55 | <!-- Set maximum amount of memory map in bytes to allocate for the pixel |
| 56 | cache. When this limit is exceeded, the image pixels are cached to |
| 57 | disk. --> |
| 58 | <policy domain="resource" name="map" value="2GiB"/> |
| 59 | <!-- Set the maximum width * height of an image that can reside in the pixel |
| 60 | cache memory. Images that exceed the area limit are cached to disk. --> |
| 61 | <policy domain="resource" name="area" value="8KP"/> |
| 62 | <!-- Set maximum amount of disk space in bytes permitted for use by the pixel |
| 63 | cache. When this limit is exceeded, the pixel cache is not created |
| 64 | and an exception is thrown. --> |
| 65 | <policy domain="resource" name="disk" value="2GiB"/> |
| 66 | <!-- Set the maximum length of an image sequence. When this limit is |
| 67 | exceeded, an exception is thrown. --> |
| 68 | <policy domain="resource" name="list-length" value="32"/> |
| 69 | <!-- Set the maximum width of an image. When this limit is exceeded, an |
| 70 | exception is thrown. --> |
| 71 | <policy domain="resource" name="width" value="8KP"/> |
| 72 | <!-- Set the maximum height of an image. When this limit is exceeded, an |
| 73 | exception is thrown. --> |
| 74 | <policy domain="resource" name="height" value="8KP"/> |
| 75 | <!-- Periodically yield the CPU for at least the time specified in |
| 76 | milliseconds. --> |
| 77 | <!-- <policy domain="resource" name="throttle" value="2"/> --> |
| 78 | <!-- Dynamically yield the CPU relative to the system load average. --> |
| 79 | <!-- <policy domain="resource" name="dynamic-throttle" value="true"/> --> |
| 80 | <!-- Do not create temporary files in the default shared directories, instead |
| 81 | specify a private area to store only ImageMagick temporary files. --> |
| 82 | <!-- <policy domain="resource" name="temporary-path" value="/magick/tmp/"/> --> |
| 83 | <!-- Force memory initialization by memory mapping select memory |
| 84 | allocations. --> |
| 85 | <policy domain="cache" name="memory-map" value="anonymous"/> |
| 86 | <!-- Ensure all image data is fully flushed and synchronized to disk. --> |
| 87 | <policy domain="cache" name="synchronize" value="true"/> |
| 88 | <!-- Replace passphrase for secure distributed processing --> |
| 89 | <!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> --> |
| 90 | <!-- Do not permit any delegates to execute. --> |
| 91 | <policy domain="delegate" rights="none" pattern="*"/> |
| 92 | <!-- Do not permit any image filters to load. --> |
| 93 | <policy domain="filter" rights="none" pattern="*"/> |
| 94 | <!-- Don't read/write from/to stdin/stdout. --> |
| 95 | <policy domain="path" rights="none" pattern="-"/> |
| 96 | <policy domain="path" rights="none" pattern="[Ff][Dd]:*"/> |
| 97 | <!-- Sensitive paths are not permitted. --> |
| 98 | <policy domain="path" rights="none" pattern="/etc/*"/> |
| 99 | <!-- Relative paths are not permitted. --> |
| 100 | <policy domain="path" rights="none" pattern="*../*"/> |
| 101 | <!-- Indirect reading is not permitted. --> |
| 102 | <policy domain="path" rights="none" pattern="@*"/> |
| 103 | <!-- These image types are security risks on read, but write is fine --> |
| 104 | <policy domain="module" rights="write" pattern="{MSL,MVG,PS,SVG,TXT,URL,XPS}"/> |
| 105 | <!-- This policy sets the number of times to replace content of certain |
| 106 | memory buffers and temporary files before they are freed or deleted. --> |
| 107 | <policy domain="system" name="shred" value="1"/> |
| 108 | <!-- Enable the initialization of buffers with zeros, resulting in a minor |
| 109 | performance penalty but with improved security. --> |
| 110 | <policy domain="system" name="memory-map" value="anonymous"/> |
| 111 | <!-- Set the maximum amount of memory in bytes that are permitted for |
| 112 | allocation requests. --> |
| 113 | <policy domain="system" name="max-memory-request" value="256MiB"/> |
| 114 | <!-- If the basename of path is a symbolic link, the open fails --> |
| 115 | <policy domain="system" name="symlink" rights="none" pattern="follow"/> |
| 116 | </policymap> |