Skip to main content

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 the securityContext 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 like runAsNonRoot or capabilities.
  • Fail: If the output indicates null or empty configurations for user workloads.

Remediation

Apply a robust securityContext to all your Pods and Containers.
  1. Pod Level: Set runAsNonRoot, runAsUser, and fsGroup to ensure identity isolation.
  2. Container Level: Set readOnlyRootFilesystem, allowPrivilegeEscalation: false, and drop ALL capabilities to harden the runtime environment.