Home Audience Developers Kubernetes Security: Threats And Controls

Kubernetes Security: Threats And Controls

0
6
Kubernetes Security: Threats and Controls
Kubernetes Security: Threats and Controls

Kubernetes has become the de facto standard for orchestrating containerised workloads at scale, but its distributed architecture introduces a broad attack surface spanning the control plane, worker nodes, network, and the software supply chain that builds container images. Thankfully, there are a number of controls that can help to secure systems.

Kubernetes (K8s) automates the deployment, scaling, and management of containerised applications. Its power comes from a highly programmable API server that mediates every action inside the cluster — from creating a pod to modifying network rules. This same programmability, however, means that a single misconfiguration (an overly permissive role, an open network path, an unscanned image) can expose the entire cluster to compromise. Industry data cited in recent reports shows that most organisations now run Kubernetes in hybrid-cloud environments and are increasing their reliance on it as a primary application platform, which raises the stakes for getting security right from the outset.

Kubernetes architecture overview

A Kubernetes cluster is divided into a control plane, which makes global decisions about the cluster (scheduling, detecting/responding to events), and worker nodes, which run the actual application workloads inside pods (Figure 1). The control plane’s kube-apiserver is the single-entry point for all requests and is therefore the most security-critical component: every authentication, authorisation, role-based access control (RBAC), and admission-control check happens here before a request is persisted to etcd, the cluster’s key-value store of records.

Kubernetes cluster architecture — control plane and worker nodes
Figure 1: Kubernetes cluster architecture — control plane and worker nodes (Source: https://kubernetes.io/docs/concepts/overview/components/)

Why Kubernetes security matters

The risks described in this article are not theoretical. In 2018, security researchers at RedLock discovered that Tesla’s Kubernetes Dashboard had been left exposed to the public internet with no authentication at all (Figure 2). Attackers found the console, used it to obtain AWS credentials embedded in a pod’s environment, and deployed cryptocurrency-mining containers across Tesla’s cloud infrastructure — deliberately throttling CPU usage to stay under the radar of monitoring systems. The incident illustrates, in one real example, how a single missing control (authentication on a management interface) cascades into credential exposure, unauthorised workload deployment, and sustained resource theft. We will revisit this and two further real-world cases in detail later.

Table 1: Core Kubernetes RBAC objects (Source:

https://kubernetes.io/docs/reference/access-control/rbac/)

Object Scope Purpose Example
Role Namespace Defines allowed verbs on resources within one namespace Allow ‘get,list’ on pods in ‘dev’
ClusterRole Cluster-wide Defines allowed verbs on resources across all namespaces, or on cluster-scoped resources Allow ‘list’ on nodes
RoleBinding Namespace Grants a Role (or ClusterRole) to a subject within one namespace Bind ‘dev-viewer’ Role to user ‘alice’
ClusterRoleBinding Cluster-wide Grants a ClusterRole to a subject across the whole cluster Bind ‘cluster-admin’ to a break-glass account
ServiceAccount Namespace Identity used by pods/CI pipelines to call the API server CI pipeline deploying to ‘staging’

Core controls of Kubernetes security

Role-based access control (RBAC)

RBAC governs who (a user, group, or ServiceAccount) can perform which verbs (get, list, create, delete, etc) on which resources (pods, secrets, deployments) in the cluster. A Role or ClusterRole defines a set of permissions; a RoleBinding or ClusterRoleBinding attaches that set of permissions to a subject. The Principle of Least Privilege (PoLP) is the guiding rule: subjects — including CI/CD service accounts — should be granted only the permissions strictly required for their function, since granting cluster-admin broadly makes lateral movement trivial for an attacker who compromises any single credential. Table 1 summarises the core RBAC objects and how they form an access-control decision.

The five objects in this table always work together as a chain, never in isolation. Consider a CI/CD pipeline that needs to deploy to the ‘staging’ namespace. The correct pattern is to create a dedicated ServiceAccount for the pipeline, define a narrowly scoped Role that permits only ‘create’ and ‘update’ on Deployments and Services within ‘staging’, and connect the two with a RoleBinding — nothing more. A ClusterRole and ClusterRoleBinding would only be justified if the same pipeline genuinely needed to act across every namespace (for example, a cluster-wide monitoring agent). A well-documented real-world failure of this pattern is the legacy Helm 2 ‘Tiller’ component: its simplest install path granted the Tiller ServiceAccount a full cluster-admin ClusterRoleBinding and exposed an unauthenticated in-cluster endpoint, meaning any pod that could reach Tiller could deploy arbitrary resources and inherit cluster-admin rights — exactly the over-broad-binding failure mode Table 1’s least-privilege pattern is designed to prevent.

Network policies

By default, all pods in a Kubernetes cluster can communicate with all other pods — a flat network with no isolation. NetworkPolicy resources restrict this by defining allowed ingress/egress traffic based on pod and namespace labels. Current security checklists recommend starting with a default deny-all policy per namespace and then explicitly allowing only the traffic paths an application needs, combining this with RBAC and secrets management to build a defence-in-depth architecture.

Pod and container hardening

Pod Security Standards (PSS) define three levels of restriction that can be enforced per namespace: Privileged (unrestricted), Baseline (blocks known privilege escalations), and Restricted (enforces current pod-hardening best practice). Recommended container-level controls include running as a non-root user, dropping all Linux capabilities and adding back only what is required, using minimal base images, and scanning images for vulnerabilities in the CI/CD pipeline before they ever reach the cluster.

PSS levels are applied per namespace via labels (e.g., pod-security.kubernetes.io/enforce: restricted), which means a cluster can safely run mixed workloads — a legacy system namespace at Baseline while every new application namespace is locked to Restricted. The practical difference between levels is best seen through container-escape vulnerabilities such as CVE-2019-5736 in runc, which allowed a malicious or compromised container to overwrite the host’s runc binary and escape to the underlying node. A Restricted-level pod (non-root, all capabilities dropped, no privilege escalation) closes off most of the preconditions that class of exploit depends on, while a Privileged-level pod offers no resistance at all — which is why production namespaces are increasingly defaulted to Restricted rather than Baseline.

Secrets management, admission control, and monitoring

Secrets encrypt Kubernetes Secrets at rest in etcd, and prefer an external secrets manager (e.g., HashiCorp Vault, AWS Secrets Manager) over storing credentials directly in manifests.

Admission controllers intercept API requests after authentication/authorisation to enforce policy before an object is persisted; policy engines such as OPA Gatekeeper and Kyverno are commonly used to block non-compliant workloads.

Audit logging and monitoring continuously monitor API server audit logs, RBAC changes, and NetworkPolicy changes; eBPF-based tools (e.g., Cilium Hubble, Tetragon) provide runtime visibility into traffic that static policy review alone would miss.

Software supply chain security

Because Kubernetes workloads are built from container images assembled through CI/CD pipelines, cluster security is inseparable from software supply chain security. A best practice is to scan and sign every image before deployment (e.g., with Trivy for vulnerability scanning and Cosign for cryptographic signing), block images with unpatched high/critical CVEs from being admitted to the cluster and verify image provenance at admission time so that only artifacts built by a trusted pipeline can run. This closes the gap between “the code is secure” and “the running container is secure.”

Table 2: Kubernetes Pod Security Standards (PSS) levels (Source: https://kubernetes.io/docs/concepts/security/pod-security-standards/)

Level Description Typical controls enforced
Privileged Unrestricted policy, provides the widest possible level of permissions None — intended only for system/infra workloads
Baseline Minimally restrictive; prevents known privilege escalations Blocks host namespaces, privileged containers, most host mounts
Restricted Heavily restricted; follows current pod-hardening best practice Requires runAsNonRoot, drops all capabilities, blocks privilege escalation

Real-world scenarios

The following three publicly documented incidents each map to one of the control areas discussed above, showing what happens in practice when a single layer of the (Cloud, Cluster, Container, Code) 4C’s-style defence is missing.

Tesla — Exposed dashboard and credential theft (2018)

As introduced in Figure 2, security firm RedLock discovered that Tesla’s Kubernetes Dashboard was reachable from the public internet with no authentication configured. Attackers used the console to reach a pod’s environment variables, which contained live AWS credentials, including access to an Amazon S3 bucket holding telemetry data. Rather than exfiltrate that data, the attackers used the stolen access to deploy cryptocurrency-mining containers, tuning CPU usage and routing traffic through Cloudflare to avoid detection. Tesla fixed the issue within hours of RedLock’s disclosure. This was a failure of authentication and secrets hygiene — the exact gap that RBAC and external secrets management are designed to close.

Kubernetes cluster architecture — control plane and worker nodes
Figure 1: Kubernetes cluster architecture — control plane and worker nodes (Source: https://kubernetes.io/docs/concepts/overview/components/)

Azurescape — Cross-tenant container escape on Azure Container Instances (2021)

Palo Alto Networks’ Unit 42 team found that Microsoft’s Azure Container Instances service was running containers on an outdated, vulnerable version of the runc container runtime. By exploiting known runc container-escape flaws, researchers broke out of their own container, reached the underlying multi-tenant Kubernetes node, obtained a privileged Kubernetes service-account token, and used it to take over the cluster’s API server — gaining the theoretical ability to access other customers’ containers on the same shared infrastructure. Microsoft patched the issue and notified affected customers to rotate credentials; no in-the-wild exploitation was reported. This demonstrates why container and node hardening (Table 2) and keeping the underlying container runtime patched are just as critical in managed and multi-tenant Kubernetes offerings as in self-managed clusters.

Dero cryptojacking campaign — Anonymous API access (2024)

More recently, an automated campaign distributing the Dero cryptominer was observed scanning the internet for Kubernetes API servers that still permitted anonymous, unauthenticated access. Where such clusters were found, the attackers used that open access to pull and deploy malicious container images directly from public registries, turning the victim’s own compute capacity into a mining botnet without ever needing to steal a credential. This maps directly to the RBAC authorisation flow in Figure 3 — a cluster with anonymous access effectively has no authorisation step at all — and to the admission-control guidance, since restricting which registries and images may be deployed would have blocked the attack outright.

Network policy enforcing micro-segmentation between tiers
Figure 3: Network policy enforcing micro-segmentation between tiers (Source: https://www.networkershome.com/fundamentals/cloud-security/kubernetes-security-rbac-policies-admission/)

Kubernetes security is best understood as a layered, ongoing discipline rather than a single setting. Securing the cluster requires coordinated controls at every level of the 4C’s (Cloud, Cluster, Container, Code) model: hardened cloud/IAM foundations, least-privilege RBAC, default-deny network segmentation, restricted pod security standards, encrypted and externally managed secrets, policy-enforcing admission controllers, continuous audit logging, and a secured software supply chain feeding trusted images into the cluster. Organisations that treat these controls as a connected system — rather than isolated checkboxes — are best positioned to operate Kubernetes safely at production scale.

Loading form…

LEAVE A REPLY

Please enter your comment!
Please enter your name here