I’m trying to set up an LXC container. I’m not an expert on the inner workings of the Linux kernel. I just want to get something running and be confident that it’s sandboxed.
As I understand it, if I map the users in the container to user 100000 etc, then I can rely on the Linux user permissions, and I don’t need to worry about the AppArmor settings being too lax or anything like that. (Apart from the caveat about ipv6 router advertisements.)
The container is stored in the directory ~/.local/share/lxc/mycontainer/
. It consists of the file config
, owned by me, and the directory rootfs/
, which is owned by user 100000, who is mapped to the root user inside the container. This is how the container was created, and it seems reasonable to me.
However, the mycontainer/
directory itself is owned by user 100000. This means (AIUI) that a malicious container-root could delete the config file (since they own the containing directory) and create a new file to replace it. They could then set idmaps so that, on the next restart of the container, container-root would be mapped to my main user, not 100000. In short, they could escalate privileges to masquerade as me.
I don’t know why that directory is owned by an unprivileged user. I tried changing the owner to myself, but then the container failed to start.
Is it safe to start the container with this setup, in the absence of other protections such as AppArmor? Or is there a way to change the permissions and still be able to start the container?