]> granicus.if.org Git - shadow/commit
newgidmap: enforce setgroups=deny if self-mapping a group
authorAleksa Sarai <asarai@suse.de>
Thu, 15 Feb 2018 12:49:40 +0000 (23:49 +1100)
committerAleksa Sarai <cyphar@cyphar.com>
Fri, 16 Feb 2018 06:56:35 +0000 (17:56 +1100)
commitfb28c99b8a66ff2605c5cb96abc0a4d975f92de0
tree3bc8c13c3e4a3a8ed6f2260ee3e22ff1fd89833a
parentc0f0c67864e0a5498de14b736456b9c111f5233a
newgidmap: enforce setgroups=deny if self-mapping a group

This is necessary to match the kernel-side policy of "self-mapping in a
user namespace is fine, but you cannot drop groups" -- a policy that was
created in order to stop user namespaces from allowing trivial privilege
escalation by dropping supplementary groups that were "blacklisted" from
certain paths.

This is the simplest fix for the underlying issue, and effectively makes
it so that unless a user has a valid mapping set in /etc/subgid (which
only administrators can modify) -- and they are currently trying to use
that mapping -- then /proc/$pid/setgroups will be set to deny. This
workaround is only partial, because ideally it should be possible to set
an "allow_setgroups" or "deny_setgroups" flag in /etc/subgid to allow
administrators to further restrict newgidmap(1).

We also don't write anything in the "allow" case because "allow" is the
default, and users may have already written "deny" even if they
technically are allowed to use setgroups. And we don't write anything if
the setgroups policy is already "deny".

Ref: https://bugs.launchpad.net/ubuntu/+source/shadow/+bug/1729357
Fixes: CVE-2018-7169
Reported-by: Craig Furman <craig.furman89@gmail.com>
Signed-off-by: Aleksa Sarai <asarai@suse.de>
src/newgidmap.c