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

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

commit 50ed843bea6f71728ca20c6fa804a2d0931cb28d
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 bde3b6c2b1..8dcae75fdb 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -376,6 +376,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) {
@@ -491,9 +496,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 277abe3eda..c1ea3d98cc 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -145,6 +145,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