目录
昨天收到公司安全部门的通知,说是Spring爆出了安全漏洞,此时网上、公众号里也有好多文章都在讲这个事,实际上对应2个RCE(Remote Code Execution)漏洞,但是发现好多博主把2个漏洞混在一起讲了,很是迷糊。
相关术语如下:
1. 漏洞1:Spring Cloud Function SPEL注入
漏洞1比较明确,有POC,此漏洞仅适用于依赖了Spring Cloud Function的应用,若未依赖相关模块则不受影响。
1.1 POC
具体POC代码可以参见:
https://gitee.com/luoex/spring-cloud-function-rce-CVE-2022-22963
1.2 影响范围
依赖Spring Cloud Function(如spring-cloud-function-context, spring-cloud-function-web, spring-cloud-function-webflux等),
受影响的版本:Spring Cloud Function (3 <= version <= 3.2.2)
1.3 修复方式
目前Spring官方已在2022-03-29发布了对应CVE声明:
https://spring.io/blog/2022/03/29/cve-report-published-for-spring-cloud-function
https://tanzu.vmware.com/security/cve-2022-22963
且同时在2022-03-29发布了Spring Cloud Function对应的修复版本,
- 3.1.x版本需升级到3.1.7
- 3.2.x版本需升级到3.2.3
2. 漏洞2:Spring Beans注入
漏洞2现在没有给出POC,且Spring官方也没有发表声明,只是国外有人声称了发现了Spring Beans这个漏洞,但是并没有披露细节。
目前还不确定漏洞是否真的存在,还是得等Spring官方发布声明为准。不过目前一手资料中也给出了相应的临时处理建议。
2.1 影响范围
- JDK 9.0+
- Spring framework 并且存在spring-beans-*.jar依赖
2.2 修复方式
2.2.1 临时方案1:WAF临时策略
在WAF等网络防护设备上,根据实际部署业务的流量情况,实现对
等字符串的规则过滤,并在部署过滤规则后,对业务允许情况进行测试,避免产生额外影响。
2.2.2 临时方案2:修改代码重新发布
如下2步皆需完成才可起到有效防护。
步骤1:
在代码工程中全局搜索@InitBinder注解,若存在dataBinder.setDisallowedFields方法调用,则需添加黑名单{"class.*", "Class.*", "*.class.*", "*.Class.*"}
(具体添加方式可参见步骤2的的示例代码)。若存在多处则所有对应位置均需添加。
步骤2:
全局创建如下代码(推荐在Controller所在包下创建),并且确保如下代码被Spring框架成功加载。
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 {
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
String[] abd = new String[]{"class.*", "Class.*", "*.class.*", "*.Class.*"};
dataBinder.setDisallowedFields(abd);
}
}
参考:
漏洞1:Spring Cloud Function SPEL注入
https://www.cyberkendra.com/2022/03/rce-0-day-exploit-found-in-spring-cloud.html?m=1
https://nsfocusglobal.com/spring-cloud-function-spel-expression-injection-vulnerability-alert/
https://pizz33.github.io/2022/03/27/%E6%BC%8F%E6%B4%9E%E5%A4%8D%E7%8E%B0-Spring%20Cloud%20Function%20SpEL%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%B3%A8%E5%85%A5/
漏洞1 - Spring官方声明:
https://spring.io/blog/2022/03/29/cve-report-published-for-spring-cloud-function
https://tanzu.vmware.com/security/cve-2022-22963
漏洞2:Spring Beans注入
https://www.springcloud.io/post/2022-03/spring-0day-vulnerability/
https://www.javai.net/post/202203/spring-0day-vulnerability/
https://baijiahao.baidu.com/s?id=1728703063164872458&wfr=spider&for=pc