As Arstechnica have recently reported, there is a critical security vulnerability in ImageMagick, an image processing library used by many websites. While official patches are being worked on, this is a reccomended workaround to secure ImageMagick on Debian.
1. Check loaded Imagick policies
From a terminal, check to see if any policies are loaded. There will almost certainly be none returned if you’ve not configured any previously.
convert -list policy
2. Open Imagick’s policy.xml file
In Debian, you can find the ImageMagick policy file in /etc/ImageMagick:
nano /etc/ImageMagick/policy.xml
In other operating systems your best bet is to run a find:
find /usr | grep "policy.xml"
3. Edit policy.xml
Now we need to edit policy.xml. The current reccomended settings related to the vulnerability are here: https://gist.github.com/rawdigits/d73312d21c8584590783a5e07e124723 It’s best to check this URL for the latest version. Alternatively here’s the code at time of writing:
<policymap> <policy domain="coder" rights="none" pattern="EPHEMERAL" /> <policy domain="coder" rights="none" pattern="URL" /> <policy domain="coder" rights="none" pattern="HTTPS" /> <policy domain="coder" rights="none" pattern="MVG" /> <policy domain="coder" rights="none" pattern="MSL" /> </policymap>
Remember it’s Ctrl + x to exit nano and you do want to save the changes. If you’re told you don’t have write permissions try closing the file and opening it again with sudo.
4. Check the Imagick policy is loaded
Now re-run the first step to make sure the policy has been loaded properly.
convert -list policy
You should get the following output:
# Path: [built-in] Policy: Undefined rights: None Path: /etc/ImageMagick/policy.xml Policy: Coder rights: None pattern: EPHEMERAL Policy: Coder rights: None pattern: URL Policy: Coder rights: None pattern: HTTPS Policy: Coder rights: None pattern: MVG Policy: Coder rights: None pattern: MSL
For more details on the problem, check out the ArsTechnica post here, and the ImageMagick forum announcement on the subject here.
Official patches are due to be distributed over the weekend, but may take longer to enter your distributions package manager.