| 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 '' domain NMTOKEN #REQUIRED |
| 7 | name NMTOKEN #IMPLIED pattern CDATA #IMPLIED rights NMTOKEN #IMPLIED |
| 8 | stealth NMTOKEN #IMPLIED value CDATA #IMPLIED> |
| 9 | ]> |
| 10 | <!-- |
| 11 | Creating a security policy that fits your specific local environment |
| 12 | before making use of ImageMagick is highly advised. You can find guidance on |
| 13 | setting up this policy at https://imagemagick.org/security-policy/, |
| 14 | and it's important to verify your policy using the validation tool located |
| 15 | at https://imagemagick-secevaluator.doyensec.com/. We also strongly |
| 16 | recommend that all users validate their security assumptions by testing their configurations after making any policy changes. This helps ensure that the |
| 17 | intended restrictions are functioning as expected in their specific |
| 18 | deployment environment. |
| 19 | |
| 20 | |
| 21 | Limited ImageMagick security policy: |
| 22 | |
| 23 | The primary objective of the limited security policy is to find a |
| 24 | middle ground between convenience and security. This policy involves the |
| 25 | deactivation of potentially hazardous functionalities, like specific coders |
| 26 | such as SVG or HTTP. Furthermore, it establishes several constraints on |
| 27 | the utilization of resources like memory, storage, and processing duration, |
| 28 | all of which are adjustable. This policy proves advantageous in situations |
| 29 | where there's a need to mitigate the potential threat of handling possibly |
| 30 | malicious or demanding images, all while retaining essential capabilities |
| 31 | for prevalent image formats. |
| 32 | --> |
| 33 | <policymap> |
| 34 | <!-- Set maximum parallel threads. --> |
| 35 | <policy domain="resource" name="thread" value="4"/> |
| 36 | <!-- Set maximum time in seconds. When this limit is exceeded, an exception |
| 37 | is thrown and processing stops. --> |
| 38 | <policy domain="resource" name="time" value="240"/> |
| 39 | <!-- Set maximum number of open pixel cache files. When this limit is |
| 40 | exceeded, any subsequent pixels cached to disk are closed and reopened |
| 41 | on demand. --> |
| 42 | <policy domain="resource" name="file" value="768"/> |
| 43 | <!-- Set maximum amount of memory in bytes to allocate for the pixel cache |
| 44 | from the heap. When this limit is exceeded, the image pixels are cached |
| 45 | to memory-mapped disk. --> |
| 46 | <policy domain="resource" name="memory" value="768MiB"/> |
| 47 | <!-- Set maximum amount of memory map in bytes to allocate for the pixel |
| 48 | cache. When this limit is exceeded, the image pixels are cached to |
| 49 | disk. --> |
| 50 | <policy domain="resource" name="map" value="2GiB"/> |
| 51 | <!-- Set the maximum width * height of an image that can reside in the pixel |
| 52 | cache memory. Images that exceed the area limit are cached to disk. --> |
| 53 | <policy domain="resource" name="area" value="8KP"/> |
| 54 | <!-- Set maximum amount of disk space in bytes permitted for use by the pixel |
| 55 | cache. When this limit is exceeded, the pixel cache is not created |
| 56 | and an exception is thrown. --> |
| 57 | <policy domain="resource" name="disk" value="2GiB"/> |
| 58 | <!-- Set the maximum length of an image sequence. When this limit is |
| 59 | exceeded, an exception is thrown. --> |
| 60 | <policy domain="resource" name="list-length" value="64"/> |
| 61 | <!-- Set the maximum width of an image. When this limit is exceeded, an |
| 62 | exception is thrown. --> |
| 63 | <policy domain="resource" name="width" value="16KP"/> |
| 64 | <!-- Set the maximum height of an image. When this limit is exceeded, an |
| 65 | exception is thrown. --> |
| 66 | <policy domain="resource" name="height" value="16KP"/> |
| 67 | <!-- Periodically yield the CPU for at least the time specified in |
| 68 | milliseconds. --> |
| 69 | <!-- <policy domain="resource" name="throttle" value="2"/> --> |
| 70 | <!-- Do not create temporary files in the default shared directories, instead |
| 71 | specify a private area to store only ImageMagick temporary files. --> |
| 72 | <!-- <policy domain="resource" name="temporary-path" value="/magick/tmp/"/> --> |
| 73 | <!-- Force memory initialization by memory mapping select memory |
| 74 | allocations. --> |
| 75 | <!-- <policy domain="cache" name="memory-map" value="anonymous"/> --> |
| 76 | <!-- Ensure all image data is fully flushed and synchronized to disk. --> |
| 77 | <!-- <policy domain="cache" name="synchronize" value="true"/> --> |
| 78 | <!-- Replace passphrase for secure distributed processing --> |
| 79 | <!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> --> |
| 80 | <!-- Do not permit any delegates to execute. --> |
| 81 | <!-- <policy domain="delegate" rights="none" pattern="*"/> --> |
| 82 | <!-- Do not permit any image filters to load. --> |
| 83 | <!-- <policy domain="filter" rights="none" pattern="*"/> --> |
| 84 | <!-- Don't read/write from/to stdin/stdout. --> |
| 85 | <!-- <policy domain="path" rights="none" pattern="-"/> --> |
| 86 | <!-- don't read sensitive paths. --> |
| 87 | <policy domain="path" rights="none" pattern="/etc/*"/> |
| 88 | <!-- Indirect reads are not permitted. --> |
| 89 | <policy domain="path" rights="none" pattern="@*"/> |
| 90 | <!-- These image types are security risks on read, but write is fine --> |
| 91 | <policy domain="module" rights="write" pattern="{MSL,MVG,PS,SVG,TEXT,URL,XPS}"/> |
| 92 | <!-- This policy sets the number of times to replace content of certain |
| 93 | memory buffers and temporary files before they are freed or deleted. --> |
| 94 | <!-- <policy domain="system" name="shred" value="1"/> --> |
| 95 | <!-- Enable the initialization of buffers with zeros, resulting in a minor |
| 96 | performance penalty but with improved security. --> |
| 97 | <!-- <policy domain="system" name="memory-map" value="anonymous"/> --> |
| 98 | <!-- Set the maximum amount of memory in bytes that are permitted for |
| 99 | allocation requests. --> |
| 100 | <policy domain="system" name="max-memory-request" value="512MiB"/> |
| 101 | </policymap> |