This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new e590588ab7 Reject HTTP/1.0 requests with a transfer-encoding header
e590588ab7 is described below
commit e590588ab7649c93d49b0eb7b3152700a977880d
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 9172073405..a7d144f334 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -834,9 +834,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) {
@@ -846,6 +846,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 184ca2e19b..5ce2af51d0 100644
--- a/java/org/apache/coyote/http11/LocalStrings.properties
+++ b/java/org/apache/coyote/http11/LocalStrings.properties
@@ -44,6 +44,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 2692d29ec8..8ac68c1541 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 fd7511bde9..dc06028581 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -265,6 +265,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]