-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CVE-2017-18188: Unsafe use of recursive chown in "Z" support #3
Comments
Looking at this briefly, it looks like ultimately the issue is in chown. |
I would say the problem is in the tmpfiles.d specification. Ultimately, there's no reason why you should ever have to "fix" permissions at startup: temporary directories will be gone, so you can create them anew with the correct permissions (mkdir/chown the top-level directory, and then drop privileges to create the rest); and non-temporary directories should still be there from before. But, the tmpfiles.d specification allows it, so people do it. And it turns out to be impossible to adjust permissions on user-controlled files in a safe manner using only POSIX features. Systemd uses a Linux-specific trick to do it safely. The way |
How do i create a hardlink?
|
Gentoo (and many other distributions) patch the linux kernel to disallow these hardlinks by default: mjo@jumba ~ $ sudo sysctl fs.protected_hardlinks
fs.protected_hardlinks = 1 To allow them (like the vanilla Linux kernel does), you'll have to set that sysctl to zero. |
I run the vanilla kernel. |
Oh, apparently i've set the sysctl myself, nvm. |
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: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...
and restart opentmpfiles-setup...
and now I own
/etc/passwd
!This happens, ultimately, because
chown -R
will "follow" a hard link. This same problem was addressed in OpenRC'scheckpath
helper in Gentoo bug 540006.The text was updated successfully, but these errors were encountered: