lxc-user-nic allows unprivileged users to open arbitrary files
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxc (Debian) |
Fix Released
|
Unknown
|
|||
lxc (Ubuntu) |
Fix Released
|
High
|
Ubuntu LXC Security team | ||
Xenial |
Triaged
|
High
|
Ubuntu LXC Security team | ||
Bionic |
Fix Released
|
High
|
Ubuntu LXC Security team | ||
Cosmic |
Fix Released
|
High
|
Ubuntu LXC Security team |
Bug Description
Matthias Gerstner from SUSE reported the following:
```
Hello,
following the lxc security reporting guidelines [1] I am reporting a
finding in the lxc-user-nic setuid binary. I'm encrypting this mail as a
best practice and because I found valid GPG keys for all of your
adresses. Please find my public key attached to this mail.
In the context of an openSUSE security audit of the lxc-user-nic setuid
binary [2] (currently private bug) I came across an issue that should be
adressed. In the "delete" case the program runs the following piece of
code unconditionally with effective uid 0 (from lxc_user_nic.c):
```
} else if (request == LXC_USERNIC_DELETE) {
if (netns_fd < 0) {
}
}
```
`args.pid` is a user controlled parameter and can be an arbitrary path
at the moment. Nothing is done with this file descriptor later on in the
program except an attempt at `setns(fd, CLONE_NEWNET)` in
`is_privileged_
of the setuid binary to achieve the following:
- it can test for existence of files normally not accessible to the
caller (information leak). Example:
```
# this file is existing
$ /usr/lib/
lxc_user_nic.c: 1017: is_privileged_
lxc_user_nic.c: 1161: main: Process is not privileged over network namespace
# this file is not existing
$ /usr/lib/
lxc_user_nic.c: 1130: main: Could not open "/root/
```
- it allows to trigger code paths in the kernel that are normally not
accessible to the caller. This can happen when opening special files
like character and block devices or files in /proc or /sys. Opening
some of these files can cause lock or alloc operations or even more
complex things to happen like when opening /dev/ptmx, which causes the
allocation of a new master/slave pseudo terminal. Therefore this can
lead to DoS like situations or have further unspecified impact.
For fixing this I suggest opening the file supplied in `args.pid` only
with the permissions of the real user, since this is already done in
`is_privileged_
normalization of the input path and then only allowing a path of the
pattern /proc/<pid>/ns/net.
[1] https:/
[2] https:/
Best regards
Matthias
```
CVE References
Changed in lxc (Debian): | |
status: | Unknown → Confirmed |
Changed in lxc (Debian): | |
status: | Confirmed → Fix Released |
Current thought is that we could statvfs the resulting path to make sure that the filesystem is nsfs and not even attempt an open if it's not the case.
This will be handled as a medium priority security issue on the LXC side, so we will be issuing patches for affected releases (LXC 2.0 and LXC 3.0 appear affected) and will publish them in our stable branches and mailing-list when we reach the CRD (TBD at this point).
We will not be issuing emergency tarballs for this though, the fix will simply get rolled into the upcoming LXC 3.0.2 release (assuming the release happens after the CRD), distros should just apply the patch as part of a security update (easier to verify than a full bugfix release).