Vulnerability & Exploit Database

Back to search

ImageMagick Delegate Arbitrary Command Execution

This module exploits a shell command injection in the way "delegates" (commands for converting files) are processed in ImageMagick versions <= 7.0.1-0 and <= 6.9.3-9 (legacy). Since ImageMagick uses file magic to detect file format, you can create a .png (for example) which is actually a crafted SVG (for example) that triggers the command injection. The PostScript (PS) target leverages a Ghostscript -dSAFER bypass (discovered by taviso) to achieve RCE in the Ghostscript delegate. Ghostscript versions 9.18 and later are affected. This target is provided as is and will not be updated to track additional vulns. For more recent Ghostscript vectors, please see the following modules: exploit/multi/fileformat/ghostscript_failed_restore exploit/unix/fileformat/ghostscript_type_confusion If USE_POPEN is set to true, a |-prefixed command will be used for the exploit. No delegates are involved in this exploitation.

Free Metasploit Download

Get your copy of the world's leading penetration testing tool

 Download Now

Module Name



  • stewie
  • Nikolay Ermishkin
  • Tavis Ormandy
  • wvu <wvu [at]>
  • hdm <x [at]>



  • SVG file
  • MVG file
  • PS file


  • unix


  • cmd



Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':

msf > use exploit/unix/fileformat/imagemagick_delegate msf exploit(imagemagick_delegate) > show targets ...targets... msf exploit(imagemagick_delegate) > set TARGET <target-id> msf exploit(imagemagick_delegate) > show options and set options... msf exploit(imagemagick_delegate) > exploit

Related Vulnerabilities