跳转到主要内容
Chinese, Simplified

信息表明 Spring Framework 中已报告了一个 RCE 0day 漏洞。如果目标系统是使用Spring开发的,并且JDK版本高于JDK9,未经授权的攻击者可以利用该漏洞在目标设备上远程执行任意代码。

 

一、漏洞情况分析

Spring框架是Java应用最广泛的轻量级开源框架,在JDK9版本的Spring框架(及以上)中,远程攻击者可以通过框架的参数绑定特性获取AccessLogValve对象,利用恶意字段值触发如果满足某些条件,则管道机制并写入任意路径中的文件。任何路径下的文件。

 

2. 受影响版本影响的漏洞范围

JDK 9.0+

Spring框架及衍生框架spring-beans-*.jar存在

3.漏洞处置建议

临时修复:漏洞的临时修复需要同时执行以下两个步骤。

 

第1步

全局搜索应用程序组以查找 @InitBinder 注释,并查看方法内部是否调用了 dataBinder.setDisallowedFields 方法。如果找到这段代码片段的介绍,将 {"class.*", "Class.*", "*.class.*", "*.Class.*"} 添加到原来的黑名单中。 (注意:如果这个代码片段使用的比较频繁,需要在每个地方追加)

 

第2步

在应用系统的工程包下创建如下全局类,并确保该类被Spring加载(建议添加到Controller所在的包中)。添加类后,需要重新编译和重新打包项目并验证功能,然后重新发布项目。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import org.sptingframework.core.annotation.Order;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllezAdvice;
import org.springframework.web.bind.annotation.InitBinder;
@ControllerAdvice
@Order(10000)
public class Global ControllerAdvice {
    @uitBinder
    public void setAllowedFields(WebDataBinder dataBinder) {
        String[] abd = new String[]{"class.*", "Class.*", "*.class.*", "*.Class.*"};
        dataBinder.setDisallowedFields(abd);
    }
}

修复建议:暂时没有官方安全补丁或最新版本发布。 受影响的客户可以使用第三方防火墙进行防御。

 

参考 https://www.javai.net/post/202203/spring-0day-vulnerability/

Tags
 
Article
知识星球
 
微信公众号
 
视频号