chunked: reject nul byte in trailer#21896
Closed
alhudz wants to merge 1 commit into
Closed
Conversation
Member
|
Since verify_header does more checks than so, shouldn't it rather just call that function? |
Trailers are delivered to the application as headers via CLIENTWRITE_TRAILER, but unlike regular response headers they skipped the verify_header() checks, so a server could smuggle a nul byte (or stray CR) into a header reaching CURLOPT_HEADERFUNCTION and curl_easy_header(). Run each assembled trailer line through Curl_verify_header(), the same validation used for normal headers. Covered by the new test 2106.
bfd5b3e to
f7cea4c
Compare
Contributor
Author
|
Good point. Exposed |
bagder
approved these changes
Jun 8, 2026
Member
|
Thanks! |
dkarpov1970
pushed a commit
to dkarpov1970/curl
that referenced
this pull request
Jun 9, 2026
Trailers are delivered to the application as headers via CLIENTWRITE_TRAILER, but unlike regular response headers they skipped the verify_header() checks, so a server could smuggle a nul byte (or stray CR) into a header reaching CURLOPT_HEADERFUNCTION and curl_easy_header(). Run each assembled trailer line through Curl_verify_header(), the same validation used for normal headers. Covered by the new test 2106. Closes curl#21896
dkarpov1970
pushed a commit
to dkarpov1970/curl
that referenced
this pull request
Jun 10, 2026
Trailers are delivered to the application as headers via CLIENTWRITE_TRAILER, but unlike regular response headers they skipped the verify_header() checks, so a server could smuggle a nul byte (or stray CR) into a header reaching CURLOPT_HEADERFUNCTION and curl_easy_header(). Run each assembled trailer line through Curl_verify_header(), the same validation used for normal headers. Covered by the new test 2106. Closes curl#21896
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repro: fetch a chunked HTTP/1 response whose trailer line carries a nul byte, e.g.
chunky-trailer: he\0llo. curl currently accepts it and exits0.Cause:
httpchunk_readwrite()accumulates trailer bytes and forwards them to the client as headers (CLIENTWRITE_TRAILER), so the trailer reaches theCURLOPT_HEADERFUNCTIONcallback andcurl_easy_header(). Regular response headers run throughverify_header(), which rejects an embedded nul, but trailers never do, so a server can smuggle a nul into a header delivered to the application.Fix: reject a nul byte in the trailer parser, matching the
verify_header()behaviour for normal headers.Covered by the new test
2106.