-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Security Hardened Kubernetes Cluster] Rule 2001 implementation #375
[Security Hardened Kubernetes Cluster] Rule 2001 implementation #375
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.
Thanks for this PR! I have some really minor change requests. Other looks good.
|
||
> [!WARNING] | ||
> `securityContext.allowPrivilegeEscalation` is set to `true` in the following exceptions: | ||
> - container is running as `privileged` | ||
> - `CAP_SYS_ADMIN` is added to the container | ||
> - `CAP_SYS_ADMIN/SYS_ADMIN` is added to the container. More information can be found [here](https://github.com/kubernetes/kubernetes/issues/119568). |
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.
> - `CAP_SYS_ADMIN/SYS_ADMIN` is added to the container. More information can be found [here](https://github.com/kubernetes/kubernetes/issues/119568). | |
> - `CAP_SYS_ADMIN` or `SYS_ADMIN` is added to the container. More information can be found in [this issue](https://github.com/kubernetes/kubernetes/issues/119568). |
var ( | ||
checkResults []rule.CheckResult | ||
allowsPrivilegeEscalation = func(securityContext corev1.SecurityContext) bool { | ||
var addsCapSysAdmin = false |
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.
var addsCapSysAdmin = false | |
addsCapSysAdmin := false |
return securityContext.AllowPrivilegeEscalation == nil || *securityContext.AllowPrivilegeEscalation || | ||
(securityContext.Privileged != nil && *securityContext.Privileged) || | ||
addsCapSysAdmin |
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.
This reads better IMO.
return securityContext.AllowPrivilegeEscalation == nil || *securityContext.AllowPrivilegeEscalation || | |
(securityContext.Privileged != nil && *securityContext.Privileged) || | |
addsCapSysAdmin | |
var ( | |
allowsPrivilegeEscalation = securityContext.AllowPrivilegeEscalation == nil || *securityContext.AllowPrivilegeEscalation | |
hasPrivilegedContext = securityContext.Privileged != nil && *securityContext.Privileged | |
) | |
return allowsPrivilegeEscalation || hasPrivilegedContext || addsCapSysAdmin |
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.
/lgtm
What this PR does / why we need it:
Which issue(s) this PR fixes:
Part of #356
Special notes for your reviewer:
Release note: