LXC as a desktop sandbox... Help?
Posted: 28. Apr 2012, 18:29
I'm thinking of using LXC for desktop and home server sandboxing purposes - it's not that secure, IIRC, but I think it should be secure enough for home use if set up right.
Unfortunately, 'lxc-execute' does not seem to set it up right. If I create an LXC named "foo" and run 'lxc-execute -n foo /bin/bash", what I get appears equivalent to the whole root filesystem being mounted -o rbind,rw in the container. If I su to my user account, I see the entire contents of the account's home directory; if I create a file there, it shows up in the real home directory, and if I delete one, it gets deleted in the real home directory. Everyhing is read-write and suid binaries are still suid... In short, it looks like this is a good deal less protection than I would get from something like this:
Am I missing something? How can I tweak Linux containers to limit the access of users in the container to system resources, and to the contents of their normal home directories? Am I barking up the wrong tree here?
Unfortunately, 'lxc-execute' does not seem to set it up right. If I create an LXC named "foo" and run 'lxc-execute -n foo /bin/bash", what I get appears equivalent to the whole root filesystem being mounted -o rbind,rw in the container. If I su to my user account, I see the entire contents of the account's home directory; if I create a file there, it shows up in the real home directory, and if I delete one, it gets deleted in the real home directory. Everyhing is read-write and suid binaries are still suid... In short, it looks like this is a good deal less protection than I would get from something like this:
Code: Select all
for x in lib bin sbin usr etc dev proc sys var tmp; do
mkdir -p /sandbox/$x
mount --rbind /$x /sandbox/$x
mount -o remount,ro,nosuid /sandbox/$x
done
mkdir -p /sandbox/home/username
chown username:users /sandbox/home/username
cp /home/username/.Xauthority /sandbox/home/username
chroot --userspec=username /sandbox /bin/bash