struts2 版本升级2.3.16.3解决多个前缀参数远程命令行漏洞 josn

来源:互联网 发布:简述什么是云计算 编辑:程序博客网 时间:2024/05/20 12:21

先来介绍一下这个漏洞

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

在2.3以下的版本都受这个漏洞的影响

解决办法:目前struts2  2.3.15及以上的版本,对这个漏洞进行了休息,建议升级到2.3.15以上的版本。

测试办法:url:********.action?redirect:http://www.baidu.com/(*****代表要测试地址的url),如果打开的是baidu,则说明有该漏洞。


目前,关于这个漏洞的解决,也就是升级struts的版本的文章,在网上已经有很多,那么,我为什么还要写这篇文章呢?因为每个人在升级的过程中,遇到的问题是不一样的,我把我的升级过程,和遇到的问题,记录在这里,希望对遇到同样问题的人有所帮助,闲话少叙,切入主题:

1、下载struts2 的新版本,这里选择的是2.3.16.3版本。

2、替换jar包:

      新增jar包:

      asm-3.3.jar
asm-commons-3.3.jar
commons-beanutils-1.8.0.jar
commons-collections-3.1.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang-2.4.jar
commons-lang3-3.1.jar
commons-logging-1.1.3.jar
ognl-3.0.6.jar
struts2-codebehind-plugin-2.3.16.3.jar
struts2-config-browser-plugin-2.3.16.3.jar
struts2-convention-plugin-2.3.16.3.jar
struts2-core-2.3.16.3.jar
struts2-json-plugin-2.3.16.3.jar
struts2-spring-plugin-2.3.16.3.jar
xwork-core-2.3.16.3.jar

      删除jar包 :

commons-beanutils-1.6.jar
commons-collections-3.1.jar
commons-fileupload-1.2.1.jar
commons-fileupload-1.2.2.jar
commons-io-1.3.2.jar
commons-lang-2.2.jar
commons-logging.jar
ognl-3.0.jar
struts2-codebehind-plugin-2.2.1.jar
struts2-config-browser-plugin-2.2.1.jar
struts2-convention-plugin-2.2.1.jar
struts2-core-2.2.1.jar
struts2-json-plugin-2.2.1.jar
struts2-spring-plugin-2.2.1.jar
xwork-core-2.2.1.jar

3、java中用到StringUtils的地方,引用改为import org.apache.commons.lang3.StringUtils;

遇到问题:

 1、***************************************************************************
    *                                 WARNING!!!                              *
    *                                                                         *
    * >>> ActionContextCleanUp <<< is deprecated! Please use the new filters! *
    *                                                                         *
    *             This can be a source of unpredictable problems!             *
    *                                                                         *
    *                Please refer to the docs for more details!               *
    *              http://struts.apache.org/2.x/docs/webxml.html              *
    *                                                                         *
    ***************************************************************************

  解决办法:去掉ActionContextCleanUp拦截器,在2.3x以后的版本中ActionContextCleanUp不需要配置。

2、json无法反回值。在action中已经赋值,但是无法反回到页面上
      解决:    <result type="json">
                <param name="root">action</param>
                <param name="includeProperties">
                        success,tip
                </param>
                </result>
      在json配置文件中,增加上面红色代码,感觉不规范,目前没有更好的办法,有可能是struts2紧急升级后的一个bug,期待官方解决。

其它类似class not fond 的问题,在这里没有列出,升级过程中,替换jar包是关键,把这步做好,就不会有大的问题

0 0