6 ms·
This may be an unpopular opinion, but containers and Docker specifically shouldn't be used to isolate systems for security. It should be used to ease deploymen
by arnon 7y ago
This may be an unpopular opinion, but containers and Docker specifically shouldn't be used to isolate systems for security.
It should be used to ease deployment.
- Leynos 7y agoDoes your recommendation still stand when Docker used in conjunction with SELinux (and SELinux categories for tennancy isolation)?
- dijit 7y agoThat seems like lazy contrarianism. If you put docker inside a VM, and your hypervisor is running in a zone, and you have different zones based on ”role”. Then of course you get the benefits of the zone and the hypervisor. The parent said “docker solves deployment, not isolation”- if you get your isolation another way then there’s no issue with using docker.
- Leynos 7y agoFair enough. :) Docker does have fairly good support for SELinux built in tho (which counts as "using Docker" in my book). And I do like that Docker makes the SELinux fairly straight forward for the simplest usecases (adding :z or :Z to volume directives).
- ownagefool 7y agoProbably slightly more complicated that. Each and every isolation layer can be broken. Why are we using just one? Run well written software. As a user. In a cgroup. With SELinux. On a VM. On Different Tin. With a security monitoring. Patch.
- ovi256 7y ago>Run well written software. As a user. In a cgroup. With SELinux. On a VM. On Different Tin. With a security monitoring. Patch. The analogy you're trying for is surely not that this is as likely to solve the deployement problem for most people just as "Eat food. Not too much. Mostly Plants" is to solve the obesity epidemic for most people ? Not at all ?
- ownagefool 7y agoNo, not most people. Industry professionals deploying applications using frameworks that help with the problem. I probably wouldn't want a fat PT, the same I don't want my sysadmin to be running apps as root.
- pmlnr 7y agoI wanted to write the same; docker is a packaging solution. It's not a security layer.
- baq 7y agoi feel like this is oversimplifying, otherwise we'd be happily running tarballs in chroots. (jails anyone?)
- tty7 7y agohuh, what do you chroot to apt-get/dnf ?
- tecleandor 7y agoI think you can do that bootstrapping, for example, with debootstrap. (I'm talking by memory)
- tty7 7y agoi think you missed my point :)
- tecleandor 7y agoThat's what it seems like :o :P
- tonyarkles 7y agoAbsolutely correct. I've got a cross-compile toolchain set up right now that needs Debian (Ubuntu won't do because of different glibc versions in the cross-compile toolchains). I used debootstrap to make a basic Debian Stretch filesystem, chroot into that, and apt-get the remaining pieces and run the build. Works like a charm, no Docker required. And, unlike containers, it's intentionally persistent so future builds go very quickly.
- loudmax 7y agoContainerization certainly ought to be an isolation layer to boost security. What's unfortunate is how little we can rely on docker to provide any additional security.
- geggam 7y agoGiven that docker is simply an abstraction of the various kernel functions it is arguable that eliminating the docker piece and directly managing the kernel functions would be more secure. Problem there is it requires a significant learning curve and when you get to that point you start evaluating the ROI of containers. Deployment is easy. Operations is easy. Until either one of the two fail. Then debugging becomes a seriously complex problem.
- cpuguy83 7y agoThere are fairly few vulnerabilities discovered in docker itself. The last one was in runc, the underlying container executor... these are very hard to get right. This is kind of a stinky one, though because docker runs in the root context (unless you are experimenting with the rootless docker mode). You could take this same argument to absurd extremes: the kernel is just an abstraction over the hardware, surely you could ditch the kernel and manage the hardware yourself and it will be more secure. The reality is, in both cases, no you can't. Doing this stuff right requires expertise, and generally need more than one or two people looking at it.
- geggam 7y agohttps://www.cvedetails.com/vulnerability-list/vendor_id-13534/Docker.html https://www.cvedetails.com/vulnerability-list/vendor_id-1353... More than a few, less than a horde
- dobin 7y agoIn my opinion, VM's are less secure than containers. VM's provide a large attack surface, while one CAN restrict containers sufficiently. See contained.af. Doesnt mean Docker does this though.
- fwsgonzo 7y agoI'm sorry but that is just false. VMs provide strong isolation which can even be two-way with secure enclaves.
- Tepix 7y agoI think you got it mixed up. The attack surface of a linux kernel is larger than the attack surface of a VM. Simply speaking, VMs only need to properly take care of a few privileged CPU opcodes.
- tapoxi 7y agoAn excellent talk from Red Hat's Dan Walsh: https://www.youtube.com/watch?v=a9lE9Urr6AQ https://www.youtube.com/watch?v=a9lE9Urr6AQ
- mitchell_h 7y agohttps://www.youtube.com/watch?v=hgN8pCMLI2U https://www.youtube.com/watch?v=hgN8pCMLI2U Bryan expresses his opinions on this. When you say Isolate that really should include security.
- asveikau 7y agoThe Unix process, with its uids, is also a form of isolation. But most reasonable people would guess that there are undiscovered privilege escalation bugs in any given kernel and thus be careful who is allowed to put code on a machine.
- cyphar 7y agoIf you take a look at LXC and LXD, I would very much argue you can use them as a security boundary. One of the main problems with Docker is that the most powerful isolation primitive available in Linux -- user namespaces -- is not used by default and doesn't fully utilise the underlying feature. LXC uses unprivileged user namespaces by default, and LXD defaults to user namespaces as well. You can even isolate containers from each other with a basic config option. All of that being said, this bug is caused by container runtimes trusting the rootfs too much. This is something I've been trying to improve but it's definitely not a trivial problem (lots of things require trusting the container processes in specific ways due to limitations in the corresponding kernel APIs -- though I am working on fixing those too).
- PyroLagus 7y agoApparently even user namespaces can't be trusted for secure isolation, so much so that Arch Linux even has them disabled by default[1]. That said, it's possible that security improved since then, and I don't know when the most recent user namespace vulnerability was found. [1] https://lists.archlinux.org/pipermail/arch-general/2017-February/043066.html https://lists.archlinux.org/pipermail/arch-general/2017-Febr...
- the8472 7y agoThat mail is outdated. Arch, like some other distros such as debian, now applies a kernel patch that allows toggling userns support via kernel.unprivileged_userns_clone sysctl.
- PyroLagus 7y agoOh, I'm aware that you can toggle it via sysctl, but it's still not on by default. That said, I can't find any user namespace CVE from 2019, only 2018, so maybe it's safe enough now. I guess "safe enough" is the keyword. If you really worry about the kernel's attack surface, you'll use a separation kernel, VMs, or separate machines altogether.
- cyphar 7y ago
- Tepix 7y agoContainers' raison d'être is to provide isolation. Just like chroot, they are used for security. If the security mechanism fails, it's good to have defense-in-depth, as usual. From reading the article it appears the issue is in Docker, not the container mechanism offered by the kernel upon which Docker builds.
- laumars 7y agoIsolation doesn't mean secure. Some containerisation solutions are designed to provide a security mechanism. Other containerisation solutions, such as Docker, are designed as a development and/or orchestration tool. I do agree that a it's important to have defence in depth
- Tepix 7y agoHis statement was: "but containers and Docker specifically shouldn't be used to isolate systems for security". Well, thousands of companies, such as ISPs offering VPS are using containers for exactly that reason. Containers use cgroups under the hood, a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes. As long as there aren't any bugs in the kernel related to cgroups, security is provided. Saying containers shouldn't be used for security is like saying kernel functions shouldn't be used for security.
- deleted 7y ago[deleted]
- laumars 7y agoI'm not suggesting all containers shouldn't be used for security. I'm just saying docker - specifically - isn't an isolation tool that's was designed primarily as a security tool. There are other solutions on Linux if you want security - such as LXC and OpenVZ - which I suspect is what those ISPs you're referring to use. The problem with docker isn't at the kernel level, it's the userspace tooling. It's pretty insecure by default. For example it creates bridged networks as the default network interface and actively encourages (by design) developers to run code as root (since creating non-root users then becomes a manual RUN command). Then you have vulnerabilities in the user space tools to contend with in addition to the same concerns about sharing a kernel that crop up when discussing security and containerisation. That said, there are some stuff it does right from a security standpoint but generally speaking docker is a tool you need to harden rather than something that comes hardened. I don't hate docker though. It's a great productivity tool and it can be run securely if you have proper defence of depth. But I would advise against running docker as your only sandboxing. To be honest, I'd advise security at all levels regardless of the docker discussion anyway.
- laumars 7y agoIs that an unpopular opinion? I don't think I see many people who do argue about docker from a security standpoint. At least nobody credible. Docker has always been sold as more of an development and orchestration tool than a security one.
- djsumdog 7y agoI wrote an article not too long ago, both on Docker orchestration and security: https://penguindreams.org/blog/my-love-hate-relationship-with-docker-and-container-orchestration-systems/ https://penguindreams.org/blog/my-love-hate-relationship-wit...
- nmjohn 7y agoIf you believe containers cannot be secure, than you should be able to capture the flag and get paid for beating https://contained.af/ https://contained.af/ Having said that, I agree that by default containers are a poor security boundary - but saying they are wholesale inadequate is not accurate.
- ploxiln 7y agocontained.af uses seccomp to block a bunch of syscalls that you would not block for a real service, for example socket()
- cpuguy83 7y agoThis is absolutely untrue. There are things that can be done to enhance the defaults that docker currently provides (b/c defaults are hard to change when you have millions of users), but a process running in a default docker container is absolutely more secure than a process running outside of a container.