client: define a "dummy" hostname to use for local connections#45942
client: define a "dummy" hostname to use for local connections#45942thaJeztah merged 4 commits intomoby:masterfrom
Conversation
|
I also opened #45943 to verify the combination of this patch with go1.20.6. |
|
Ah, looks like I overlooked a test; |
9ae0fb8 to
859ef78
Compare
|
Looks like we need more code updated; From #45943 |
pkg/plugins/client.go
Outdated
| return transport.NewHTTPTransport(tr, scheme, socket), nil | ||
| return transport.NewHTTPTransport(tr, scheme, dummyHost), nil |
There was a problem hiding this comment.
Arf.. this needs more work;
=== FAIL: pkg/plugins TestFailOnce (15.02s)
time="2023-07-12T13:13:54Z" level=warning msg="Unable to connect to plugin: plugin.moby.localhost/Test.FailOnce: Post \"http://plugin.moby.localhost/Test.FailOnce\": dial tcp: lookup plugin.moby.localhost on 10.100.0.2:53: no such host, retrying in 1s"
time="2023-07-12T13:13:55Z" level=warning msg="Unable to connect to plugin: plugin.moby.localhost/Test.FailOnce: Post \"http://plugin.moby.localhost/Test.FailOnce\": dial tcp: lookup plugin.moby.localhost on 10.100.0.2:53: no such host, retrying in 2s"
time="2023-07-12T13:13:57Z" level=warning msg="Unable to connect to plugin: plugin.moby.localhost/Test.FailOnce: Post \"http://plugin.moby.localhost/Test.FailOnce\": dial tcp: lookup plugin.moby.localhost on 10.100.0.2:53: no such host, retrying in 4s"
time="2023-07-12T13:14:01Z" level=warning msg="Unable to connect to plugin: plugin.moby.localhost/Test.FailOnce: Post \"http://plugin.moby.localhost/Test.FailOnce\": dial tcp: lookup plugin.moby.localhost on 10.100.0.2:53: no such host, retrying in 8s"
client_test.go:62: Post "http://plugin.moby.localhost/Test.FailOnce": dial tcp: lookup plugin.moby.localhost on 10.100.0.2:53: no such host
a8b2770 to
9d24ef4
Compare
|
And more to fix; |
9d24ef4 to
61a41ba
Compare
|
Some more; |
61a41ba to
08aaec1
Compare
corhere
left a comment
There was a problem hiding this comment.
There is a more standards-compliant choice of Host header value for local communications: the empty string.
client/client.go
Outdated
| // For local communications (npipe://, unix://), the hostname is not used, | ||
| // but we need valid and meaningful hostname. |
There was a problem hiding this comment.
If the authority component is missing or undefined for the target URI, then a client MUST send a Host header field with an empty field-value.
The authority component is undefined for the unix scheme, therefore the empty string is the valid and meaningful host name to use.
08aaec1 to
d565fe6
Compare
corhere
left a comment
There was a problem hiding this comment.
Getting Go's HTTP client infrastructure to cooperate with sending an empty Host request header is going to be a big uphill battle which likely would require substituting a non-trivial amount of the machinery with custom implementations. Let's just stick with the *.localhost dummy strings for now. localhost is a reserved TLD, and UNIX domain sockets are only accessible on the local host, so it is a logical, future-proof and fairly self-documenting choice.
2df6195 to
c025300
Compare
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Docker daemon started to fail at handling most local connections when being compiled with Go 1.19.11, which addresses CVE-2023-29406 by blocking invalid host headers of HTTP/1. As a workaround, Docker started to define a dummy host header, and to use it for local connections. Backport the fixes to Flatcar to avoid failures. See also moby/moby#45935, moby/moby#45942.
Docker daemon started to fail at handling most local connections when being compiled with Go 1.19.11, which addresses CVE-2023-29406 by blocking invalid host headers of HTTP/1. As a workaround, Docker started to define a dummy host header, and to use it for local connections. Backport the fixes to Flatcar to avoid failures. See also moby/moby#45935, moby/moby#45942.
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Docker client and daemon started to fail at sending or handling most local connections when being compiled with Go 1.19.11, which addresses CVE-2023-29406 by blocking invalid host headers of HTTP/1. As a workaround, Docker started to define a dummy host header, and to use it for local connections. Backport the fixes to Flatcar to fix the runtime failures. See also moby/moby#45935, moby/moby#45942.
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
Go 1.20.6 and 1.19.11 include a security check of the http Host header: golang/go#60374 docker-cli does not satisfy this check: $ docker exec -it ctr bash http: invalid Host header This is a backported patch to fix this issue: Issue: moby/moby#45935 Upstream PR: moby/moby#45942 The upstream PR has been merged and will be included in v24.0.5. Signed-off-by: Christian Stewart <christian@aperture.us>
As a security fix, Go implemented stricter checks for the Host header in the http package. This breaks the Go Docker client library [1] resulting in "http: invalid Host header" errors in our integration tests. A fix [2] was merged to the 24.0 branch, but is not yet included in a release. Therefore, this commit updates the dependency to a specific commit (`go get -u github.com/docker/docker@24.0`). Once it's included in a release, this can be switched back to using a release version. [1] moby/moby#45935 [2] moby/moby#45942
* NR-100933 chore: upgrade to Go 1.20 * ci: set high severity threshold for snyk (#40) * fix: pin to 1.20.5 for test image see testcontainers/testcontainers-go#1359 and moby/moby#45942 --------- Co-authored-by: Roger Coll <rogercoll@protonmail.com>
For local communications (npipe://, unix://), the hostname is not used, but we need valid and meaningful hostname.
The current code used the client's
addras hostname in some cases, which could contain the path for the unix-socket (/var/run/docker.sock), which gets rejected by go1.20.6 and go1.19.11 because of a security fix for CVE-2023-29406 , which was implemented in https://go.dev/issue/60374.Prior versions go Go would clean the host header, and strip slashes in the process, but go1.20.6 and go1.19.11 no longer do, and reject the host header.
This patch introduces a
DummyHostconst, and uses this dummy host for cases where we don't need an actual hostname.Before this patch (using go1.20.6):
With this patch applied:
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)