Skip to content
Race condition Write-up Advanced

The Great Tomcat Escape: How to Outsmart CVE-2024–50379

A time-of-check to time-of-use race condition during JSP compilation in Apache Tomcat could allow an attacker to execute arbitrary code. The vulnerability affects specific versions on case-insensitive file systems with a non-default servlet setting.

medium.com

Published on medium.com

Imagine throwing a party, and just when the fun begins, an uninvited guest named CVE-2024–50379 crashes in. This pesky intruder exploits a time-of-check to time-of-use (TOCTOU) race condition during JSP compilation in Apache Tomcat.

CyferNest Sec, on medium.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 race condition during JSP compilation where a file can be replaced after being checked but before being used, on case-insensitive file systems with the default servlet's readonly parameter set to false.

Impact

An attacker could execute arbitrary code on the server, but only if the system uses a case-insensitive file system and the default servlet's readonly parameter is set to false (a non-default setting).

What the attacker needed

Tomcat version 9.0.0.M1 to 9.0.97, 10.1.0-M1 to 10.1.33, or…; case-insensitive file system (e.g., Windows or macOS); default servlet readonly parameter set to false

The fix

The issue was fixed in Tomcat versions 9.0.98, 10.1.34, and 11.0.2; additionally, set the default servlet's readonly parameter to true and, for Java 8 or 11, set the system property sun.io.useCanonCaches to false.

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 is a flaw in Apache Tomcat, a popular web server for Java applications. A race condition means the server checks something and then uses it, but an attacker can change it in between, like swapping a file after it's been checked. If exploited, an attacker could run their own code 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.

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.