upatch.dev

CVE-2025-24813

Apache Tomcat: Potential RCE and/or information disclosure and/or information corruption with partial PUT

Refuses the Apache Tomcat partial PUT session file write and load to mitigate CVE-2025-24813.

Critical 9.8VettedKnown exploited

EPSS 99.9%: the estimated chance this CVE is exploited in the next 30 days, as of 24 Nov 2026.

At a glance

CVE-2025-24813 is a critical (CVSS 9.8) vulnerability in Apache Tomcat, published 10 March 2025 and on CISA's Known Exploited Vulnerabilities list. A vetted upatch, cve-2025-24813-tomcat-block, blocks it on running Linux machines with shirudo until Apache Tomcat is upgraded.

Severity
Critical 9.8 CVSS 3.1
Chance of exploitation
99.9% in the next 30 days (EPSS, 24 Nov 2026)
Known exploited
Yes, on CISA’s KEV list since 1 Apr 2025
Weakness
CWE-44, CWE-502, CWE-706
Affected software
Apache Tomcat (Apache Software Foundation)
Upatch status
Vetted, merged into the registry
How to apply
Build, sign and roll out with shirudo

Overview

CVE-2025-24813, "Apache Tomcat: Potential RCE and/or information disclosure and/or information corruption with partial PUT", was published by Apache on 10 March 2025. When the DefaultServlet accepts writes (readonly set to false, off by default), a PUT with a Content-Range header makes Tomcat copy the resource into the web application's work directory under the request path with every / replaced by .. A partial PUT to /evil/session writes work/<engine>/<host>/<app>/.evil.session. When sessions are persisted by a PersistentManager with a FileStore in its default location, which is that same directory, a request carrying the cookie JSESSIONID=.evil makes Tomcat deserialize the attacker's file. That runs code when a deserialization gadget library is on the class path. The same file naming also lets an attacker view or inject content into files uploaded by partial PUT.

Official description

Path Equivalence: 'file.Name' (Internal Dot) leading to Remote Code Execution and/or Information disclosure and/or malicious content added to uploaded files via write enabled Default Servlet in Apache Tomcat. This issue affects Apache Tomcat: from 11.0.0-M1 through 11.0.2, from 10.1.0-M1 through 10.1.34, from 9.0.0.M1 through 9.0.98. The following versions were EOL at the time the CVE was created but are known to be affected: 8.5.0 though 8.5.100. Other, older, EOL versions may also be affected. If all of the following were true, a malicious user was able to view security sensitive files and/or inject content into those files: - writes enabled for the default servlet (disabled by default) - support for partial PUT (enabled by default) - a target URL for security sensitive uploads that was a sub-directory of a target URL for public uploads - attacker knowledge of the names of security sensitive files being uploaded - the security sensitive files also being uploaded via partial PUT If all of the following were true, a malicious user was able to perform remote code execution: - writes enabled for the default servlet (disabled by default) - support for partial PUT (enabled by default) - application was using Tomcat's file based session persistence with the default storage location - application included a library that may be leveraged in a deserialization attack Users are recommended to upgrade to version 11.0.3, 10.1.35 or 9.0.99, which fixes the issue.

Affected versions

Apache Tomcat:

Branch Affected Fixed in
11.0 11.0.0-M1 to 11.0.2 11.0.3
10.1 10.1.0-M1 to 10.1.34 10.1.35
9.0 9.0.0.M1 to 9.0.98 9.0.99
8.5 8.5.0 to 8.5.100 never (end of life)

Kernels: the program uses the inode_create LSM hook prototype that takes the mount's idmap as its first argument, as current mainline and bpf-next do. CO-RE relocates field offsets, not hook argument positions, so on a kernel with the older three-argument hook the verifier should refuse the program, which reads one argument past that hook's end. This was not tested on such a kernel.

Sources

More references from NVD (9)

Mitigation

