This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new bf44bee23d Reject HTTP/1.0 requests with a transfer-encoding header
bf44bee23d is described below

commit bf44bee23d97fbb1a64cbbbb213ff2b6506d26c4
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Aug 20 15:44:17 2026 +0100

    Reject HTTP/1.0 requests with a transfer-encoding header
---
 java/org/apache/coyote/http11/Http11Processor.java     | 8 +++++---
 java/org/apache/coyote/http11/LocalStrings.properties  | 1 +
 test/org/apache/coyote/http11/TestHttp11Processor.java | 3 +--
 webapps/docs/changelog.xml                             | 4 ++++
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 555ff5880d..e96577c31a 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -835,9 +835,9 @@ public class Http11Processor extends AbstractProcessor {
         // Parse transfer-encoding header
         // HTTP specs say an HTTP 1.1 server should accept any recognised
         // HTTP 1.x header from a 1.x client unless the specs says otherwise.
-        if (!http09) {
-            MessageBytes transferEncodingValueMB = 
headers.getValue("transfer-encoding");
-            if (transferEncodingValueMB != null) {
+        MessageBytes transferEncodingValueMB = 
headers.getValue("transfer-encoding");
+        if (transferEncodingValueMB != null) {
+            if (http11) {
                 List<String> encodingNames = new ArrayList<>();
                 if 
(TokenList.parseTokenList(headers.values("transfer-encoding"), encodingNames)) {
                     for (String encodingName : encodingNames) {
@@ -847,6 +847,8 @@ public class Http11Processor extends AbstractProcessor {
                     // Invalid transfer encoding
                     
badRequest("http11processor.request.invalidTransferEncoding");
                 }
+            } else {
+                
badRequest("http11processor.request.transferEncodingWithHttp10");
             }
         }
 
diff --git a/java/org/apache/coyote/http11/LocalStrings.properties 
b/java/org/apache/coyote/http11/LocalStrings.properties
index 7d9fe90f1f..91a3c18bd8 100644
--- a/java/org/apache/coyote/http11/LocalStrings.properties
+++ b/java/org/apache/coyote/http11/LocalStrings.properties
@@ -40,6 +40,7 @@ http11processor.request.nonNumericContentLength=The request 
contained a content-
 http11processor.request.prepare=Error preparing request
 http11processor.request.process=Error processing request
 http11processor.request.sni=The host header does not match the SNI host
+http11processor.request.transferEncodingWithHttp10=The transfer-encoding 
header is not supported for HTTP/1.0 or earlier
 http11processor.request.unsupportedEncoding=Error preparing request, 
unsupported transfer encoding [{0}]
 http11processor.request.unsupportedVersion=Error preparing request, 
unsupported HTTP version [{0}]
 http11processor.response.finish=Error finishing response
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index b87c7da917..ede3a14286 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -1972,8 +1972,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 
         client.connect();
         client.processRequest();
-        Assert.assertTrue(client.isResponse200());
-        Assert.assertTrue(client.getResponseBody().contains("test - data"));
+        Assert.assertTrue(client.isResponse400());
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index caedf241be..e0d10ec855 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -241,6 +241,10 @@
         Fix OpenSSL support for CRLs when using OpenSSL trust with the server
         key held in a Java key store. (markt)
       </fix>
+      <fix>
+        Reject HTTP/1.0 or earlier requests that send a
+        <code>transfer-encoding</code> header. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to