Kubernetes & Container Attack Surface Hardening: CIS Benchmark & Production Security Manual
The definitive enterprise hardening checklist for production Kubernetes clusters (EKS, GKE, AKS, and self-hosted OpenShift). Aligned with the CIS Kubernetes Benchmark v1.8, NSA/CISA Kubernetes Hardening Guidance, and MeitY cloud standards. Covers API server protection, Pod Security Standards (PSS), eBPF-based runtime observability, immutable root filesystems, and network policy microsegmentation.
Interactive Technical Checklist (12 Verification Checkpoints)
-
[Control Plane Security] Disable anonymous authentication on kube-apiserver (--anonymous-auth=false).Mandate: CIS Benchmark 1.2.1
-
[Control Plane Security] Encrypt Kubernetes secrets at rest in etcd using AWS KMS / Azure Key Vault envelope encryption provider.Mandate: CIS Benchmark 1.2.31
-
[Control Plane Security] Restrict API server access to corporate egress IP CIDRs; disable public internet endpoint access.Mandate: RBI Perimeter Control
-
[Workload Hardening] Enforce Pod Security Standard 'Restricted' profile on all application namespaces via admission controllers.Mandate: NSA/CISA Hardening
-
[Workload Hardening] Configure readOnlyRootFilesystem=true and runAsNonRoot=true on all container securityContext definitions.Mandate: Container Immutability
-
[Workload Hardening] Drop all Linux capabilities (capabilities.drop: ['ALL']) and explicitly add back only required capabilities.Mandate: Least Privilege
-
[Network Microsegmentation] Deploy default-deny NetworkPolicy in every namespace blocking unauthorized ingress and egress.Mandate: Zero Trust Architecture
-
[Network Microsegmentation] Block access from application pods to Cloud Instance Metadata Service (169.254.169.254) via NetworkPolicy.Mandate: Metadata Service Defense
-
[Runtime Observability] Deploy eBPF runtime security agent (Falco / Tetragon) to detect process spawning, privilege escalations, and kernel exploits.Mandate: CERT-In Threat Detection
-
[Supply Chain & Images] Scan all container images with Trivy or Grype in CI/CD; fail build on any Critical/High CVE with available patch.Mandate: Vulnerability Management
-
[Supply Chain & Images] Enforce container image signature verification at admission time via Kyverno or Gatekeeper using Cosign.Mandate: Supply Chain Integrity
-
[RBAC & Service Accounts] Audit ClusterRoleBindings; eliminate excessive cluster-admin grants; set automountServiceAccountToken=false by default.Mandate: RBAC Hardening
Default Kubernetes configurations prioritize developer ease-of-use over security. Containers run with elevated capabilities, shared host namespaces, and unrestricted network egress. This hardening manual enforces cryptographic boundaries across cluster control planes and container runtimes.
1. Hardened Production Pod Security Context
Every production pod deployment manifest must declare an explicit securityContext enforcing immutable root filesystems and dropping dangerous Linux capabilities:
apiVersion: apps/v1
kind: Deployment
metadata:
name: hardened-api-service
spec:
template:
spec:
automountServiceAccountToken: false # Prevent service account token theft
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
fsGroup: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: api
image: enterprise-registry.in/api:v2.4@sha256:abc123...
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true # Prevents malware persistence
capabilities:
drop:
- ALL # Drop all 38+ Linux capabilities
resources:
limits:
cpu: "500m"
memory: "512Mi"
2. Metadata Service (IMDSv2) Protection via NetworkPolicy
A common SSRF exploit path enables compromised pods to query the AWS/Azure instance metadata service (169.254.169.254) to steal node IAM credentials. The following NetworkPolicy blocks this egress path:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: block-instance-metadata
namespace: default
spec:
podSelector: {}
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 169.254.169.254/32 # Denies traffic to AWS/Azure/GCP metadata service
Need Accredited Auditors to Execute This Audit or Gap Assessment?
BlueCiphr's certified lead auditors (CEH Master, PenTest+, ISO 27001 Lead Auditors) conduct deep technical verification and produce board-ready evidence binders complying with RBI, SEBI CSCRF, CERT-In, and the DPDP Act 2023.