Two BPF LSM programs return -EPERM to processes whose executable is named java, in an application's work directory (work/<engine>/<host>/<app>/, as in work/Catalina/localhost/ROOT or an embedded Tomcat's work/Tomcat/localhost/ROOT):

Hook Refused
lsm/inode_create Creating a file whose name starts with . directly in that directory
lsm/file_open Opening a file there whose name starts with . and ends in .session

Every file the vulnerable partial PUT writes starts with ., because a request path starts with /. Session ids never do. The file_open program also stops a payload that was planted before the upatch was loaded. Each program tests one byte of the file name first, and returns when it isn't .. A refusal from an earlier BPF LSM program on the same hook is passed on.

The refused per-CPU array counts refusals: key 0 for creates, key 1 for opens.

Side effects

  • Every partial PUT to a vulnerable Tomcat fails with HTTP 500, because its temporary file can't be created. This matches Apache's workaround of disabling partial PUT. Full PUTs keep working.
  • A Java process can't create dot files directly in an application's work directory, or open dot-named .session files there. Tomcat itself never names sessions or compiled JSPs that way, and other files and subdirectories are untouched.
  • Fixed Tomcat releases name their partial PUT temporary file put-part-*, which the upatch leaves alone.
  • Not covered: a JVM started through a launcher whose executable isn't named java, a workDir outside the work/<engine>/<host>/<app> layout, and a dot file that existed before the upatch was loaded and doesn't end in .session (a partial PUT to that path reuses it).

Preemption model and cost

The programs keep no state beyond the refusal counter, which they update with an atomic add, so they're correct under every preemption model, including preemptible RCU and PREEMPT_RT. On nearly every file create and open, a run costs one read of the name's first byte. Only dot-named files go on to the parent-directory and executable-name checks.

The policy

172 lines of BPF C, attached at lsm/inode_create and lsm/file_open.

// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
/*
 * CVE-2025-24813 mitigation for Apache Tomcat (9.0.0.M1-9.0.98,
 * 10.1.0-M1-10.1.34, 11.0.0-M1-11.0.2).
 *
 * A partial PUT (a PUT with Content-Range) to the DefaultServlet, when it
 * is writable, makes Tomcat copy the resource into a file in the web
 * application's work directory named after the request path with every
 * '/' turned into '.': PUT /evil/session writes
 * work/<engine>/<host>/<app>/.evil.session. FileStore keeps sessions in
 * that same directory as <id>.session, so a request with the cookie
 * JSESSIONID=.evil deserializes the attacker's file.
 *
 * Every name the vulnerable code writes there starts with '.', because a
 * request path starts with '/'; session ids never do. So this upatch
 * refuses, to a java process:
 *
 *  - creating a file whose name starts with '.' directly in an
 *    application's work directory (the partial PUT write), and
 *  - opening a file there whose name starts with '.' and ends in
 *    ".session" (the session load, for a payload planted before the
 *    upatch was loaded).
 *
 * The fixed releases write the partial PUT to a "put-part-*" temp file,
 * which this upatch leaves alone, as it leaves every other file of the
 * work directory, the JSP sources and classes below it included.
 */

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_core_read.h>

#define EPERM		1
#define NAME_BUF	64

char _license[] SEC("license") = "Dual BSD/GPL";

enum {
	REFUSED_CREATE,
	REFUSED_OPEN,
	NR_COUNTERS,
};

/* Refusals per CPU, summed on export: refusals are rare, the cost is nil. */
struct {
	__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
	__uint(max_entries, NR_COUNTERS);
	__type(key, __u32);
	__type(value, __u64);
} refused SEC(".maps");

static __always_inline void count(__u32 key)
{
	__u64 *value = bpf_map_lookup_elem(&refused, &key);

	/* A preemptible kernel can interleave two runs on one CPU. */
	if (value)
		__sync_fetch_and_add(value, 1);
}

