SPRING FRAMEWORK反射型文件下载漏洞(CVE-2020-5421)

一、综述

近日,VMware Tanzu发布安全公告,公布了一个存在于Spring Framework中的反射型文件下载(Reflected File Download,RFD)漏洞CVE-2020-5421。CVE-2020-5421 可通过jsessionid路径参数,绕过防御RFD攻击的保护。先前针对RFD的防护是为应对 CVE-2015-5211 添加的。

攻击者通过向用户发送带有批处理脚本扩展名的URL,使用户下载并执行文件,从而危害用户系统。

官方已发布修复了漏洞的新版本。

Spring Framework是 Java 平台的一个开源全栈应用程序框架和控制反转容器实现,一般被直接称为 Spring。

二、影响范围

受影响产品版本

  • Spring Framework 5.2.0 – 5.2.8
  • Spring Framework 5.1.0 – 5.1.17
  • Spring Framework 5.0.0 – 5.0.18
  • Spring Framework 4.3.0 – 4.3.28
  • 以及其他已不受支持的版本

不受影响产品版本

  • Spring Framework 5.2.9
  • Spring Framework 5.1.18
  • Spring Framework 5.0.19
  • Spring Framework 4.3.29

三、解决方案

官方已发布修复了漏洞的新版本,建议相关用户尽快升级进行防护。

四、项目整改示例

涉及相关jar包:

更换为:

 涉及配置文件:spring-mvc.xml

<!-- 支持返回json(避免IE在ajax请求时,返回json出现下载 ) -->
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
        <property name="messageConverters">
            <list>
            <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>  
                <ref bean="mappingJacksonHttpMessageConverter"/>
            </list>
        </property>
    </bean>
    <bean id="mappingJacksonHttpMessageConverter"
          class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/plain;charset=UTF-8</value>
                <value>application/json;charset=UTF-8</value>
            </list>
        </property>
    </bean>

更改为:

<!-- 支持返回json(避免IE在ajax请求时,返回json出现下载 ) -->
    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="messageConverters">
            <list>
            <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>  
                <ref bean="mappingJacksonHttpMessageConverter"/>
            </list>
        </property>
    </bean>
    <bean id="mappingJacksonHttpMessageConverter"
          class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>text/plain;charset=UTF-8</value>
                <value>application/json;charset=UTF-8</value>
            </list>
        </property>
    </bean>

 完毕!

原文地址:https://www.cnblogs.com/penghq/p/13712899.html