Back to all scenarios
Scenario #249
Security
K8s v1.22, Google Cloud

Lack of Security Context in Pod Specifications

Pods were deployed without defining appropriate security contexts, resulting in privileged containers and access to host resources.

Find this helpful?
What Happened

Many pods in the cluster were deployed without specifying a security context, leading to some containers running with excessive privileges, such as access to the host network or running as root. This allowed attackers to escalate privileges if they were able to compromise a container.

Diagnosis Steps
  • 1Inspected pod specifications and identified a lack of security context definitions, allowing containers to run as root or with other high privileges.
  • 2Verified pod logs and found containers with host network access and root user privileges.
Root Cause

Failure to specify a security context for pods allowed containers to run with unsafe permissions.

Fix/Workaround
• Defined and enforced security contexts for all pod deployments to restrict privilege escalation and limit access to sensitive resources.
• Implemented security policies to reject pods that do not comply with security context guidelines.
Lessons Learned

Always define security contexts for pods to enforce proper security boundaries.

How to Avoid
  • 1Set default security contexts for all pod deployments.
  • 2Use Kubernetes admission controllers to ensure that only secure pod configurations are allowed.