LXC 1.0 Released
lists.linuxcontainers.org
lists.linuxcontainers.org
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-feature...
There is plenty of general advice around, but a complete lack of actionable steps to take.
Or even just:
http://danwalsh.livejournal.com/28545.html
...an selinux sandbox without the containers stuff.
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.
I'm interested in the seccomp option, but it looks pretty intimidating to setup. I suspect I could do much of what I need with AppArmor, but I have no idea how to apply that to a single Docker container.
Edit: I also tried the MBox sandbox, but it doesn't work on Ubuntu.
Apparmor has a rather simple "deny network" rule, which might be a good starting point... but I haven't spent much time with it and not sure how to apply it to one container either. Maybe apply it to the python in the container not the container itself? Might be easier.
FreeBSD's 'capsicum' and Linux's 'seccomp' look like they can conceptually do the same thing, but afaict there isn't yet a good command-line interface to them that lets you drop privileges of unmodified binaries.
This is where I run into trouble - given that I want to sandbox arbitrary code in theory I should be able to define what I want to allow, and then set it up. But the practice seems.. esoteric.
you could give it a go.
I seem to end up doing that a lot, for every single thing I try in this area.
Maybe apply it to the python in the container not the container itself?
That would actually be Python-in-ZeroVM. But yeah, that's an interesting idea.
The other thing is that ZeroVM currently has no networking available via Python. So there is some protection there, too.
My train of thought would be that you'd put the strongest isolation on the outside.
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.
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
[2]: https://www.stgraber.org/2014/01/17/lxc-1-0-unprivileged-con...
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.
http://l3net.wordpress.com/2013/08/25/debian-virtualization-...
I would like to run my IRC bouncer inside a container. I want to make sure that this bouncer only makes outbound connections using an OpenVPN instance running outside the container. I think I need to wire up a tun/tap device to the container. The container also needs to somehow accept connections from my IRC client (directly, not through the VPN) while still concealing the connecting IP. Basically, I don't want my ZNC container or the IRC servers that it connects to to have access to sensitive Ip addresses.
Docker 0.8 added a lot of new features and fixed a lot of bugs but it is still work in progress. I.e. you can't rename containers and have to recreate (remove and create) them.
and thank you guys for the release!
Thanks!