diff --git a/plugin/pkg/admission/exec/admission.go b/plugin/pkg/admission/exec/admission.go index e82bb020e87..610b3feb9a9 100644 --- a/plugin/pkg/admission/exec/admission.go +++ b/plugin/pkg/admission/exec/admission.go @@ -110,7 +110,7 @@ func (d *denyExec) Admit(a admission.Attributes) (err error) { // isPrivileged will return true a pod has any privileged containers func isPrivileged(pod *api.Pod) bool { for _, c := range pod.Spec.InitContainers { - if c.SecurityContext == nil { + if c.SecurityContext == nil || c.SecurityContext.Privileged == nil { continue } if *c.SecurityContext.Privileged { @@ -118,7 +118,7 @@ func isPrivileged(pod *api.Pod) bool { } } for _, c := range pod.Spec.Containers { - if c.SecurityContext == nil { + if c.SecurityContext == nil || c.SecurityContext.Privileged == nil { continue } if *c.SecurityContext.Privileged {