Skip to content

Commit dbb36a6

Browse files
authored
chore: update to go1.20.8 (#47)
Part of ooni/probe#2524
2 parents a23fe43 + 56b9280 commit dbb36a6

File tree

6 files changed

+42
-14
lines changed

6 files changed

+42
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ the `Request` and `Response` fields;
248248

249249
- [ ] commit the changes and push `merged-main` to gitub;
250250

251-
- [ ] open a PR and merge it *using a merge commit*;
251+
- [ ] open a PR using this check-list as part of the PR text and merge it *using a merge commit*;
252252

253253
- [ ] create a new working branch to update the examples;
254254

UPSTREAM

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
go1.20.6
1+
go1.20.8

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ module github.com/ooni/oohttp
22

33
go 1.20
44

5-
require golang.org/x/net v0.12.0
5+
require golang.org/x/net v0.15.0
66

7-
require golang.org/x/text v0.11.0 // indirect
7+
require golang.org/x/text v0.13.0 // indirect

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50=
2-
golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
3-
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
4-
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
1+
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
2+
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
3+
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
4+
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=

request.go

+22-1
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,29 @@ func (r *Request) write(w io.Writer, usingProxy bool, extraHeaders Header, waitF
586586
if err != nil {
587587
return err
588588
}
589+
// Validate that the Host header is a valid header in general,
590+
// but don't validate the host itself. This is sufficient to avoid
591+
// header or request smuggling via the Host field.
592+
// The server can (and will, if it's a net/http server) reject
593+
// the request if it doesn't consider the host valid.
589594
if !httpguts.ValidHostHeader(host) {
590-
return errors.New("http: invalid Host header")
595+
// Historically, we would truncate the Host header after '/' or ' '.
596+
// Some users have relied on this truncation to convert a network
597+
// address such as Unix domain socket path into a valid, ignored
598+
// Host header (see https://go.dev/issue/61431).
599+
//
600+
// We don't preserve the truncation, because sending an altered
601+
// header field opens a smuggling vector. Instead, zero out the
602+
// Host header entirely if it isn't valid. (An empty Host is valid;
603+
// see RFC 9112 Section 3.2.)
604+
//
605+
// Return an error if we're sending to a proxy, since the proxy
606+
// probably can't do anything useful with an empty Host header.
607+
if !usingProxy {
608+
host = ""
609+
} else {
610+
return errors.New("http: invalid Host header")
611+
}
591612
}
592613

593614
// According to RFC 6874, an HTTP client, proxy, or other

request_test.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -767,16 +767,23 @@ func TestRequestWriteBufferedWriter(t *testing.T) {
767767
}
768768
}
769769

770-
func TestRequestBadHost(t *testing.T) {
770+
func TestRequestBadHostHeader(t *testing.T) {
771771
got := []string{}
772772
req, err := NewRequest("GET", "http://foo/after", nil)
773773
if err != nil {
774774
t.Fatal(err)
775775
}
776-
req.Host = "foo.com with spaces"
777-
req.URL.Host = "foo.com with spaces"
778-
if err := req.Write(logWrites{t, &got}); err == nil {
779-
t.Errorf("Writing request with invalid Host: succeded, want error")
776+
req.Host = "foo.com\nnewline"
777+
req.URL.Host = "foo.com\nnewline"
778+
req.Write(logWrites{t, &got})
779+
want := []string{
780+
"GET /after HTTP/1.1\r\n",
781+
"Host: \r\n",
782+
"User-Agent: " + DefaultUserAgent + "\r\n",
783+
"\r\n",
784+
}
785+
if !reflect.DeepEqual(got, want) {
786+
t.Errorf("Writes = %q\n Want = %q", got, want)
780787
}
781788
}
782789

0 commit comments

Comments
 (0)