Struts2属于老框架了,最近爆出漏洞,先看看漏洞描述:
Apache Struts2 框架是一个用于开发 Java EE 网络应用程序的 Web 框架。如果开发人员通过使用%{…}语法应用了强制 OGNL 求值,某些tag的属性可以执行双重求值。对不受信任的用户输入使用强制OGNL求值可能会导致远程执行代码。
官方通告:https://cwiki.apache.org/confluence/display/WW/S2-061
解决方案:升级struts到最新版本:Apache Struts version >= Struts 2.5.26
struts2升级不能简单替换jar包实现,目前最新版本为:2.5.26。
升级方案如下:
1.删除xwork-core-2.3.35.jar
2.修改web.xml的struts启动类配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
3.修改struts.xml配置2.0改为2.5
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
4.新增或替换以下jar包
commons-io-2.6.jar
commons-lang3-3.8.1.jar
log4j-api-2.12.1.jar
ognl-3.1.28.jar
struts2-core-2.5.26.jar
struts2-jfreechart-plugin-2.5.26.jar
struts2-json-plugin-2.5.26.jar
struts2-junit-plugin-2.5.26.jar
struts2-spring-plugin-2.5.26.jar
5.重要提醒:确保服务器端使用jdk1.7+