Skip to content

Conversation

robmry
Copy link
Contributor

@robmry robmry commented Mar 8, 2024

- What I did

CVE-2024-29018

Picked up Albin's change from #46609 - and added a regression test.

Commit cbc2a71 makes connect syscall fail fast when a container is only attached to an internal network. Thanks to that, if such a container tries to resolve an "external" domain, the embedded resolver returns an error immediately instead of waiting for a timeout.

This commit makes sure the embedded resolver doesn't even try to forward to upstream servers - this is important when the host's DNS server is running on a localhost address. In this case, the internal resolver's upstream DNS requests are made from the host's network namespace, so they work even when the network is declared as 'internal'. Communication with external DNS servers is unexpected for an internal network.

- How Albin did it

Add a way to enable/disable upstream forwarding to the embedded resolver. When an endpoint joins/leaves a sandbox, this forwarding policy is modified based on whether there's an endpoint providing external connectivity.

- How to verify it

New regression test.

- Description for the changelog

Do not forward requests to external DNS servers for a container that is only connected to an 'internal' network. Previously, requests were forwarded if the host's DNS server was running on a localhost address, like systemd's 127.0.0.53.

- A picture of a cute animal (not mandatory but encouraged)

@robmry robmry requested review from corhere and neersighted March 8, 2024 16:21
@robmry robmry self-assigned this Mar 8, 2024
@robmry robmry added kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. area/networking Networking area/networking/dns Networking labels Mar 8, 2024
@robmry robmry added this to the 26.0.0 milestone Mar 8, 2024
@vvoland vvoland modified the milestones: 26.0.0, 27.0.0 Mar 14, 2024
@robmry robmry force-pushed the libnet-resolver-nxdomain branch from 3a5a6c3 to 999a014 Compare March 14, 2024 11:57
@robmry robmry marked this pull request as ready for review March 14, 2024 11:59
@vvoland vvoland modified the milestones: 27.0.0, 26.0.0 Mar 14, 2024
Copy link
Member

@neersighted neersighted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with one missing comment.

// an internal network. This way, it's the driver responsibility to make sure `connect` syscall fails fast when
// no external connectivity is available (eg. by not setting a default gateway).
sb.resolver = NewResolver(resolverIPSandbox, true, sb)
sb.resolver = NewResolver(resolverIPSandbox, sb.getGatewayEndpoint() != nil, sb)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a comment here that explains the proxyDNS/internal relationship.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's done, thank you.

@robmry robmry force-pushed the libnet-resolver-nxdomain branch from 999a014 to 13d4546 Compare March 14, 2024 14:43
Copy link
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, comments aside

Commit cbc2a71 makes `connect` syscall fail fast when a container is
only attached to an internal network. Thanks to that, if such a
container tries to resolve an "external" domain, the embedded resolver
returns an error immediately instead of waiting for a timeout.

This commit makes sure the embedded resolver doesn't even try to forward
to upstream servers.

Co-authored-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Rob Murray <rob.murray@docker.com>
@robmry robmry force-pushed the libnet-resolver-nxdomain branch from 13d4546 to 790c303 Compare March 14, 2024 17:47
Copy link
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Member

@akerouanton akerouanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for moving this forward.

@DerDakon
Copy link

Shouldn't the GHSA-mq39-4gv4-mvpx package/version list also refer to moby/moby? It's currently only talking about docker.

@neersighted
Copy link
Member

neersighted commented Mar 26, 2024

The name of the Go codebase in this repo is github.com/docker/docker. While the upstream repository is moby/moby, we have not yet completed a migration to the new name, which remains the source of truth for the codebase here.

fruch added a commit to fruch/scylla-cluster-tests that referenced this pull request Mar 26, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: scylladb#7302
Ref: moby/moby#47538
fruch added a commit to fruch/scylla-cluster-tests that referenced this pull request Mar 26, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: scylladb#7302
Ref: moby/moby#47538
@DerDakon
Copy link

DerDakon commented Mar 26, 2024

The name of the Go codebase in this repo is github.com/docker/docker. While the upstream repository is moby/moby, we have not yet completed a migration to the new name, which remains the source of truth for the codebase here.

Correct. But as I read it both packages are equally affected, right? So both should be listed in the advisory, otherwise moby would not be matched by automated tools.

I.e. I'm confused that e.g. GHSA-rc4r-wh2q-q6c4 uses moby/moby but this one does not.

@neersighted
Copy link
Member

neersighted commented Mar 26, 2024

There is only one package; github.com/docker/docker is a redirect to github.com/moby/moby. As far as Go is concerned, there is only one package, as relative imports do not exist.

That GHSA has an incorrect Go package identified, and should be corrected: github/advisory-database#4144.

fruch added a commit to fruch/scylla-cluster-tests that referenced this pull request Mar 26, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: scylladb#7302
Ref: moby/moby#47538
fruch added a commit to fruch/scylla-cluster-tests that referenced this pull request Mar 26, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: scylladb#7302
Ref: moby/moby#47538
@DerDakon
Copy link

There is only one package; github.com/docker/docker is a redirect to github.com/moby/moby. As far as Go is concerned, there is only one package, as relative imports do not exist.

That GHSA has an incorrect Go package identified, and should be corrected: github/advisory-database#4144.

Ok, thanks for the clarification. Here are some more:

@neersighted
Copy link
Member

It sounds like we'll have to reach out to GitHub's security team regarding how they editorialize advisories. Thanks for bringing this to our attention!

fruch added a commit to scylladb/scylla-cluster-tests that referenced this pull request Mar 26, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: #7302
Ref: moby/moby#47538
@robmry robmry deleted the libnet-resolver-nxdomain branch March 27, 2024 16:32
fruch added a commit to scylladb/scylla-cluster-tests that referenced this pull request Apr 2, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: #7302
Ref: moby/moby#47538
(cherry picked from commit b23e17a)
fruch added a commit to scylladb/scylla-cluster-tests that referenced this pull request Apr 2, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: #7302
Ref: moby/moby#47538
(cherry picked from commit b23e17a)
@neersighted
Copy link
Member

#47662 is open to track this regression; please 👍 there instead of commenting on related issues, or adding a "me too."

@jsoriano
Copy link

Hey, I see this change was backported to 25.0 and 23.0, is 24.0 not affected by this issue?

@akerouanton
Copy link
Member

  • 23.0 is the long-term support version that Mirantis bundle in their Container Runtime. IIRC it's also the version currently used by Azure. They're both maintaining it because it's used in their products.
  • Since 26.0 was a fresh new major version when the security fix was released, we (at Docker) decided to backport it to 25.0 to not force Engine users to migrate to 26.0 right away. At this point and AFAIK we (Docker Inc.) don't plan to release any new 25.0 patch release, and I think neither Mirantis nor Microsoft will make it their LTS version.
  • 24.0 is EOL since no company (ie. neither Docker, Mirantis nor Microsoft) have interest into maintaining it. It's affected but unmaintained and thus won't receive the security patch.

@jsoriano
Copy link

@akerouanton thanks for the clarification!

vponomaryov pushed a commit to scylladb/scylla-cluster-tests that referenced this pull request May 22, 2024
since moby/moby#47538, dns isn't forward automaticlly
into internal networks, and we need to create a specfic
network that has a gatway, for it to work as we expect and
forward DNS requests out

Fixes: #7302
Ref: moby/moby#47538
(cherry picked from commit b23e17a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking/dns Networking area/networking Networking kind/enhancement Enhancements are not bugs or new features but can improve usability or performance. process/cherry-picked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants