This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 9c91bba7a4 Reject HTTP/1.0 requests with a transfer-encoding header
9c91bba7a4 is described below
commit 9c91bba7a4f4270453f70b9f2cadaca5fc992f89
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 | 16 ++++++++++------
java/org/apache/coyote/http11/LocalStrings.properties | 1 +
test/org/apache/coyote/http11/TestHttp11Processor.java | 3 +--
webapps/docs/changelog.xml | 4 ++++
4 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/java/org/apache/coyote/http11/Http11Processor.java
b/java/org/apache/coyote/http11/Http11Processor.java
index dd1a18022b..14743ba1ac 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -805,14 +805,18 @@ public class Http11Processor extends AbstractProcessor {
// HTTP 1.x header from a 1.x client unless the specs says otherwise.
MessageBytes transferEncodingValueMB =
headers.getValue("transfer-encoding");
if (transferEncodingValueMB != null) {
- List<String> encodingNames = new ArrayList<>();
- if (TokenList.parseTokenList(headers.values("transfer-encoding"),
encodingNames)) {
- for (String encodingName : encodingNames) {
- addInputFilter(inputFilters, encodingName);
+ if (http11) {
+ List<String> encodingNames = new ArrayList<>();
+ if
(TokenList.parseTokenList(headers.values("transfer-encoding"), encodingNames)) {
+ for (String encodingName : encodingNames) {
+ addInputFilter(inputFilters, encodingName);
+ }
+ } else {
+ // Invalid transfer encoding
+
badRequest("http11processor.request.invalidTransferEncoding");
}
} else {
- // Invalid transfer encoding
- badRequest("http11processor.request.invalidTransferEncoding");
+
badRequest("http11processor.request.transferEncodingWithHttp10");
}
}
diff --git a/java/org/apache/coyote/http11/LocalStrings.properties
b/java/org/apache/coyote/http11/LocalStrings.properties
index 66ac995771..642b02f971 100644
--- a/java/org/apache/coyote/http11/LocalStrings.properties
+++ b/java/org/apache/coyote/http11/LocalStrings.properties
@@ -37,6 +37,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
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 64a08ec045..c21a7b0cac 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -412,6 +412,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 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]