Impact & Risk Analysis
- Severity: Medium (Level 2 - Defense in Depth)
- CIS Benchmark: CIS 5.6.3
- Impact: Insecure Defaults. A security context defines privilege and access control settings for a Pod or Container. Without an explicit security context, Kubernetes relies on the container runtime’s defaults, which often include running as
root, having unnecessary Linux capabilities, and allowing write access to the root filesystem. This significantly increases the attack surface if the application is compromised.
Common Misconfiguration
Omitting thesecurityContext section entirely in Deployment or Pod manifests. This is the most common default state for new deployments, leaving the application running with permissions it likely does not need.
Vulnerable Example
Secure Example
Audit Procedure
Review the pod definitions in your cluster and verify that security contexts are defined. You can use this command to find pods that lack a security context entirely or have specific missing fields.- Analyze: Look for empty brackets
{}or missing critical fields likerunAsNonRootorcapabilities. - Fail: If the output indicates
nullor empty configurations for user workloads.
Remediation
Apply a robustsecurityContext to all your Pods and Containers.
- Pod Level: Set
runAsNonRoot,runAsUser, andfsGroupto ensure identity isolation. - Container Level: Set
readOnlyRootFilesystem,allowPrivilegeEscalation: false, and dropALLcapabilities to harden the runtime environment.

