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

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


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

commit 1ad63de866a6e7007304ebe5165f72e65ece32b6
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 a5a566e337..3bfa923ec9 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -823,9 +823,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) {
@@ -835,6 +835,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 a930f68fc3..2692a8183a 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 2f7dedf113..0d264ca476 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 357edcbc37..2887a7aae8 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -257,6 +257,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