GHSA-38jw-g2qx-4286 KubeVirt Affected by an Authentication Bypass in Kubernetes Aggregation Layer
Summary_Short summary of the problem. Make the impact and severity as clear as possible.A flawed implementation of the Kubernetes aggregation layer's authentication flow could enable bypassing RBAC controls.Details_Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer._It was discovered that the `virt-api` component fails to correctly authenticate the client when receiving API requests over mTLS. In particular, it fails to validate the CN (Common Name) field in the received client TLS certificates against the set of allowed values defined in the `extension-apiserver-authentication` configmap.The Kubernetes API server proxies received client requests through a component called aggregator (part of K8S's API server), and authenticates to the `virt-api` server using a certificate signed by the CA specified via the `--requestheader-client-ca-file` CLI flag. This CA bundle is primarily used in the context of aggregated API servers, where the Kubernetes API server acts as a trusted front-end proxy forwarding requests.While this is the most common use case, the same CA bundle can also support less common scenarios, such as issuing certificates to [authenticating](how-kubernetes-certificates-work) front-end [proxies](https://deepwiki.com/kubernetes/apiserver/7.1-authentication#request-header-authentication). These proxies can be deployed by organizations to extend Kubernetes' native authentication mechanisms or to integrate with existing identity systems (e.g., LDAP, OAuth2, SSO platforms). In such cases, the Kubernetes API server can trust these external proxies as legitimate authenticators, provided their client certificates are signed by the same CA as the one defined via `--requestheader-client-ca-file`.
Nevertheless, these external authentication proxies are not supposed to directly communicate with aggregated API servers.Thus, by failing to validate the CN field in the client TLS certificate, the `virt-api` component may allow an attacker to bypass existing RBAC controls by directly communicating with the aggregated API server, impersonating the Kubernetes API server and its aggregator component.However, two key prerequisites must be met for successful exploitation:The attacker must possess a valid front-end proxy certificate signed by the trusted CA (`requestheader-client-ca-file`). For example, they can steal the certificate material by compromising a front-end proxy or they could obtain a bundle by exploiting a poorly configured and managed PKI system.The attacker must have network access to the `virt-api` service, such as via a compromised or controlled pod within the cluster.These conditions significantly reduce the likelihood of exploitation. In addition, the `virt-api` component **acts as a sub-resource server**, meaning it only handles requests for specific resources and sub-resources . The handled by it requests are mostly related to the lifecycle of already existing resources.Nonetheless, if met, the vulnerability could be exploited by a *Pod-Level Attacker* to escalate privileges, and manipulate existing virtual machine workloads potentially leading to violation of their CIA (Confidentiality, Integrity and Availability).PoC_Complete instructions, including specific configuration details, to reproduce the vulnerability._Bypassing authenticationIn this section, it is demonstrated how an attacker could use a certificate with a different CN field to bypass the authentication of the aggregation layer and perform arbitrary API sub-resource requests to the `virt-api` server.The `kube-apiserver` has been launched with the following CLI flags:By default, Minikube generates a self-signed CA certificate (`var/lib/minikube/certs/front-proxy-ca.crt`) and use it to sign the certificate used by the aggregator (`/var/lib/minikube/certs/front-proxy-client.crt`):One can also inspect the contents of the `extension-apiserver-authentication` ConfigMap which is used as a trust anchor by all extension API servers:It is assumed that an attacker has obtained access to a Kubernetes pod and could communicate with `virt-api` reachable at `10.244.0.6`.The `virt-api` service has two types of endpoints -- authenticated and non-authenticated:Each endpoint which is not in this list is considered an authenticated endpoint and requires a valid client certificate to be presented by the caller.To illustrate the vulnerability and attack scenario, below is generated a certificate signed by the `front-proxy-ca` but issued to an entity which is different than `front-proxy-client` (i.e the certificate has a different CN). Later on, it is assumed that the attacker has obtained access to the certificate bundle:The authentication will now succeed:To fully exploit the vulnerability, the attacker must also provide valid authentication HTTP headers:The `virt-api` is a sub-resource extension server - it handles only requests for specific resources and sub-resources (requests having URIs prefixed with `/apis/subresources.kubevirt.io/v1/`). In reality, most of the requests that it accepts are actually executed by the `virt-handler` component and are related to the lifecycle of a VM.Hence, `virt-handler`'s API can be seen as aggregated within `virt-api`'s API which in turn transforms it into a proxy.The endpoints which are handled by `virt-api` are listed in the Swagger definitions available on GitHub @openapi-spec.Resetting a Virtual Machine InstanceConsider the following deployed `VirtualMachineInstance` (VMI) within the default namespace:An attacker with a stolen external authentication proxy certificate could easily reset (hard reboot), freeze, or remove volumes from the virtual machine.Impact_What kind of vulnerability is it? Who is impacted?_The `virt-api` component may allow an attacker to bypass existing RBAC controls by directly communicating with the aggregated API server, impersonating the Kubernetes API server and its aggregator component.
CVSS v3.1 score: 4.7