Patch/Configuration Management, Vulnerability Management

Not a Pretty Picture: ImageMagick flaw enables remote code execution via uploaded images

Open-source image processing software provider ImageMagick has issued patches and workarounds for a series of recently disclosed vulnerabilities, including one that could allow hackers to remotely execute code via the uploading of maliciously crafted images.

At least one researcher, Ryan Huber, who performs IT security services for Slack, has stated that it is “being used in the wild,” although in an emailed statement to SCMagazine.com, an ImageMagick spokesperson wrote, “We are not personally aware of any specific incidents.” Another security expert, Dan Tentler, founder of Phobos Group, was able to quickly build an exploit and tweeted the proof.

Able to read and write over 200 image file formats, ImageMagick is used in many social media websites, online blogs and content management systems, and its library is leveraged by numerous image-processing plugins.

The vulnerabilities were discovered by Nikolay Ermishkin and "Stewie" — two security researchers associated with the Russian Internet services company Mail.Ru Group. Details on the flaw were revealed today by Mail.Ru via Openwall after the news initially surfaced on an online forum, prompting concerns that bad actors would quickly capitalize. SCMagazine.com has reached out to Mail.Ru and will update this report upon receiving a response. ImageMagick acknowledged the vulnerabilities in lesser detail yesterday on its website.

Of chief concern among the vulnerabilities is CVE-2016-3714, which Huber's website refers as ImageTragick. The vulnerability stems from the insufficient parameter filtering of user-added files that contain external libraries. This flaw makes it possible for bad actors to execute a shell command injection, resulting in remote code execution during the conversion of certain file formats.

In other words, hackers can embed malicious code into seemingly benign image files in order to gain control of a machine. Even if the corrupted file is not in a traditional image file format, the hacker can most likely sneak it past ImageMagick's file check process by simply renaming the file extension—to .jpg or .png, for instance. "ImageMagick tries to guess the type of the file by its content, so exploitation doesn't depend on the file extension,” explained the Mail.Ru vulnerability disclosure.

There were four other disclosed vulnerabilities, the consequences of which potentially include the execution of HTTP GET or FTP requests, and the unauthorized deletion, moving and reading of files using various “pseudo protocols.”

ImageMagick responded by developing patches for versions 7.0.1-1 and 6.9.3-10 (The latter should be available by the weekend, the company stated.) However, Mail.Ru in its disclosure called these measures “incomplete.”

For other versions, ImageMagick has developed a workaround, recommending that users add several statements to their policy.xml configuration file in order to disable vulnerable coders. “For HTTPS, you can also remove support by deleting it from the delegates.xml configuration file,” the company added. For extra security, Mail.Ru also recommends that users “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.”

Bradley Barth

As director of multimedia content strategy at CyberRisk Alliance, Bradley Barth develops content for online conferences, webcasts, podcasts video/multimedia projects — often serving as moderator or host. For nearly six years, he wrote and reported for SC Media as deputy editor and, before that, senior reporter. He was previously a program executive with the tech-focused PR firm Voxus. Past journalistic experience includes stints as business editor at Executive Technology, a staff writer at New York Sportscene and a freelance journalist covering travel and entertainment. In his spare time, Bradley also writes screenplays.

Get daily email updates

SC Media's daily must-read of the most current and pressing daily news

By clicking the Subscribe button below, you agree to SC Media Terms and Conditions and Privacy Policy.