Bug 1334188 (CVE-2016-5239)

Summary: CVE-2016-5239 ImageMagick,GraphicsMagick: Gnuplot delegate vulnerability allowing command injection
Product: [Other] Security Response Reporter: Adam Mariš <amaris>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: jhorak, sardella, scorneli, security-response-team, slawomir, yozone
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
It was discovered that ImageMagick did not properly sanitize certain input before passing it to the gnuplot delegate functionality. A remote attacker could create a specially crafted image that, when processed by an application using ImageMagick or an unsuspecting user using the ImageMagick utilities, would lead to arbitrary execution of shell commands with the privileges of the user running the application.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-08 02:51:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1341777, 1341778, 1341779, 1341780    
Bug Blocks: 1333419, 1334189    

Description Adam Mariš 2016-05-09 06:53:22 UTC
It was found that gnuplot delegate functionality in ImageMagick and GraphicsMagick allows system command injection while interpreting gnuplot files.

Upstream patch (ImageMagick):

http://git.imagemagick.org/repos/ImageMagick/commit/70a2cf326ed32bedee144b961005

Upstream patch (GraphicsMagick):

http://hg.code.sf.net/p/graphicsmagick/code/rev/45998a25992d

Comment 2 Adam Mariš 2016-05-23 14:08:15 UTC
Public via:

http://www.openwall.com/lists/oss-security/2016/05/09/1

Comment 4 errata-xmlrpc 2016-06-16 22:48:02 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6
  Red Hat Enterprise Linux 7

Via RHSA-2016:1237 https://access.redhat.com/errata/RHSA-2016:1237

Comment 7 Stefan Cornelius 2016-08-11 11:03:04 UTC
To clear things up a bit:

* gnuplot files should not be processed when coming from an untrusted source, as they can contain dangerous commands.
* ImageMagick does not care. If it detects a gnuplot file, it tries to delegate it to gnuplot.

If gnuplot is not installed or ImageMagick can't launch gnuplot, there should be no issue.

RHEL5 specific: The gnuplot delegation in RHEL5 is broken due to an unrelated issue. ImageMagick fails to launch gnuplot correctly, thus preventing this attack vector.