Skip to content
Race condition Write-up Advanced

Deep Dive & POC of CVE-2024-50379 Exploit Tomcat Vulnerability (9

A race condition during JSP compilation in Apache Tomcat on case-insensitive file systems allows an attacker to replace a harmless JSP file with a malicious one, leading to remote code execution. Exploitation requires the default servlet to be configured with write permissions, which is not the default.

Vidhi patel Follow

Published on infosecwriteups.com

In the ever-evolving landscape of cybersecurity, staying ahead of vulnerabilities is crucial for protecting sensitive systems. Recently, a critical security flaw — CVE-2024–50379 — was uncovered in Apache Tomcat, one of the most widely used web application servers globally.

Vidhi patel, on infosecwriteups.com

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 time-of-check time-of-use race condition in Tomcat's JSP compilation on case-insensitive file systems, combined with a misconfiguration that enables write access to the default servlet.

Impact

An attacker could execute arbitrary code on the server, but only if the default servlet is configured with write permissions and the file system is case-insensitive.

What the attacker needed

Tomcat with default servlet write enabled; Case-insensitive file system (e.g., Windows); Ability to upload JSP files

The fix

Upgrade to a patched version (11.0.2, 10.1.34, or 9.0.98) and disable write permissions for the default servlet.

How it was found

  1. Set up a JSP webpage that allows file uploads to the server.
  2. Modify web.xml to enable write permissions for the default servlet and allow JSP uploads.
  3. Upload a harmless JSP file (hello.jsp).
  4. Create a malicious JSP file (HELLO.JSP) that executes a command.
  5. Overwrite the harmless file with the malicious one using a script.
  6. Access the uploaded JSP file to trigger execution.

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.

This bug is a timing problem: the server checks a file and then uses it, but an attacker can swap the file in between. On Windows, file names are not case-sensitive, so 'hello.jsp' and 'HELLO.JSP' are the same file, letting an attacker replace a safe file with a harmful one that runs commands on the server. However, this only works if the server is set up in an unsafe way that allows file uploads and write access.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.