Skip to content

Reject malformed HTTP/1 header fields and trailers in both classic and async transports. - #724

Closed
arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:http1-header-validation
Closed

arturobernalg wants to merge 1 commit into
apache:masterfrom
arturobernalg:http1-header-validation

Conversation

@arturobernalg

Copy link
Copy Markdown
Member

Validate serialized header fields, including FormattedHeader, to prevent CRLF injection without modifying valid header content.

Add regression tests for both transports, covering requests, responses, and chunked trailers.

@arturobernalg
arturobernalg requested a review from ok2c October 21, 2026 08:49
@ok2c

ok2c commented Oct 21, 2026

Copy link
Copy Markdown
Member

@arturobernalg Why do we need all this?

@arturobernalg

Copy link
Copy Markdown
Member Author

Why do we need all this?
@ok2c
The issue is that FormattedHeader bypasses BasicLineFormatter, allowing CR/LF in the raw buffer to reach the wire with an explicit charset encoder.

@ok2c

ok2c commented Oct 21, 2026

Copy link
Copy Markdown
Member

The issue is that FormattedHeader bypasses BasicLineFormatter, allowing CR/LF in the raw buffer to reach the wire with an explicit charset encoder.

@arturobernalg And to remedy that you suggest we introduce a super expensive scan over each and every header in one of the hottest execution path of the library?

@arturobernalg

Copy link
Copy Markdown
Member Author

@arturobernalg And to remedy that you suggest we introduce a super expensive scan over each and every header in one of the hottest execution path of the library?

Both classic and async transports preserve CR/LF in a raw FormattedHeader when an explicit UTF-8 encoder is configured. The default path replaces them with ?. Confirmed against clean master.
I agree this edge case does not justify scanning every header. The current patch is too broad.

@arturobernalg

Copy link
Copy Markdown
Member Author

@ok2c Please check #725

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