Skip to content

Commit

Permalink
Default allow_privilege_escalation to False
Browse files Browse the repository at this point in the history
Allows it to be set to None as well, to not set the property.

This is a breaking change for hubs where admins were granting
sudo rights to users. That already required some extra work,
so this would be an additional propety to set for that. The
added security benefit from this much more secure default is
well worth the breakage IMO.

Fixes #544
  • Loading branch information
yuvipanda committed Nov 15, 2021
1 parent 73754d8 commit f45fc60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kubespawner/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ def make_pod(
container_security_context.run_as_group = int(run_as_gid)
if run_privileged:
container_security_context.privileged = True
if not allow_privilege_escalation:
container_security_context.allow_privilege_escalation = False
if not allow_privilege_escalation is not None:
container_security_context.allow_privilege_escalation = allow_privilege_escalation
# Only clutter container spec with actual content
if all([e is None for e in container_security_context.to_dict().values()]):
container_security_context = None
Expand Down
14 changes: 10 additions & 4 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,15 +747,21 @@ def _validate_image_pull_secrets(self, proposal):
)

allow_privilege_escalation = Bool(
True,
False,
config=True,
allow_none=True,
help="""
Controls whether a process can gain more privileges than its parent process.
This bool directly controls whether the no_new_privs flag gets set on the container
When set to False (the default), the primary user visible effect is that
setuid binaries (like sudo) will no longer work.
When set to None, the defaults for the cluster are respected.
This bool directly controls whether the no_new_privs flag gets set on the container
process.
AllowPrivilegeEscalation is true always when the container is:
AllowPrivilegeEscalation is true always when the container is:
1) run as Privileged OR 2) has CAP_SYS_ADMIN.
"""
)
Expand Down

0 comments on commit f45fc60

Please sign in to comment.