CVE-2024-50379: Apache Tomcat Race Condition Vulnerability Leads
A race condition in Apache Tomcat's JSP compilation on case-insensitive file systems allows an attacker to upload a malicious JSP file that is then executed. This can lead to remote code execution on the server.
Published on infosecwriteups.com
Apache Tomcat is an open-source web server and servlet container developed by the Apache Software Foundation (ASF). It is designed to execute Java-based web applications, providing a “pure Java” HTTP server environment for running Java Servlets, JavaServer Pages (JSP), and other Java-based web technologies.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a race condition in Tomcat's file handling during JSP compilation, where the file type check and the subsequent use of the file are not atomic, allowing a malicious file to be executed.
Impact
Attackers could upload and execute malicious JSP files, gaining control of the server and potentially accessing sensitive data.
What the attacker needed
Windows (case-insensitive file system); Tomcat with readonly=false; Ability to send HTTP requests
The fix
Upgrade to Apache Tomcat 11.0.2, 10.1.34, or 9.0.98 or later, and set the readonly parameter to true and disable the HTTP PUT method.
How it was found
- Set up a Windows 10 virtual machine with Java and Apache Tomcat 10.1.33.
- Install Turbo Intruder in Burp Suite.
- Edit conf\web.xml to set the readonly parameter to false for DefaultServlet.
- Restart Tomcat and browse to the server.
- Send a request to Turbo Intruder and run a script that repeatedly sends PUT requests for .Jsp files and GET requests for .jsp files.
- Check for successful responses and access the uploaded JSP file to execute commands.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Tomcat is a Java web server. When it compiles JSP pages, it checks the file type and then uses it. On Windows, file names are not case-sensitive, so 'test.Jsp' and 'test.jsp' are the same file. An attacker can quickly send many requests to upload a malicious file and then request it as a JSP, hoping the server executes it before it realises it's not a valid JSP. This lets the attacker run commands on the server.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.