Disable su/sudo access unless sudo explicitly enabled for a specific user using GRANT_SUDO. #845
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a follow up to the PR #654.
That prior PR was intended to lock down a very specific corner case where the notebook images were run as an arbitrary user which had no user ID in the
/etc/passwd
.In that situation, the user would run with group ID of 0, since there also was no group for the unknown user ID. The prior PR removed the write access to
/etc/group
that had previously been added for group ID of 0 to prevent them from adding themselves to any groups, and requiring a user be inwheel
group in order to runsu
. This was to prevent a user adding a password hash into/etc/passwd
forroot
and then usingsu
to become root.What has been overlooked in the prior PR, is that a user could change the primary group in
/etc/passwd
and still add themselves to thewheel
group.There is also a further problem with being able to update the group. That is that a user could change their primary group to
sudo
oradmin
and then runsudo
if they add a password has to/etc/passwd
file for themselves.This PR does a couple of things to lock this down further.
The first is that instead of requiring users be in
wheel
group to usesu
, the ability to usesu
is blocked outright for anyone butroot
. This is achieved by dropping from/etc/pam.d/su
:and adding instead:
This means that the only
auth
that can apply is:That is only
root
can usesu
.The second change is to
/etc/sudoers
and disablessudo
for people insudo
oradmin
groups. This is done by commenting out the lines:Although this is done, it doesn't conflict with
GRANT_SUDO
because when that is used the/etc/sudoers.d/notebook
file is created containing:which is configuring
sudo
access forjovyan
.Further, the changes don't block a user when
GRANT_SUDO
is being used from running:as after the
sudo
, thesu
command is being run asroot
.All up, this locks down ability to become
root
for the corner case when arbitrary user ID is used, but shouldn't stopGRANT_SUDO
working. It is not believed there are other ways of becomingroot
thanGRANT_SUDO
.Note that these changes are an extra level of protection. Under normal use, running as an arbitrary user ID wouldn't usually be done. The one case known of where it is done is when deploying to OpenShift, but in that case, Linux capabilities for
SETUID
andSETGID
are also dropped, so you couldn't becomeroot
anyway even before this change to lock things down further.Thanks go to @javabrett who raised the issue via #560 (comment) that this PR addresses, and testing the solution.