Skip to content

Commit 63727cc

Browse files
committed
http2: validate Host header before sending
Verify that the Host header we send is valid. Avoids sending a request that the server will reject, possibly sending us into a retry loop. No test in this CL, but this will be covered by the net/http test added in CL 506996. For golang/go#60374 Change-Id: I78867eb05293ad8ca1b02bc22fb626760949d4b8 Reviewed-on: https://go-review.googlesource.com/c/net/+/506995 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Tatiana Bradley <[email protected]>
1 parent 1bb09e6 commit 63727cc

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

Diff for: http2/transport.go

+3
Original file line numberDiff line numberDiff line change
@@ -1880,6 +1880,9 @@ func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trail
18801880
if err != nil {
18811881
return nil, err
18821882
}
1883+
if !httpguts.ValidHostHeader(host) {
1884+
return nil, errors.New("http2: invalid Host header")
1885+
}
18831886

18841887
var path string
18851888
if req.Method != "CONNECT" {

0 commit comments

Comments
 (0)