Do priviledged containers have a different view on the filesystem + general container security?


#1

Using system containers most of the root filesystem should be similar. But what about /proc and /sys or maybe other ones? Would there be differences between e.g. /proc in an priviledged and /proc in an unpriviledged container? Can you determine from inside the container if it is running priviledged or not? From what I read you would at least need root for that and you could indirectly check if e.g. mount fails or loading kernel modules. What other operations would not be possible in an unpriviledged container (in particular for a normal user)? Or could you just say everything is allowed which is also allowed for the user which started the container. For instance, if I start the container as root every protection would be gone even if it is an unpriviledged one?
How could you make detection of a container from the inside harder in general? Could you hide mount points or change files in /proc or /sys?
Can you boot the average installation of ubuntu or debian in an unpriviledged container?


#2

(talking about LXD)

Containers are set of processes that run under a specific set of UIDs.
When this set of UIDs are not in use on the host, you get unprivileged containers.

If, however, the set of processes of a container reuses the UIDs of the host, then you get privileged containers.

A typical Linux distribution uses UIDs between 0 and 65535 (in practice: between 0 and 1000).
In unprivileged LXD containers, the container uses UIDs that are higher than 65535, therefore there is no chance to coincide with a UID of a process on the host.

You can read this a bit more eloquently at https://help.ubuntu.com/lts/serverguide/lxd.html.en#lxd-uid

If you create a container as root, by default it will be unprivileged.
You need to specify security.privileged=true if you want to make a container privileged.
You can do so either when you launch a new container, or on an existing container. If the container already exists, you need to restart it after you set that flag.


#3

Thanks for the reply. Is there some way to spoof or hide information in /proc or /sys inside the container from the outside? I want to make it harder for people to gather information about the host. I could come up with some custom apparmor profiles which restricts access to those. I’m not sure though if this would be best implemented on the inside or the outside. The ideal case for me would be spoofing, but I could not yet come up with something beyond LD_PRELOAD inside the container or nesting the application inside the container into another container. But I think in the latter case apparmor can’t be used anymore.