Security challenges in Kubernetes
26 Oct 2021
Container-based cluster orchestrators have been incepted to deploy and manage whole distributed applications as sets of containers that run across multiple data centers. Their main functionalities are automated management of virtual compute and network infrastructure for running the clusters, setting up of inter-container networks with support for service discovery and fine-grained security firewalls, as well as the automated deployment and management of various types of workloads such as web services, databases and data processing jobs, all uniformly running as portable containers.
Very quickly after the breakthrough of containers, the container orchestration framework Kubernetes has become the de-facto standard for deploying and managing portable container-based clusters. Kubernetes has also become the preferred cluster orchestrator for companies that work with two or more cloud providers in order to realize portable, multi-cloud applications. Kubernetes started as an open-source project that is partially based on Google’s internal cluster orchestrator and later has been donated to the Cloud Native Computing Foundation (CNCF)1. Kubernetes operates according to the declarative configuration management approach, which entails that a user-specified, desired system state is enforced upon an actual system by a controller that detects differences between desired and actual state. In Kubernetes, the desired state is specified and managed using a RESTful API and is composed of various types of resources such as containers, nodes and load balancers. Different controllers exist for the life cycle management of different resources types.
The adoption of Kubernetes has skyrocketed in both the private cloud2 and public cloud3. According to a recent survey of 500 relevant IT professionals4, its adoption rate has spiked during the Corona pandemic: 68% of the respondents said to have increased their use of Kubernetes during the pandemic in order to achieve faster deployment cycles of their new applications. A quarter of respondents said that they achieved a cost reduction of at least 30% on an annual basis as a result of using Kubernetes. Moreover, Kubernetes has increasingly been used to manage compute-intensive workloads. For example, 84% of respondents have used a Kubernetes environment to test or develop AI models and applications.
Two sources of insecurity
A weakness of Kubernetes is however security. In the above survey, 54% of the respondents said that security is the greatest challenge for their organization. Security is difficult to handle because it is not implemented by a single system component but by multiple system layers in the Kubernetes stack (cloud, clusters, containers, and application code).
Misconfigurations are by far the most common cause of Kubernetes-related incidents as reflected in a recent report by StackRox5. Misconfigurations also arise due to inconsistencies between different system layers that each require specific security policies and specific security controllers for enforcing these policies. The amount of security policies is also unfortunately huge as container-based clusters are multi-tenant systems on top of which multiple co-located applications need to be isolated from each other.
Kubernetes also has a large security attack interface as it is composed of and depends on many moving parts that expose specific web services or configuration facilities to external users. The more such accessible and evolvable parts exist, the larger the attack interface becomes, and therefore reducing it is of utmost importance, especially when using Kubernetes for running critical infrastructures such as telecommunications systems. Such critical infrastructure require a system architecture where the number of mutually trusted components is kept as small as possible and the outer shell around these trusted components is watertight. Realizing such a system architecture on top of the quickly evolving Kubernetes eco-system is challenging.
The remainder of this article outlines the specific security challenges that ensue from misconfigurations and the large security attack interface of Kubernetes and presents explored directions in existing R&D activities. Some of these challenges are being investigated by KU Leuven and Ericsson in the context of the Horizon 2020 Marie Skłodowska-Curie Action project 5GhOSTS6 that is developing formally founded building blocks for improving the security of Kubernetes deployments in the edge of 5G networks.
Misconfiguration challenges
With respect to misconfigurations, the following resources of the RESTful Kubernetes API are a source of concern:
-
Authorization and access control configurations are tedious to manage and are limited in expressiveness. Role-Based Access Control (RBAC), which is the primary model for authorization in Kubernetes, is managed through the folliowing inter-dependent API resources: Roles, ClusterRoles, Namespaces, RoleBindings, ClusterRoleBindings and ServiceAccounts. As such, adding a permission for a subject to access a particular object in a namespace involves a tedious process of editing multiple YAML files in a consistent manner. The implemented RBAC model is also limited in expressiveness. For example, negative authorization, which denies access to particular object, is not supported; instead you need to exhaustively list all existing objects except the denied one7. Moreover it is not possible to express fine-grained policies that select specific instances of an object type or information-specific policies that evaluate random attributes of objects or subjects8. An alternative approach is configuring Kubernetes to run in webhook mode for authorization, which allows to delegate access control decisions to an external authorization component. One such external component is the Open Policy Agent framework9 that allows defining more expressive access control rules by means of a policy language called Rego. However not all Kubernetes vendors can be configured with webhook mode for authorization. This is especially the case for Kubernetes vendors of the hosted type10.
-
Misconfiguration is of course not limited to security configurations but also applies to any type of cluster- or application-specific resource of the Kubernetes API. To handle this type of misconfiguration, Kubernetes offers admission controllers that are run in sequence after authentication and authorization of API requests has succeeded. However, for some specific use-cases more stringent constraints need to be enforced and therefore Kubernetes allows to inject custom admission controllers. Writing such custom admission controllers is error-prone and it cannot be excluded that some code is malicious. Therefore Gatekeeper11, which is part of the Open Policy Agent project, implements a generic admission controller and an extensible library of constraints that are specified as custom resource definitions that extend the RESTful API of Kubernetes with new resource types.
-
Third-party, mandatory networking components such as Calico and Cilium come with configurable firewalls and DoS prevention based on declarative networking policies that are also to be submitted to the Kubernetes API. Without network policies, every container can send traffic to any other container in a Kubernetes cluster. To ensure proper network isolation between co-located applications, network policies must be configured according to the principle of least privilege. This principle implies that only those inter-container communication paths should be permitted that are necessary for an application to function correctly. However, there is no way in Kubernetes to automatically enforce this principle. Moreover, many other misconfigurations such as conflicting or redundant policies may arise. This challenge is a hot topic of research in the networking, operating systems and security communities, which targets automated, fast, scalable and incremental verification of network policies against formally specified quality properties12.
-
The problem of cross-layer inconsistencies manifests itself most profoundly in the area of inter-container networking. The abovementioned networking policies do not cover application-level access control with permissions at the level of CRUD operations of long-running containers such as web services. Instead service meshes, such as Istio, offer intelligent routing of HTTPs requests and access policy enforcement on top of Kubernetes. Of course, the security controllers of Istio and the abovementioned mandatory networking components of Kubernetes need to be integrated in order to prevent configuration inconsistencies between their respective security policies. A similar integration is needed when running Kubernetes on top of private or public cloud platforms; conflicts may arise between the declarative network policies of Kubernetes and the security groups and virtual routers that are managed by the cloud platforms. This challenge is currently handled in a pragmatic, yet ad-hoc approach: integration between different system layers is achieved by fostering interaction between vendors in the context of a certification programme of the CNCF. This approach restricts however the number of technologies that can be combined. Ongoing research intends to extend the above mentioned verification work with a cross-layer policy conflict detection and reconciliation method that is able to work with different trust models. Different trust models may apply with respect to the extent how the human administrators and vendors of different system layers in the Kubernetes stack trust each other.
Large security attack interface
With respect to the large security attack interface of Kubernetes, different entities in a Kubernetes cluster can be distinguished:
-
The nodes that make up a cluster. A Kubernetes cluster consists of a master node that implements the RESTful API and multiple worker nodes. These nodes can be attacked, either from the inside (e.g., malicious software, privileged user) or outside the node (e.g., an attacker that exploits a certain service publicly exposed). Therefore prevention and detection of malicious activity on nodes should be attained. Prevention entails reducing the attack interface by removing all the unnecessary software and packages from the OS that are not needed for the operation of Kubernetes. Detection of malicious activity can be achieved by means of node attestation13, which is a method to cryptographically prove that the software that is running on the node has not been tampered with. Node attestation can be integrated with Kubernetes to build trust over the nodes of a cluster. In short, trusted nodes whose attestation has succeeded can be distinguished from untrusted ones by applying a label to them, so that the control plane can be aware of which nodes are trusted and which ones not.
-
Containers that may perform malicious activity. Container images can be (made) corrupt, for instance, by man-in-the-middle attacks that inject malicious code into the image while it is being sent over the network. Despite the ample existing measures for preventing malicious activity (image scanning, digital signing and hashing, container runtimes with stronger security isolation, limiting access of the container towards the underlying operating system, trusted execution environments) there still remains the possibility that the container circumvents the restrictions it is subject to, or that a trusted container becomes compromised by an external attacker. As such, runtime monitoring tools should be used to detect malicious activity in the cluster. Falco14 can be used for this purpose. It is an open source runtime security tool part of the CNCF.
-
Systems-oriented programming languages needed for low-latency applications. Many low-latency applications are implemented in systems-oriented programming languages such as C and C++, which do not offer memory-safety, and thus can be exploited by buffer-overflow attacks. These attacks submit carefully crafted inputs to the application in order to trick the application to execute arbitrary code or to leak sensitive information. This is especially damaging in multi-tenant applications such as web services where a HTTP request from one user can overwrite or steal data from other users.
-
Third-party libraries. No application is written from scratch, all of them include third-party libraries. These could be malicious and any vulnerabilities or bugs in imported third-party software cannot be detected. As a result, more fine-grained isolation systems within an application are needed.
-
The Kubernetes software itself. As with any popular software, bugs and security vulnerabilities will be discovered. Kubernetes is certainly no exception as is witnessed by the list of CVE records that are related to Kubernetes15. Some of these CVEs can only be mitigated by a workaround as the vulnerability is caused by a design flaw that cannot be resolved without user-facing changes. Another daunting evolution, is that due to the increasing need to support performance-demanding workloads, some Go code of Kubernetes is rewritten in C++. For example, in order to realize high-performance networking, the data plane and network policy enforcement of the aforementioned Calico and Cilium components is developed as an eBPF program. Such programs are written in a restricted variant of C++ that is said to be free from buffer-overflow vulnerabilities. Yet, a buffer-overflow vulnerability has been discovered in the eBPF runtime, which could have been exploited to damage the integrity of the Linux kernel16. Finally, the aforementioned dynamic webhooks for authorization and admission control allow to inject user code that can be written in any programming language. A cluster administrator that colludes with an attacker can compromise the integrity of Kubernetes in this way.
In summary, Kubernetes is being adopted at an increasing rate, resulting in a huge number of Kubernetes deployments world-wide. Kubernetes has however a large security attack interface, which means that it is composed of many application and system components that expose specific web services or configuration facilities to external users. The more such accessible components exist, the more challenging it becomes to ensure security. Another major source of security incidents are misconfigurations and cross-layer inconsistencies in the Kubernetes stack.
Resources
-
Cloud Native Computing Foundation visit site ↩
-
Openstack User Survey visit site ↩
-
why organizations choose a multicloud strategy visit site ↩
-
kubernetes adoption survey visit site ↩
-
State of Container and Kubernetes visit site ↩
-
5GhOSTS visit site ↩
-
Kubernetes RBAC: Moving from ‘It’s Complicated’ to ‘In a Relationship visit site ↩
-
The Kubernetes Authorization Webhook visit site ↩
-
Introducing Policy As Code: The Open Policy Agent (OPA) visit site ↩
-
E. Truyen, N. Kratzke, D. Van Landuyt, B. Lagaisse and W. Joosen, “Managing Feature Compatibility in Kubernetes: Vendor Comparison and Analysis,” in IEEE Access, vol. 8, pp. 228420-228439, 2020, doi: 10.1109/ACCESS.2020.3045768. view document ↩
-
Gatekeeper visit site ↩
-
Budigiri, Gerald ; Baumann, Christoph ; Mühlberg, Jan Tobias ; Truyen, Eddy ; Joosen, Wouter. IEEE; European Conference on Networks and Communications, Date: 2021/06/08 - 2021/06/11, Location: Porto, Portugal. 2021 Joint European Conference on Networks and Communications & 6G Summit (EuCNC/6G Summit); 2021; pp. 407 - 412 view document ↩
-
Securing Kubernetes with Trusted Platform Module (TPM) visit site ↩
-
The Falco Project visit site ↩
-
Kubernetes Security Vulnerabilities visit site ↩
-
Vulnerability Details : CVE-2021-3489 visit site ↩