struts2 漏洞分析与防护方案 CVE-2017-5638 S2-045 除了升级外还是有修复方案的

【IT168 评论】关注网络安全的朋友们,想必最近两天已经被一个高危漏洞刷屏,其来势汹汹让不少网络安全圈内人士咋舌。近日,多家网络安全公司发现并曝光了全球最为流行的Java Web服务器框架之一的Apache Struts2存在漏洞。而这一漏洞最终也被Struts2官方确认,其漏洞编号为S2-045,CVE编号:cve-2017-5638,并将其定级为高危漏洞。

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 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);
		}

	}


转:http://toutiao.secjia.com/struts2-vulnerability-analysis-and-protection-cve-2017-5638

猜你喜欢

转载自hanxin0311.iteye.com/blog/2364961