Missing Security Context Configuration
Kubernetes workloads are deployed without defining securityContext at pod or container level, causing them to inherit insecure default settings that enable root execution and privilege escalation.
Kubernetes pods and containers deployed without explicit securityContext configuration inherit insecure defaults including root user execution, privilege escalation permissions, broad Linux capabilities, writable root filesystems, and unconfined security profiles. This creates multiple attack vectors for container escape, privilege escalation, and lateral movement.
# VULNERABLE: Pod without any security context
apiVersion: v1
kind: Pod
metadata:
name: vulnerable-pod
spec:
# VULNERABLE: No securityContext defined
containers:
- name: app
image: app:v1.0.0
# VULNERABLE: No container-level securityContext
# VULNERABLE: Deployment with minimal security
apiVersion: apps/v1
kind: Deployment
metadata:
name: vulnerable-deployment
spec:
replicas: 3
selector:
matchLabels:
app: vulnerable-app
template:
metadata:
labels:
app: vulnerable-app
spec:
# VULNERABLE: Missing pod-level securityContext
containers:
- name: web-server
image: nginx:latest
# VULNERABLE: No container securityContext
ports:
- containerPort: 80# SECURE: Pod with security context
apiVersion: v1
kind: Pod
metadata:
name: secure-pod
spec:
# SECURE: Pod-level security context
securityContext:
runAsNonRoot: true
runAsUser: 1000
containers:
- name: app
image: app:v1.0.0
# SECURE: Container-level security context
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop: ["ALL"]
# SECURE: Deployment with security configuration
apiVersion: apps/v1
kind: Deployment
metadata:
name: secure-deployment
spec:
replicas: 3
selector:
matchLabels:
app: secure-app
template:
metadata:
labels:
app: secure-app
spec:
# SECURE: Pod security context
securityContext:
runAsNonRoot: true
runAsUser: 1000
containers:
- name: web-server
image: nginx:latest
# SECURE: Container security context
securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities:
drop: ["ALL"]
ports:
- containerPort: 80Kubernetes workloads are deployed without defining securityContext at pod or container level, causing them to inherit insecure default settings that enable root execution and privilege escalation.
Sourcery automatically identifies authorization bypass due to missing securitycontext in kubernetes workload spec and many other security issues in your codebase.