Using imagemagick securely

Imagemagick supports a very wide range of image codecs. Parsing
file formats is a complex task and mistakes in parsing files
can often lead to security vulnerabilities. Debian puts considerable
effort into identifying and backporting security fixes into
released distributions, but there's a number of recommendations
to harden your use of imagemagick:

1. Restrict codecs to what's actually in use
Many image supported image codecs are likely irrelevant to your
setup. Imagemagick supports a policy mechanism to control which
formats are supported, so when you use imagemagick e.g. as a
service it's strongly recommended to configure the supported
formats. Further information can be found at
https://wiki.debian.org/imagemagick/security

2. Configuring memory limits / monitor memory usage
When using imagemagick as a library in a service (e.g. through
PHP) we recommend setting memory limits within your application
or your init system in combination with monitoring for memory
usage. Bugfixes for memory leaks or memory exhaustion are usually
not backported to released versions of Debian.