Repository navigation
handle the Host header case-insensitively - #678
Merged
Merged
Conversation
A Host header passed via -H was only applied when the name was exactly "Host". Any other casing (e.g. -H 'host: example.com') was silently ignored, and with --no-canonicalize-headers it was sent as a second Host header next to the one derived from the URL.
Collaborator
|
thanks! |
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.
A Host header passed with
-His only used when the name is spelled exactlyHost. Any other casing is silently dropped, so the requests go out with the Host from the URL.NewHTTPClientcomparesh.Name == "Host", while header names are matched case-insensitively everywhere else (fuzz mode already useshttp.CanonicalHeaderKeyfor this). With--no-canonicalize-headersthe lowercase name also goes intoreq.Headeras is, andnet/httponly filters the canonicalHostkey, so it is written as an extra header.This uses
http.CanonicalHeaderKeyfor the check and skips the Host entry when copying the custom headers, since it is already applied throughreq.Host.Testing:
TestRequestHostHeaderinlibgobuster/http_test.go(thehost,HOSTand-nchcases fail without the change)go vet ./...,go test -race -cover ./...,gofumpt -l .,golangci-lint run ./...dirandfuzzmode: Host istarget.localforhost:,HOST:and-nch -H 'host: ...'