Struts2升级版本至2.5.10
来源:互联网 发布:网络用语蛤蟆啥意思 编辑:程序博客网 时间:2024/06/05 16:17
2017年3月6日,Apache Struts2被曝存在远程命令执行漏洞,官方评级为高危,该漏洞是由于在使用基于Jakarta插件的文件上传功能条件下,恶意用户可以通过修改HTTP请求头中的Content-Type值来触发该漏洞,进而执行任意系统命令,导致系统被黑客入侵。
建议:
如果这个版本在Struts2.3.5 到 Struts2.3.31 以及 Struts2.5 到 Struts2.5.10之间则存在漏洞,请升级到struts 2.3.32或2.5.10.1
升级说明:
一、找不到类
java.lang.ClassNotFoundException:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
找不到那得多正常,查看了一下源码,2.5版本已变更了包路径。
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
二、配置好了居然找不到Action
是不是有点怀疑人生了,赶紧去http://struts.apache.org/struts2的官网扒拉扒拉。
由于版本跨度大,2.5版本升级了很多特性,在Struts 2.5中,严格DMI被扩展,它被称为严格方法调用 又名SMI。你可以想象DMI是一个“边境警察”,SMI是一个“税务警察”,并注意内部。使用此版本,SMI默认情况下启用(strict-method-invocation属性默认设置为 true在 struts-default包中),您可以选择禁用它每个包 - 没有全局开关禁用整个应用程序的SMI。
SMI的工作原理如下:
<allowed-methods>/ @AllowedMethods 被定义每个动作 - SMI工作,而不打开它,但只是那些动作(加上<global-allowed-methods/>)
SMI已启用,但没有<allowed-methods>/ @AllowedMethods 被定义 - SMI工作,但只有<global-allowed-methods/>
SMI已禁用-允许调用任何与默认RegEx匹配的操作方法-([A-Za-z0-9_$]*)
您可以使用常量重新定义默认RegEx,如下所示<constant name="struts.strictMethodInvocation.methodRegex"value="([a-zA-Z]*)"/>
在操作定义中使用通配符映射时,SMI有两种方式:
SMI被禁用-任何通配符将被替换为默认的RegEx,即:<action name="Person*"method="perform*">将被翻译成allowedMethod="regex:perform([A-Za-z0-9_$]*)".
启用SMI -不会发生通配符替换,必须严格定义通过注释或<allowed-method/>标记可以访问哪些方法。
也就是说你必须加入这个配置才可以,最好全局设置:
<global-allowed-methods>regex:.*</global-allowed-methods>
三、package中元素顺序的问题
元素类型为"package"的内容必须匹配"(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?
出现此报错,你就要注意了,一定要检查package中 global-allowed-methods 的位置,然后按照报错指定顺序放置配置。
四、可能会出现的问题
如果你的项目中使用的是log4j而不是log4j2,那么问题就来了,你还需要加入log4j-api-2.7.jar 和log4j-core-2.7.jar,并且配置 log4j2.xml(暂且是个空的)。
<?xml version="1.0"encoding="UTF-8"?>
<configurationstatus="error">
<appenders>
</appenders>
<loggers>
<rootlevel="info">
</root>
</loggers>
</configuration>
否则会一直报以下错误,至于为什么,还没深入了解。
ERROR StatusLoggerNolog4j2 configuration file found.Usingdefaultconfiguration:logging only errors to the console.
好了,如果启动没有其他问题,应该就可以访问到久违的Action了。
.
.
.
.
.文章转载:http://mt.sohu.com/20170313/n483222686.shtml
- Struts2升级版本至2.5.10
- Struts2升级版本至2.5.10,高危漏洞又来了
- Struts2升级版本至2.5.10,高危漏洞又来了
- Struts2 版本升级记录
- struts2.5 从老版本升级到2.5版本
- struts2 升级 struts-2.3.32 和 struts-2.5.10以上版本报404错误问题
- Struts2版本2.3.24升级2.5.10.1小结
- struts2升级到2.3.15.1版本
- struts2最新安全漏洞版本升级步骤
- 升级Struts2版本到2.3.28.1,
- struts2 2.5.10.1升级至2.5.13
- struts2 2.3.32 升级至2.5.10.1
- 关于struts2升级2.5版本后不能用通配符的解决方法
- Struts2从版本2.2.1升级至2.3.15.1出现的问题
- Struts2命令执行漏洞--(升级struts至struts-2.3.28.1版本)
- Struts2.1.8.1 升级至Struts2.3.20
- struts2.3升级到2.5
- struts2 升级至2.3.32
- 每天一个 Linux 命令(57):ss命令
- Android中在Button控件上显示倒计时
- table标签
- 高速ADC时钟jitter对信噪比和有效位数的影响
- 蓝桥杯打印十字
- Struts2升级版本至2.5.10
- 关于javascript闭包与重构
- Java学习一
- javascript面向对象 -- 构造函数
- Spring通过XML配置c3p0连接池和dao层注解注入使用 jdbcTemplate
- 小朋友排队(归并)
- 利用百度orc的图像识别
- hibernate手动配置
- 安卓工程师入门——ImageView