Skip to content

Validate request method and sanitize streaming request headers - #924

Merged
benoitc merged 1 commit into
masterfrom
fix/streaming-header-and-method-validation
Aug 11, 2026
Merged

Validate request method and sanitize streaming request headers#924
benoitc merged 1 commit into
masterfrom
fix/streaming-header-and-method-validation

Conversation

@benoitc

@benoitc benoitc commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Two gaps in HTTP/1.1 request serialization where a caller-supplied value reached the wire unsanitized.

The streaming path (send_headers_only) built headers with a raw to_list/1 list-comprehension, so CR/LF in a header value was written verbatim and could add extra header lines. It now serializes through hackney_headers:to_iolist/1, the same sanitizing path the buffered request uses.

The method was never validated either, only the path. valid_request_line/2 now checks CR/LF/NUL in both the method and the target at every entry point (request, request_streaming, send_request_headers, open_h2_stream, request_async), returning {error, {invalid_method, _}} for a bad method.

The streaming request path (send_headers_only) serialized headers with a
raw to_list/1 concatenation, so a CR/LF in a header value was written
verbatim and could add extra header lines. Route it through
hackney_headers:to_iolist/1 like the buffered path, which strips CR/LF.

The method was also never checked, only the path. valid_request_line/2
now validates both at every entry point so a CR/LF in either is refused
before it reaches the request line.
@benoitc
benoitc merged commit 8b28c63 into master Aug 11, 2026
6 checks passed
@benoitc benoitc mentioned this pull request Aug 11, 2026
benoitc added a commit that referenced this pull request Aug 11, 2026
Bundles the fixes merged since 4.7.2 (#914/#915, #918/#919, #920, #921,
#922, #924) and the curl-style Content-Length change (#917/#925). Bumps
dependencies to their latest releases: quic 1.8.0, webtransport 0.4.4,
mimerl 1.5.0, cowboy 2.18.0 (test).
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.

1 participant