Apache Struts2的Jakarta Multipart parser插件存在远程代码执行漏洞,漏洞编号为CNNVD-201703-152。攻击者可以在使用该插件上传文件时,修改HTTP请求头中的Content-Type值来触发该漏洞,导致远程执行代码。
相关链接如下:https://cwiki.apache.org/confluence/display/WW/S2-045?from=timeline&isappinstalled=0
影响的版本
● Struts 2.3.5 - Struts 2.3.31
● Struts 2.5 - Struts 2.5.10
不受影响的版本
● Struts 2.3.32
● Struts 2.5.10.1
官方解决方案
官方已经发布了版本更新,建议用户升级到不受影响的最新版本(Struts2 2.3.32或Struts 2.5.10.1),下载链接如下所示:
● Struts 2.3.32:
https://github.com/apache/struts/releases/tag/STRUTS_2_3_32
● Struts 2.5.10.1:
https://github.com/apache/struts/releases/tag/STRUTS_2_5_10_1
临时修复方案
在用户不便进行升级的情况下,作为临时的解决方案,用户可以进行以下操作来规避风险:
修改Web-INF/classes目录下的struts.xml中的配置
● 在Web-INF/classes目录下的struts.xml 中的struts 标签下添加<constant name="struts.custom.i18n.resources" value="global" />;
● 在WEB-INF/classes/ 目录下添加 global.properties,文件内容如下:
struts.messages.upload.error.InvalidContentTypeException=1
配置过滤器过滤Content-Type的内容
● 在web应用的web.xml中配置过滤器,在过滤器中对Content-Type内容的合法性进行检测:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws java.io.IOException, ServletException { String contentType = request.getContentType().toLowerCase(Locale.ENGLISH); if (contentType != null && contentType.contains("multipart/form-data") && !contentType.startsWith("multipart/form-data")) { response.getWriter().write("Reject!"); } else { chain.doFilter(request, response); } } |
回复(1)
投票成功