3 ms·
Can someone talk about LXC security in practice? I've read[1], and it is excellent to have options, but there I'd like guidance for what is actually usable and
by nl 13y ago
Can someone talk about LXC security in practice?
I've read[1], and it is excellent to have options, but there I'd like guidance for what is actually usable and useful, especially via Docker.
Background: I want to be able to execute arbitrary code submitted from the web. At the moment I'm sandboxing it inside a ZeroVM[2] container, inside a Docker (LXC) container.
I'd like to lock down the Docker container more than the default (eg, disable outgoing network connections), but I don't really know where to start.
(And yes, I do find it strange that it was easier to get an entirely new, experimental and undocumented container running inside LXC than it was to work out how to configure LXC. But layers are good, right?)
[1] https://www.stgraber.org/2014/01/01/lxc-1-0-security-features/ https://www.stgraber.org/2014/01/01/lxc-1-0-security-feature...
[2] http://zerovm.org/ http://zerovm.org/
- zobzu 13y agolayers of containers wont give you much. the main issue is the shared kernel, any bug there, any shared resource from there, and all containers have the same risk, no matter how many levels of nesting you have. layers of vm's, lxc containers, zerovms, etc, will probably make the attacks harder, but also the management, and speed, will suffer, and the security/useability trade off will probably not be adequate (given how fast vm's start anyway, if you want more isolation, you could just use a VM then) Zerovm is nice, but it requires porting, and of course, is not a silver bullet either.
- falconfunction 13y agoLibvirt and virtsandbox might help?
- nl 13y agoCould you be more specific? There is plenty of general advice around, but a complete lack of actionable steps to take.
- groks 13y agohttp://sandbox.libvirt.org/quickstart/ http://sandbox.libvirt.org/quickstart/ Or even just: http://danwalsh.livejournal.com/28545.html http://danwalsh.livejournal.com/28545.html ...an selinux sandbox without the containers stuff.
- justincormack 13y agoVeroZM is a perfectly correct answer, that is exactly what it is designed for. The security model is excellent, far better guarantees than anything you will get from containers. If you want another answer that works, well what kind of code is it? That does make some difference. I am assuming it is some scripting language (as I presume you are not compiling it for zerovm). And I assume it is not one with a trustable sandboxing model (I only really trust Lua, and that is with caveats). You can lock down networking by not having any (assume you use eg a pipe to communicate), or with iptables, or by using seccomp mode 2 filter system calls. The third is the most general extra filtering, but you do need to know exactly what your container needs to do - the more minimal it is the better.
- tinco 13y agoZeroVM is very interesting, but my intuition would be to put the Docker container inside the ZeroVM, instead of the ZeroVM inside the Docker container. Is my intuition weird? Perhaps I misunderstand ZeroVM. My train of thought would be that you'd put the strongest isolation on the outside.
- justincormack 13y agoYou can't do that. Zerovm does not give you access to the system calls to create containers.
- shykes 13y agoDocker is evolving towards a generic "container engine" with swappable execution backends. In that architecture, lxc becomes one possible backend. ZeroVM, OpenVZ, kvm/qemu or plain chroot could be used as backends under the same management API.
- jimmcslim 13y agoInteresting, but at that point doesn't Docker just become libvirt almost?
- 13y ago
- willvarfar 13y agoDefence is best in depth. Put all your login etc on a separate box. Have that box send code to the dedicated runner box to be run. Boot your runner's host OS from CD and reboot each midnight too. Plus the zerovm in docker and everything you already have. And look at firewalling and rescinding capabilities to further isolate the sandbox.
- pekk 13y agoIf you want security, just use a VM designed for isolation rather than something obscure or experimental or primarily aimed at other use cases.
- nl 13y agoIsn't isolation the primary use case of ZeroVM? Although I'll concede the "experimental" bit.
- cjbprime 13y agoMy understanding is that recent (13.10+) Ubuntu ships with an AppArmor profile that blocks known ways of escalating out of the container. So, LXC under Ubuntu is in better shape than LXC on other distros, where you can use the uevent_helper trick[1] to easily escape the container. It sounds like your use case could also use the new unprivileged containers[2] feature, which is going to be a dramatic increase in security (since even if you somehow get access to run a command on the host container, it would not be as root). [1]: http://blog.bofh.it/debian/id_413 http://blog.bofh.it/debian/id_413 [2]: https://www.stgraber.org/2014/01/17/lxc-1-0-unprivileged-containers/ https://www.stgraber.org/2014/01/17/lxc-1-0-unprivileged-con...
- persepolist123 13y agoThis is a nice blog post about isolating your container network stack using LXC: http://l3net.wordpress.com/2013/08/25/debian-virtualization-lxc-network-isolation/ http://l3net.wordpress.com/2013/08/25/debian-virtualization-...