Skip to content

Ignore HTTP/1.1 response header fields whose name is not a token - #1249

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:response-invalid-header-name
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:response-invalid-header-name

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

RFC 9110, section 5.1 requires a field name to be a token. After #1154 and its follow-up, HTTP/2 response headers and HTTP/1.1 trailer fields drop invalid names, but HTTP/1.1 response headers still write them as is. A name such as "bad name" or "X:Y" produces an invalid or misleading header line.

This removes such header fields in Http11Processor.writeHeaders() and logs them with the existing http11processor.response.invalidHeader message, as is already done for header fields that cannot be written.

Checked against a running Tomcat: before the change the HTTP/1.1 response contained "bad name: v1", "x(y): v2" and "X:Y: v4"; with it they are removed and logged, while valid fields are unchanged. The new test in TestHttp11Processor fails without the fix.

RFC 9110, section 5.1 requires a field name to be a token. HTTP/2 response
headers and HTTP/1.1 trailer fields already drop invalid names. HTTP/1.1
response headers still wrote them, so a name such as "bad name" or "X:Y"
produced an invalid or misleading header line. Remove such header fields
and log them, as is already done for header fields that cannot be written.
@arturobernalg
arturobernalg force-pushed the response-invalid-header-name branch from dce8f8b to 0fda29e Compare November 17, 2026 19:11
@arturobernalg arturobernalg changed the title Ignore response header fields whose name is not a token Ignore HTTP/1.1 response header fields whose name is not a token Nov 17, 2026
@arturobernalg

Copy link
Copy Markdown
Member Author

Reworked now that #1154 is merged: the check moved from Response to Http11Processor.writeHeaders(), so it only covers HTTP/1.1 response headers, the case still missing.

@rmaucher

Copy link
Copy Markdown
Contributor

Indeed, when you start accepting one of these, you have to add all of them. Great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants