Spring4Shell RCE
CVE-2022-22965 is a remote code execution bug in Spring MVC data binding on JDK 9 and newer. By steering the object properties that Spring binds from request parameters, an attacker reaches the class loader and writes a file into the server. The exploit only works when the app runs as a WAR on Tomcat, which is exactly how this challenge is deployed. A default Spring Boot jar would not be vulnerable.
The target is a small bakery blog. The vulnerable endpoint is a POST to /blogposts/posts. The common approach writes a web shell through the data-binding trick, then calls it to run commands. The flag sits where the vulnerability lets you read it.
How to reach it
Run the challenge locally with its docker-compose. The flagger sidecar writes your per-run flag into the container before it starts. The app is at http://localhost:8080/blogposts/.
Run this challenge
Spin it up locally with Docker. The flagger sidecar fetches a per-run flag into a shared volume, then the challenge container boots and reads it.
services:
flagger:
image: matejbasic/rootcause-flagger:1.0
environment:
ROOTCAUSE_API_URL: https://root-cause-api.matejbasic.com
ROOTCAUSE_API_KEY: ${ROOTCAUSE_API_KEY}
ROOTCAUSE_CHALLENGE: spring4shell
FLAG_PATH: /flag/flag.txt
volumes:
- flag:/flag
challenge:
image: matejbasic/cve-2022-22965:1.0
depends_on:
flagger:
condition: service_completed_successfully
environment:
FLAG_PATH: /flag/flag.txt
volumes:
- flag:/flag
ports:
- "8080:8080"
volumes:
flag:
rootcause start spring4shellThe rootcause CLI does all of this in one command. Running a challenge needs your API key, which you generate in your profile.