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

rmaucher 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 e0b3f7097e Improve trailer allowed list check
e0b3f7097e is described below

commit e0b3f7097eddc64b68c5dc96d0e46ed2feef6142
Author: remm <[email protected]>
AuthorDate: Tue May 19 14:26:41 2026 +0200

    Improve trailer allowed list check
    
    Otherwise, cookie, host and priority could be set through the trailers.
---
 java/org/apache/coyote/http2/Stream.java | 8 +++++---
 webapps/docs/changelog.xml               | 3 +++
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 40eba2d370..2d3d607d80 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -369,6 +369,11 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
             headerState = HEADER_STATE_REGULAR;
         }
 
+        if (headerState == HEADER_STATE_TRAILER && 
!handler.getProtocol().isTrailerHeaderAllowed(name)) {
+            // Processing trailers and the header is not in the allowed list
+            return;
+        }
+
         switch (name) {
             case ":method": {
                 if (coyoteRequest.getMethod() == null) {
@@ -483,9 +488,6 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
                 break;
             }
             default: {
-                if (headerState == HEADER_STATE_TRAILER && 
!handler.getProtocol().isTrailerHeaderAllowed(name)) {
-                    break;
-                }
                 if ("expect".equals(name) && "100-continue".equals(value)) {
                     coyoteRequest.setExpectation(true);
                 }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f3e34018aa..ad67ab26d0 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -153,6 +153,9 @@
         Ensure that malformed HTTP/2 messages that should trigger a stream 
reset
         do so, rather than triggered a connection close. (markt)
       </fix>
+      <fix>
+        Improve enforcement of header trailer allow list for HTTP/2. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Cluster">


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

Reply via email to