From 25e5a3a653b10d62ca61461a6bec3ce62a92c7eb Mon Sep 17 00:00:00 2001 From: wk333 <13474090681@163.com> Date: Wed, 18 Jun 2025 10:32:53 +0800 Subject: [PATCH] Fix CVE-2025-48988, CVE-2025-49125 (cherry picked from commit 5c08879e4b8a7070b2180285396b9166aa160cf5) --- CVE-2025-48988.patch | 165 ++++++++++++++++++++++++++++++++ CVE-2025-49125-pre.patch | 202 +++++++++++++++++++++++++++++++++++++++ CVE-2025-49125.patch | 165 ++++++++++++++++++++++++++++++++ tomcat.spec | 10 +- 4 files changed, 540 insertions(+), 2 deletions(-) create mode 100644 CVE-2025-48988.patch create mode 100644 CVE-2025-49125-pre.patch create mode 100644 CVE-2025-49125.patch diff --git a/CVE-2025-48988.patch b/CVE-2025-48988.patch new file mode 100644 index 0000000..bce787f --- /dev/null +++ b/CVE-2025-48988.patch @@ -0,0 +1,165 @@ +From ee8042ffce4cb9324dfd79efda5984f37bbb6910 Mon Sep 17 00:00:00 2001 +From: Mark Thomas +Date: Tue, 3 Jun 2025 16:05:53 +0100 +Subject: [PATCH] Provide finder grained control of multi-part requests + +Origin: https://github.com/apache/tomcat/commit/ee8042ffce4cb9324dfd79efda5984f37bbb6910 + +This exposes two new configuration attributes on the Connector: +- maxPartCount +- maxPartHeaderSize +--- + .../apache/catalina/connector/Connector.java | 24 ++++++++++++++++ + .../apache/catalina/connector/Request.java | 28 +++++++++++++++---- + webapps/docs/config/ajp.xml | 15 ++++++++++ + webapps/docs/config/http.xml | 15 ++++++++++ + webapps/docs/config/http2.xml | 2 ++ + 6 files changed, 78 insertions(+), 6 deletions(-) + +diff --git a/java/org/apache/catalina/connector/Connector.java b/java/org/apache/catalina/connector/Connector.java +index 49d80c884378..59565abf1053 100644 +--- a/java/org/apache/catalina/connector/Connector.java ++++ b/java/org/apache/catalina/connector/Connector.java +@@ -204,6 +204,10 @@ public Connector(ProtocolHandler protocolHandler) { + */ + protected int maxParameterCount = 10000; + ++ private int maxPartCount = 10; ++ ++ private int maxPartHeaderSize = 512; ++ + /** + * Maximum size of a POST which will be automatically parsed by the container. 2 MiB by default. + */ +@@ -463,6 +467,26 @@ public void setMaxParameterCount(int maxParameterCount) { + } + + ++ public int getMaxPartCount() { ++ return maxPartCount; ++ } ++ ++ ++ public void setMaxPartCount(int maxPartCount) { ++ this.maxPartCount = maxPartCount; ++ } ++ ++ ++ public int getMaxPartHeaderSize() { ++ return maxPartHeaderSize; ++ } ++ ++ ++ public void setMaxPartHeaderSize(int maxPartHeaderSize) { ++ this.maxPartHeaderSize = maxPartHeaderSize; ++ } ++ ++ + /** + * @return the maximum size of a POST which will be automatically parsed by the container. + */ +diff --git a/java/org/apache/catalina/connector/Request.java b/java/org/apache/catalina/connector/Request.java +index 6bc8d8096424..ccadd497affc 100644 +--- a/java/org/apache/catalina/connector/Request.java ++++ b/java/org/apache/catalina/connector/Request.java +@@ -2630,13 +2630,29 @@ private void parseParts(boolean explicit) { + upload.setFileItemFactory(factory); + upload.setFileSizeMax(mce.getMaxFileSize()); + upload.setSizeMax(mce.getMaxRequestSize()); +- if (maxParameterCount > -1) { +- // There is a limit. The limit for parts needs to be reduced by +- // the number of parameters we have already parsed. +- // Must be under the limit else parsing parameters would have +- // triggered an exception. +- upload.setFileCountMax(maxParameterCount - parameters.size()); ++ upload.setPartHeaderSizeMax(connector.getMaxPartHeaderSize()); ++ /* ++ * There are two independent limits on the number of parts. ++ * ++ * 1. The limit based on parameters. This is maxParameterCount less the number of parameters already processed. ++ * ++ * 2. The limit based on parts. This is maxPartCount. ++ * ++ * The lower of these two limits will be applied to this request. ++ * ++ * Note: Either of both limits may be set to -1 (unlimited). ++ */ ++ int partLimit = maxParameterCount; ++ if (partLimit > -1) { ++ partLimit = partLimit - parameters.size(); ++ } ++ int maxPartCount = connector.getMaxPartCount(); ++ if (maxPartCount > -1) { ++ if (partLimit < 0 || partLimit > maxPartCount) { ++ partLimit = maxPartCount; ++ } + } ++ upload.setFileCountMax(partLimit); + + parts = new ArrayList<>(); + try { +diff --git a/webapps/docs/config/ajp.xml b/webapps/docs/config/ajp.xml +index 2ee5f5280b01..14ce080f3707 100644 +--- a/webapps/docs/config/ajp.xml ++++ b/webapps/docs/config/ajp.xml +@@ -175,6 +175,21 @@ + exceed the limit.

+ + ++ ++

The maximum total number of parts permitted in a request where the ++ content type is multipart/form-data. This limit is in ++ addition to maxParameterCount. Requests that exceed this ++ limit will be rejected. A value of less than 0 means no limit. If not ++ specified, a default of 10 is used.

++
++ ++ ++

The maximum number of header bytes permitted per part in a request ++ where the content type is multipart/form-data. Requests that ++ exceed this limit will be rejected. A value of less than 0 means no limit. ++ If not specified, a default of 512 is used.

++
++ + +

The maximum size in bytes of the POST which will be handled by + the container FORM URL parameter parsing. The limit can be disabled by +diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml +index 316e02dacd62..a12c740fc1ac 100644 +--- a/webapps/docs/config/http.xml ++++ b/webapps/docs/config/http.xml +@@ -173,6 +173,21 @@ + exceed the limit.

+
+ ++ ++

The maximum total number of parts permitted in a request where the ++ content type is multipart/form-data. This limit is in ++ addition to maxParameterCount. Requests that exceed this ++ limit will be rejected. A value of less than 0 means no limit. If not ++ specified, a default of 10 is used.

++
++ ++ ++

The maximum number of header bytes permitted per part in a request ++ where the content type is multipart/form-data. Requests that ++ exceed this limit will be rejected. A value of less than 0 means no limit. ++ If not specified, a default of 512 is used.

++
++ + +

The maximum size in bytes of the POST which will be handled by + the container FORM URL parameter parsing. The limit can be disabled by +diff --git a/webapps/docs/config/http2.xml b/webapps/docs/config/http2.xml +index 78ec1fe79b8c..0a0d98cb32d1 100644 +--- a/webapps/docs/config/http2.xml ++++ b/webapps/docs/config/http2.xml +@@ -317,6 +317,8 @@ +