Skip to content

http: trim custom header name before the Authorization drop#22178

Closed
alhudz wants to merge 1 commit into
curl:masterfrom
alhudz:http-custom-header-name-trim
Closed

http: trim custom header name before the Authorization drop#22178
alhudz wants to merge 1 commit into
curl:masterfrom
alhudz:http-custom-header-name-trim

Conversation

@alhudz

@alhudz alhudz commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Repro: -x <proxy> -H "Authorization : s3cr3t" --location against a URL that redirects to a different host forwards the header to the second host.
Cause: the cross-host Authorization/Cookie drop matches the field name parsed up to the :, which keeps the blanks around it, so a padded name like Authorization misses the exact-length compare and the drop is skipped. Curl_add_custom_headers and the proxy CONNECT builder dynhds_add_custom both do this.
Fix: curlx_str_trimblanks() the parsed name before the compare in both builders, the same way the value is already trimmed. test2113 covers it (fails before, passes after; modelled on test317).

A custom header name padded with blanks (`Authorization :`) missed the exact-length compare and slipped past the cross-host Authorization and Cookie drop, forwarding the header to the redirect target. Trim the parsed name in both the request and proxy CONNECT header builders.
@github-actions github-actions Bot added the tests label Jun 25, 2026
@bagder bagder closed this in a36384a Jun 26, 2026
@bagder

bagder commented Jun 26, 2026

Copy link
Copy Markdown
Member

Thanks!

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

Labels

Development

Successfully merging this pull request may close these issues.

2 participants