Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

Chore: harden ImageMagick policy

shamoon41953c78468d
diff --git a/docker/rootfs/etc/ImageMagick-6/paperless-policy.xml b/docker/rootfs/etc/ImageMagick-6/paperless-policy.xml
index 095355706..7943ca56e 100644
--- a/docker/rootfs/etc/ImageMagick-6/paperless-policy.xml
+++ b/docker/rootfs/etc/ImageMagick-6/paperless-policy.xml
@@ -68,7 +68,14 @@
<!-- <policy domain="resource" name="thread" value="4"/> -->
<!-- <policy domain="resource" name="throttle" value="0"/> -->
<!-- <policy domain="resource" name="time" value="3600"/> -->
- <!-- <policy domain="coder" rights="none" pattern="MVG" /> -->
+ <!-- Paperless does not process SVG or ImageMagick scripting formats. -->
+ <policy domain="coder" rights="none" pattern="SVG" />
+ <policy domain="coder" rights="none" pattern="SVGZ" />
+ <policy domain="coder" rights="none" pattern="MSVG" />
+ <policy domain="coder" rights="none" pattern="RSVG" />
+ <policy domain="coder" rights="none" pattern="MSL" />
+ <policy domain="coder" rights="none" pattern="MVG" />
+ <policy domain="coder" rights="none" pattern="EPHEMERAL" />
<!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
<!-- <policy domain="delegate" rights="none" pattern="HTTPS" /> -->
<!-- <policy domain="path" rights="none" pattern="@*" /> -->
@@ -78,8 +85,6 @@
<!-- <policy domain="system" name="pixel-cache-memory" value="anonymous"/> -->
<!-- <policy domain="system" name="shred" value="2"/> -->
<!-- <policy domain="system" name="precision" value="6"/> -->
- <!-- not needed due to the need to use explicitly by mvg: -->
- <!-- <policy domain="delegate" rights="none" pattern="MVG" /> -->
<!-- use curl -->
<policy domain="delegate" rights="none" pattern="URL" />
<policy domain="delegate" rights="none" pattern="HTTPS" />
diff --git a/docs/setup.md b/docs/setup.md
index 821200140..528d0abc5 100644
--- a/docs/setup.md
+++ b/docs/setup.md
@@ -416,22 +416,15 @@ to a positive number to enable polling and disable native filesystem notificatio
You may need to change the path in the files. Example:
`ExecStart=/opt/paperless/.local/bin/celery --app paperless worker --loglevel INFO`
-12. Configure ImageMagick to allow processing of PDF documents. Most
- distributions have this disabled by default, since PDF documents can
- contain malware. If you don't do this, Paperless-ngx will fall back to
- Ghostscript for certain steps such as thumbnail generation.
-
- Edit `/etc/ImageMagick-6/policy.xml` and adjust
-
- ```
- <policy domain="coder" rights="none" pattern="PDF" />
- ```
-
- to
-
- ```
- <policy domain="coder" rights="read|write" pattern="PDF" />
- ```
+12. Configure ImageMagick to allow processing of PDF documents and disable
+ formats that Paperless-ngx does not use. Most distributions disable PDF
+ processing by default, since PDF documents can contain malware. If you
+ don't enable it, Paperless-ngx will fall back to Ghostscript for certain
+ steps such as thumbnail generation.
+
+ Configure the active ImageMagick policy file (commonly
+ `/etc/ImageMagick-6/policy.xml` or `/etc/ImageMagick-7/policy.xml`) and
+ adjust similar to [the docker policy file](https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/refs/heads/main/docker/rootfs/etc/ImageMagick-6/paperless-policy.xml). You should also include restrictions as noted there.
**Optional: Install the [jbig2enc](https://ocrmypdf.readthedocs.io/en/latest/jbig2.html) encoder.**
This will reduce the size of generated PDF documents. You'll most likely need to compile this yourself, because this