Kubernetes security: hard to get in, harder to get out

Admission control, pod security, network policy, workload identity, secrets and the escape paths attackers actually use.

🔒 PROLesson·28 min read·Intermediate → Advanced
Kubernetesadmissionnetwork policyruntime

01Four layers of a cluster

✓What you will learn
  • Harden cluster, workload, network and runtime layers in order
  • Write an admission policy that blocks the dangerous defaults
  • Map the common container escape paths and close them
LayerThreatControl
Control planeExposed API server, overly broad RBACPrivate endpoint behind ZT gateway, RBAC audit, audit logs on
WorkloadPrivileged pods, hostPath mounts, rootPod Security Standards (restricted), admission policies, read-only root FS
NetworkFlat pod network, egress to anywhereDefault-deny NetworkPolicy, egress allow-list, mesh mTLS
RuntimeCrypto-miner, reverse shell, exec into podFalco/eBPF detection, no shell in images, alert on kubectl exec
Block the dangerous defaults at admissionyaml
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata: { name: restricted-defaults }
spec:
  validationFailureAction: Enforce
  rules:
  - name: no-privileged
    match: { any: [{ resources: { kinds: [Pod] } }] }
    validate:
      message: "privileged, hostPID, hostNetwork and hostPath are not allowed"
      pattern:
        spec:
          =(hostPID): false
          =(hostNetwork): false
          =(volumes): [ { X(hostPath): "null" } ]
          containers:
          - securityContext:
              =(privileged): false
              runAsNonRoot: true
              allowPrivilegeEscalation: false
              capabilities: { drop: [ALL] }

This is an advanced module

Cloud & Platform Security is part of the Pro pass. 1 more section — the deep dives, the final design, follow-ups and the test — unlock with it.

Already a cyart.io or studio.cyart.io member? Your pass code is in your Studio account.