Date: Thu, 30 Jun 2022 08:04:24 +0100 From: Doug Rabson <dfr@rabson.org> To: freebsd-jail@freebsd.org, freebsd-net@freebsd.org Cc: Samuel Karp <me@samuelkarp.com> Subject: Container Networking for jails Message-ID: <CACA0VUgNHPaDUkzgZh48DXtB9KxkLLcWGX=HgH8-yrVYkAEQwQ@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
--000000000000d509bf05e2a4e17e Content-Type: text/plain; charset="UTF-8" I wanted to get a quick sanity check for my current approach to container networking with buildah and podman. These systems use CNI ( https://www.cni.dev) to set up the network. This uses a sequence of 'plugins' which are executables that perform successive steps in the process - a very common setup uses a 'bridge' plugin to add one half of an epair to a bridge and put the other half into the container's vnet. IP addresses are managed by an 'ipam' plugin and an optional 'portmap' plugin can be used to advertise container service ports on the host. All of these plugins run on the host with root privileges. In kubernetes and podman, it is possible for more than one container to share a network namespace in a 'pod'. Each container in the pod can communicate with its peers directly via localhost and they all share a single IP address. Mapping this over to jails, I am using one vnet jail to manage the network namespace and child jails of this to isolate the containers. The vnet jail uses '/' as its root path and the only things which run inside this jail are the CNI plugins. Using the host root means that a plugin can safely call host utilities such as ifconfig and route without having to trust the container's version of them. An important factor here is that the CNI plugins will only be run strictly before the container (to set up) or strictly after (to tear down) - at no point will CNI plugins be executed at the same time as container executables. The child jails use ip4/6=inherit to share the vnet and each will use a root path to the container's contents in the same way as a normal non-hierarchical jail. Can anyone see any potential security problems here, particularly around the use of nested jails? I believe that the only difference between this setup and a regular non-nested jail is that the vnet outlives the container briefly before it is torn down. --000000000000d509bf05e2a4e17e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>I wanted to get a quick sanity check for my current a= pproach to container networking with buildah and podman. These systems use = CNI (<a href=3D"https://www.cni.dev" target=3D"_blank">https://www.cni.dev<= /a>) to set up the network. This uses a sequence of 'plugins' which= are executables that perform successive steps in the process - a very comm= on setup uses a 'bridge' plugin to add one half of an epair=C2=A0to= a bridge and put the other half into the container's vnet. IP addresse= s are managed by an 'ipam' plugin and an optional 'portmap'= plugin can be used to advertise container service ports on the host. All o= f these plugins run on the host with root privileges.</div><div><br></div><= div>In kubernetes and podman, it is possible for more than one container to= share a network namespace in a 'pod'. Each container in the pod ca= n communicate with its peers directly via localhost and they all share a si= ngle IP address.</div><div><br></div><div>Mapping this over to jails, I am = using one vnet jail to manage the network namespace and child jails of this= to isolate the containers. The vnet jail uses '/' as its root path= and the only things which run inside this jail are the CNI plugins. Using = the host root means that a plugin can safely call host utilities=C2=A0such = as ifconfig and route without having to trust the container's version o= f them. An important factor here is that the CNI plugins will only be run s= trictly before the container (to set up) or strictly after (to tear down) -= at no point will CNI plugins be executed at the same time as container exe= cutables.</div><div><br></div><div>The child jails use ip4/6=3Dinherit to s= hare the vnet and each will use a root path to the container's contents= in the same way as a normal non-hierarchical jail.</div><div><br></div><di= v>Can anyone see any potential security problems here, particularly around = the use of nested jails? I believe that the only difference between this se= tup and a regular non-nested jail is that the vnet outlives the container b= riefly before it is torn down.</div><font color=3D"#888888"></font></div> --000000000000d509bf05e2a4e17e--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACA0VUgNHPaDUkzgZh48DXtB9KxkLLcWGX=HgH8-yrVYkAEQwQ>