-
Couldn't load subscription status.
- Fork 9
limitations
- Understanding unprivileged Linux namespaces
- The
suidandsgidbits are ignored sudowill failchownwill mostly fail- Other syscalls may fail
-
lxrootcreates virtual software environments via Linux namespaces.- For more info, see
user_namespaces(7)andnamespaces(7). - More specifically:
lxrootuses what I call "unprivileged" Linux namespaces. - That is,
lxrootuses only namespace features that are available to non-root users. - Unprivileged Linux namespaces, by their very nature, have limitations.
- Lxroot inherits these limitations.
- Understanding the limitations of unprivileged namespaces will help you understand (and adapt to)
lxroot's own limitations. - There are both advantages and limitations to using unprivileged namespaces.
- For more info, see
- Advantages
-
root-access is not required. - Safety and security:
- A process running inside an
lxrootenvironment is limited by the Linux kernel itself. - In other words, provided that there are no bugs in the Linux kernel: a process will only be able to perform actions that can be performed by the non-root user who ran
lxroot.
- A process running inside an
- Performance: namespace functionality is built into the Linux kernel and therefore may be more efficient than alternative virtualization technologies.
-
- Limitations
-
root-access is not available to a process running inside the unprivileged namespace. - The
suidandguidbits are ignored. Consequently: (a) privileged escalation is impossible, and (b) all processes run with the same non-rootuidandgid.- Aside: Two different users may both
lxrootinto the same directory. In this case, two different virtual environments are created that happen to share the same directories and files. This can be useful. But at the kernel level, two distinct and separate namespaces are created.
- Aside: Two different users may both
- Secondary group IDs (also called "supplementary group IDs") may be (are?) ignored (or frozen?). I'm not sure of the exact details. Suffice to say, secondary group IDs may work differently, or may not work at all, inside an unprivileged namespace.
- A process inside an unprivileged namespace will be limited to actions that can be performed by the non-root user that ran
lxroot. Any syscall that attempts to exceed these limitation will fail. - Very old Linux kernels lack unprivileged namespaces.
- Even with modern Linux kernels, unprivileged namespaces may be disabled either: (a) when the kernel was compiled, or (b) at runtime by
root.
-
- As mentioned above, the
suidandsgidbits are ignored inside an unprivileged namespace. - Advantages
- Privilege escalation is impossible inside the unprivileged namespace.
- Disadvantages
- Programs that rely upon privilege escalation will probably fail.
The failure of sudo inside an unprivileged namespace is a direct consequence the fact that the suid and sgid bits are ignored.
Possible workarounds
- Change
lxroot -- sudo commandtolxroot -r -- command. - Change
lxroot -- sudo commandtolxroot -w -- unshare -r command- Note:
unshareuses namespaces, just likelxroot.unshareshould be as efficient aslxroot.
- Note:
- Charge
lxroot -- sudo commandtolxroot -w -- proot -R / command- Note: I am not a
prootexpert. It is possible there are better options than-R /to use withproot. - Note:
prootusesptrace()instead of namespaces. Therefore:-
prootis noticeably less efficient thanlxroot. -
proothas virtualization capabilities thatlxrootlacks.
-
- Note: I am not a
- Replace
/usr/bin/sudowith the following script, and runlxrootwith the-woption:
#! /bin/sh
/usr/bin/unshare -r "$@"
I guess alternatively, you could use:
#! /bin/sh
proot -R / "$@"
There may be other workarounds beyond the above. It is also possible that there is no easy lxroot-based workaround for your particular situation.
A process running inside an unprivileged namespace will not be able to change the owner of a file. Attempts to change the group of a file may (will?) also fail.
Calls to chown() that change neither the UID nor GID may (will?) succeed.
I've learned that it should be possible for lxroot to use seccomp filters to cause the kernel to ignore all calls to chown(). By "ignore" I mean: the kernel will (a) do nothing yet (b) report success. I have not yet invested any time in exploring use of seccomp.
Obviously, beyond chown(), there are other syscalls that will also fail inside an unprivileged namespace. Specifically, any syscall should fail when the syscall exceeds the permissions of the non-user that ran lxroot.
It may be possible to extend lxroot to use seccomp to ignore these syscalls as well. I have not yet explored any use of seccomp.