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

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

commit 478c9a1f0b45b9f2d9a76daf61bfa639dcfff4d7
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 34d716d092..afe697ba4a 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -370,6 +370,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) {
@@ -484,9 +489,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 fa32a9c35e..d233815c0d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -281,6 +281,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="Jasper">


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

Reply via email to