libnetwork icon indicating copy to clipboard operation
libnetwork copied to clipboard

IPv6 security should match IPv4

Open grigorig opened this issue 5 years ago • 4 comments

Docker abuses IPv4 NAT to create a private network for containers. Ports opened by containers are by default not available from the public internet and need to be mapped/forwarded explicitly. When IPv6 is enabled for Docker, all of that goes out of the window and what's worse is that there is NO indication about this at all to the user.

Docker should use a stateful packet filter to mirror a similar setup with IPv6, i.e.:

  • Block access to Docker's IPv6 network from the outside world by default
  • Port numbers explicitly configured as exposed by a container can then be used to let through traffic to specific IP/port combinations to containers
  • There should probably be an option to fully expose a container if that is desired

Of course there are some limitations as well: as there is no NAT, there is no way to remap ports. But that should not a serious issue in practice because after all every container gets its own address.

grigorig avatar May 29 '20 09:05 grigorig

I think this should be fixed by https://github.com/moby/libnetwork/pull/2572 (not yet in a release, but will probably included as an experimental feature for docker 20.10)

thaJeztah avatar Nov 23 '20 10:11 thaJeztah

As far as I can tell, that MR implements IPv6 NAT as an optional mode of operation for IPv6. This is a completely different matter. Please reopen.

grigorig avatar Nov 23 '20 11:11 grigorig

Ah, right, so the intent here is to not use IPv6 NAT (the default, routable IPv6 addresses for containers), but still block access?

I can reopen, but I think generally firewall rules to block access are out of scope for the rules that the daemon sets up.

/cc @arkodg

thaJeztah avatar Nov 23 '20 11:11 thaJeztah

I don't really see how that is out of scope. NAT indirectly forces a default-block policy in a sense. The same can be achieved with regular routing and a stateful filter. And if Docker doesn't handle this, the whole "port publishing" functionality doesn't make much sense.

grigorig avatar Nov 23 '20 11:11 grigorig