/* First byte of a dentry's name, or 0 when it cannot be read. */
static __always_inline char first_char(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	char c = 0;

	if (!name || bpf_probe_read_kernel(&c, sizeof(c), name))
		return 0;
	return c;
}

static __always_inline bool name_is(const struct dentry *dentry,
				    const char *want, __u32 want_len)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	char buf[8] = {};

	if (!dentry || BPF_CORE_READ(dentry, d_name.len) != want_len ||
	    want_len > sizeof(buf) - 1)
		return false;
	if (bpf_probe_read_kernel_str(buf, sizeof(buf), name) < 0)
		return false;
	for (__u32 i = 0; i < sizeof(buf) - 1; i++) {
		if (i == want_len)
			return true;
		if (buf[i] != want[i])
			return false;
	}
	return false;
}

/*
 * An application's work directory is work/<engine>/<host>/<app>: the
 * standalone layout is work/Catalina/localhost/ROOT, the embedded one
 * /tmp/tomcat.<port>.<n>/work/Tomcat/localhost/ROOT.
 */
static __always_inline bool is_app_work_dir(const struct dentry *app)
{
	const struct dentry *work = BPF_CORE_READ(app, d_parent, d_parent, d_parent);

	return name_is(work, "work", 4);
}

static __always_inline bool current_is_java(void)
{
	struct task_struct *task = bpf_get_current_task_btf();
	const struct dentry *exe = BPF_CORE_READ(task, mm, exe_file, f_path.dentry);

	return name_is(exe, "java", 4);
}

static __always_inline bool ends_with_session(const struct dentry *dentry)
{
	const unsigned char *name = BPF_CORE_READ(dentry, d_name.name);
	__u32 len = BPF_CORE_READ(dentry, d_name.len);
	char tail[8] = {};

	/* At least one character before ".session", which is 8 long. */
	if (len < 9 || len > 255)
		return false;
	if (bpf_probe_read_kernel(tail, sizeof(tail), name + len - 8))
		return false;
	return tail[0] == '.' && tail[1] == 's' && tail[2] == 'e' &&
	       tail[3] == 's' && tail[4] == 's' && tail[5] == 'i' &&
	       tail[6] == 'o' && tail[7] == 'n';
}

static __always_inline int earlier_verdict(int ret)
{
	/* Keep a refusal an earlier BPF LSM program made, in the range the
	 * verifier accepts for an LSM return value. */
	return ret >= -4095 && ret < 0 ? ret : -EPERM;
}

/*
 * The hook takes the mount's idmap first:
 * LSM_HOOK(int, 0, inode_create, const struct mnt_idmap *idmap,
 *	    struct inode *dir, struct dentry *dentry, umode_t mode).
 * CO-RE relocates field offsets, not argument positions, so the
 * prototype must match the target kernel's hook.
 */
SEC("lsm/inode_create")
int BPF_PROG(cve_2025_24813_create, const struct mnt_idmap *idmap,
	     struct inode *dir, struct dentry *dentry, umode_t mode, int ret)
{
	if (ret)
		return earlier_verdict(ret);
	/* Cheapest test first: nearly no file created is a dot file. */
	if (first_char(dentry) != '.')
		return 0;
	if (!is_app_work_dir(BPF_CORE_READ(dentry, d_parent)) || !current_is_java())
		return 0;
	count(REFUSED_CREATE);
	return -EPERM;
}

SEC("lsm/file_open")
int BPF_PROG(cve_2025_24813_open, struct file *file, int ret)
{
	const struct dentry *dentry = file->f_path.dentry;

	if (ret)
		return earlier_verdict(ret);
	if (first_char(dentry) != '.' || !ends_with_session(dentry))
		return 0;
	if (!is_app_work_dir(BPF_CORE_READ(dentry, d_parent)) || !current_is_java())
		return 0;
	count(REFUSED_OPEN);
	return -EPERM;
}

Process

How this upatch was written, checked and reviewed, from the registry’s history.

  1. 10 Mar 2025CVECVE published
  2. 24 Nov 2026Pull requestPull request #1 openedAdd cve-2025-24813-tomcat-blockshimont
  3. 24 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)
  4. 24 Nov 2026MergeMerged #1shimont
  5. 24 Nov 2026Pull requestPull request #2 openedAdd evidence/ to every entryshimont
  6. 24 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)
  7. 25 Nov 2026MergeMerged #2romanlab
  8. 25 Nov 2026Pull requestPull request #4 openedOne directory per CVE, and a payload and before/after test for every upatchromanlab
  9. 25 Nov 2026MergeMerged #4romanlab
  10. 25 Nov 2026ReviewReviewedqodo-code-review[bot] (automated)

No human review is recorded on GitHub for this upatch yet.

Evidence

On a vulnerable Tomcat 9.0.98, the loaded upatch stopped both exploit steps: the partial PUT wrote no file and a planted session file was no longer deserialized. Normal uploads and sessions kept working.

Tested
24 Nov 2026
Target
Apache Tomcat 9.0.98 on OpenJDK 21.0.13, DefaultServlet readonly=false, PersistentManager with FileStore, commons-collections 3.2.1, loopback only
Kernel
7.4-shirudo-ci-20261123
Architecture
x86_64
Machine
EC2 t3.large
Distribution
Ubuntu 26.04
shirudo
154afeea
Results
StatePartial PUT writes the dot filePlanted .session deserialized (code runs as tomcat)Full PUTNormal session
Before loadingyes (HTTP 409)yes201200
Upatch loadedno (HTTP 500)no201200
After unloadingyes (HTTP 409)yes201200
Two minutes on the lab machine: the exploit runs code as tomcat, the upatch loads without a restart, the same exploit fails, and root cannot remove it.
test-matrix.log Output of the before, loaded and after test run, including the refusal counters and the refused unlink of the link pin.
# cve-2025-24813-tomcat-block test run, 2026-11-24
# Target: Ubuntu 26.04 on EC2 t3.large, kernel 7.4-shirudo-ci-20261123, shirudo 154afeea
# Lab: Apache Tomcat 9.0.98 on OpenJDK 21.0.13, readonly=false, PersistentManager with FileStore,
#      commons-collections 3.2.1, listening on 127.0.0.1 only.
# Each row: a payload is planted with a partial PUT, the planted session is requested,
# then a new partial PUT, a full PUT and a normal session request are made.
before: partialPUT=409 dotfile_written=yes planted_deserialized=yes fullPUT=201 session=200
upatch load: cve-2025-24813-tomcat-block measured, register 62cc605ec359e312fc25d462bec61ce2ddf58910ae3453c22a829deaf53c7a12
loaded: partialPUT=500 dotfile_written=no planted_deserialized=no fullPUT=201 session=200
root touch of dotfile: ok
root rm pin: rm: cannot remove '/run/shirudo/bpffs/upatches/cve-2025-24813-tomcat-block/link_0': Operation not permitted
  key=0: sum=1
  key=1: sum=1
upatch unload: cve-2025-24813-tomcat-block detached and unpinned
after: partialPUT=409 dotfile_written=yes planted_deserialized=yes fullPUT=201 session=200

Use it

Build the upatch from source, sign it with your own shirudo key, and publish it to your own OCI registry. Machines that follow your upatch tree load it within about a minute.

Build and sign
git clone https://github.com/copper-helm/upatch-registry
cd upatch-registry
tools/build <shirudo-checkout> <keys-dir> 1.0.0 upatches/cve-2025-24813
Publish and roll out
shirudo bpm push build/packages/cve-2025-24813-1.0.0.bee oci://<registry>/<namespace>/cve-2025-24813 --keys-dir <keys-dir>
shirudo bpm tree append build/packages/cve-2025-24813-1.0.0.bee oci://<registry>/<namespace>/<tree> --tree-id <tree-id> --keys-dir <keys-dir>