|
| 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/. |
| 20 | + Web-safe ImageMagick security policy: |
| 21 | + This security protocol designed for web-safe usage focuses on situations |
| 22 | + where ImageMagick is applied in publicly accessible contexts, like websites. |
| 23 | + It deactivates the capability to read from or write to any image formats |
| 24 | + other than web-safe formats like GIF, JPEG, and PNG. Additionally, this |
| 25 | + policy prohibits the execution of image filters and indirect reads, thereby |
| 26 | + thwarting potential security breaches. By implementing these limitations, |
| 27 | + the web-safe policy fortifies the safeguarding of systems accessible to |
| 28 | + the public, reducing the risk of exploiting ImageMagick's capabilities |
| 29 | + for potential attacks. |
| 30 | + --> |
| 31 | +<policymap> |
| 32 | + <!-- Set maximum parallel threads. --> |
| 33 | + <policy domain="resource" name="thread" value="2"/> |
| 34 | + <!-- Set maximum time to live in seconds or neumonics, e.g. "2 minutes". When |
| 35 | + this limit is exceeded, an exception is thrown and processing stops. --> |
| 36 | + <policy domain="resource" name="time" value="60"/> |
| 37 | + <!-- Set maximum number of open pixel cache files. When this limit is |
| 38 | + exceeded, any subsequent pixels cached to disk are closed and reopened |
| 39 | + on demand. --> |
| 40 | + <policy domain="resource" name="file" value="768"/> |
| 41 | + <!-- Set maximum amount of memory in bytes to allocate for the pixel cache |
| 42 | + from the heap. When this limit is exceeded, the image pixels are cached |
| 43 | + to memory-mapped disk. --> |
| 44 | + <policy domain="resource" name="memory" value="256MiB"/> |
| 45 | + <!-- Set maximum amount of memory map in bytes to allocate for the pixel |
| 46 | + cache. When this limit is exceeded, the image pixels are cached to |
| 47 | + disk. --> |
| 48 | + <policy domain="resource" name="map" value="512MiB"/> |
| 49 | + <!-- Set the maximum width * height of an image that can reside in the pixel |
| 50 | + cache memory. Images that exceed the area limit are cached to disk. --> |
| 51 | + <policy domain="resource" name="area" value="16KP"/> |
| 52 | + <!-- Set maximum amount of disk space in bytes permitted for use by the pixel |
| 53 | + cache. When this limit is exceeded, the pixel cache is not be created |
| 54 | + and an exception is thrown. --> |
| 55 | + <policy domain="resource" name="disk" value="1GiB"/> |
| 56 | + <!-- Set the maximum length of an image sequence. When this limit is |
| 57 | + exceeded, an exception is thrown. --> |
| 58 | + <policy domain="resource" name="list-length" value="16"/> |
| 59 | + <!-- Set the maximum width of an image. When this limit is exceeded, an |
| 60 | + exception is thrown. --> |
| 61 | + <policy domain="resource" name="width" value="4KP"/> |
| 62 | + <!-- Set the maximum height of an image. When this limit is exceeded, an |
| 63 | + exception is thrown. --> |
| 64 | + <policy domain="resource" name="height" value="4KP"/> |
| 65 | + <!-- Periodically yield the CPU for at least the time specified in |
| 66 | + milliseconds. --> |
| 67 | + <policy domain="resource" name="throttle" value="2"/> |
| 68 | + <!-- Do not create temporary files in the default shared directories, instead |
| 69 | + specify a private area to store only ImageMagick temporary files. --> |
| 70 | + <!-- <policy domain="resource" name="temporary-path" value="/magick/tmp/"/> --> |
| 71 | + <!-- Force memory initialization by memory mapping select memory |
| 72 | + allocations. --> |
| 73 | + <policy domain="cache" name="memory-map" value="anonymous"/> |
| 74 | + <!-- Ensure all image data is fully flushed and synchronized to disk. --> |
| 75 | + <policy domain="cache" name="synchronize" value="true"/> |
| 76 | + <!-- Replace passphrase for secure distributed processing --> |
| 77 | + <!-- <policy domain="cache" name="shared-secret" value="secret-passphrase" stealth="true"/> --> |
| 78 | + <!-- Do not permit any delegates to execute. --> |
| 79 | + <policy domain="delegate" rights="none" pattern="*"/> |
| 80 | + <!-- Do not permit any image filters to load. --> |
| 81 | + <policy domain="filter" rights="none" pattern="*"/> |
| 82 | + <!-- Don't read/write from/to stdin/stdout. --> |
| 83 | + <policy domain="path" rights="none" pattern="-"/> |
| 84 | + <!-- don't read sensitive paths. --> |
| 85 | + <policy domain="path" rights="none" pattern="/*"/> |
| 86 | + <!-- allow access to required paths. --> |
| 87 | + <policy domain="path" rights="read|write" pattern="/var/bigbluebutton/*"/> |
| 88 | + <policy domain="path" rights="read|write" pattern="/tmp/*"/> |
| 89 | + <!-- Indirect reads are not permitted. --> |
| 90 | + <policy domain="path" rights="none" pattern="@*"/> |
| 91 | + <!-- Deny all image modules and specifically exempt reading or writing |
| 92 | + web-safe image formats. --> |
| 93 | + <policy domain="module" rights="none" pattern="*" /> |
| 94 | + <policy domain="module" rights="read | write" pattern="{BMP,GIF,JPEG,PDF,PNG,TIFF,WEBP}"/> |
| 95 | + <policy domain="module" rights="read | write" pattern="{MPC}" stealth="true"/> |
| 96 | + <policy domain="module" rights="write" pattern="{JSON,INFO,PNM,PS,SVG}"/> |
| 97 | + <!-- This policy sets the number of times to replace content of certain |
| 98 | + memory buffers and temporary files before they are freed or deleted. --> |
| 99 | + <policy domain="system" name="shred" value="1"/> |
| 100 | + <!-- Enable the initialization of buffers with zeros, resulting in a minor |
| 101 | + performance penalty but with improved security. --> |
| 102 | + <policy domain="system" name="memory-map" value="anonymous"/> |
| 103 | + <!-- Set the maximum amount of memory in bytes that are permitted for |
| 104 | + allocation requests. --> |
| 105 | + <policy domain="system" name="max-memory-request" value="256MiB"/> |
| 106 | +</policymap> |
0 commit comments