-
Notifications
You must be signed in to change notification settings - Fork 594
Harden dhcp by checking for /sbin/dhclient #3239
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for finding this!
IMHO sbox is not really in the position to figure out what to execute. Maybe we should replace the |
Yeah, |
Running /sbin/dhclient or /usr/sbin/dhclient avoids PATH-based vulnerabilities. We also check that the dhclient is owned by root. We take an approach similar to netfiler.c and assume that the required binary ar in /sbin or /usr/sbin, or (like on Arch) /sbin is a symlink to /usr/bin.
Quickly checked and there seem to be no other instances. Also means that replacing
👍 |
Merged, thanks! |
I'm going to remove the execvp in a separate patch. |
@smitsohu Oh, I am also trying to put together a patch for that -- with some extra checking. Playing around with some symlinks, I think the paranoia with |
@kris7t Go ahead! I did not start yet :) |
In order to avoid picking up some random executable from
$PATH
and potentially running it root privileges,dhcp.c
should check for/sbin/dhclient
or/usr/sbin/dhclient
directly. This might cause problems on distributions wheredhclient
is located elsewhere, but as far as I know,/sbin
is the default location (and even Arch, which uses only/usr/bin
, symlinks/sbin
to/usr/bin
). This is the same approach thatnetfilter.c
takes when runningiptables-restore
.I formulated the check for root privileges according to https://github.com/netblue30/firejail/blob/master/src/firejail/x11.c#L1103, which allows the binary to either be owned by root, or the root group. A more paranoid version would use
open
,fstat
andfexecve
to make sure ownership of the binary does not change between thestat
andexec
calls. On the other hand, manipulation of a binary already owned by root means the system is already compromised, so there's probably not much point to be careful about TOCTOU here.netfiler.c
even skips the check altogether, and relies on/sbin
being only writable by root.Hopefully, we don't blindly execute a binary with root privileges anywhere else in the codebase.
A more meta question: what is the policy with running external executable from firejail with root privilages (even if capability and seccomp sandboxed)? The potential for introducing setuid-related vulnerabilities is high. If we want to integrate additional external tools (like
xdg-dbus-proxy
), we should try to keep it reasonably safe.