A Storage Vulnerability Deep Dive

0
124
A Storage Vulnerability Deep Dive

[ad_1]

Posted by Fabricio Voznika and Mauricio Poppe, Google Cloud Kubernetes Safety is consistently evolving – retaining tempo with enhanced performance, usability and adaptability whereas additionally balancing the safety wants of a large and various set of use-cases.Lately, the GKE Safety workforce found a excessive severity vulnerability that allowed workloads to have entry to elements of the host filesystem outdoors the mounted volumes boundaries. Though the vulnerability was patched again in September we thought it will be helpful to put in writing up a extra in-depth evaluation of the problem to share with the group.We assessed the influence of the vulnerability as described in vulnerability administration in open-source Kubernetes and labored carefully with the GKE Storage workforce and the Kubernetes Safety Response Committee to discover a repair. On this put up we’ll give some background on how the subpath storage system works, an outline of the vulnerability, the steps to search out the foundation trigger and the repair, and eventually some suggestions for GKE and Anthos customers.Kubernetes Filesystems: Intro to Quantity SubpathThe vulnerability, CVE-2021-25741, was brought on by a race situation in the course of the creation of a subpath bind mount inside a container, and allowed an attacker to realize unauthorized entry to the underlying node filesystem and its delicate recordsdata. We’ll describe how that system is meant to work, after which speak concerning the vulnerability.The quantity subpath function in Kubernetes allows sharing a quantity in a number of containers inside a pod. For instance, we might create a Pod with an InitContainer that creates directories with pre-populated information in a mounted filesystem quantity. These directories can then be utilized by containers in the identical Pod by mounting the identical quantity and optionally specifying a subpath area to restrict what’s seen contained in the container.Whereas there are some nice use instances for this function, it’s an space that has had vulnerabilities found prior to now. The kubelet have to be additional cautious when dealing with user-owned subpaths as a result of it operates with privileges within the host. One vulnerability that has been beforehand found concerned the creation of a malicious workload the place an InitContainer would create a symlink pointing to any location within the host. For instance, the InitContainer might mount a quantity in /mnt and create a symlink /mnt/assault contained in the container pointing to /and so on. Later within the Pod lifecycle, one other container would try to mount the identical quantity with subpath assault. Whereas getting ready the volumes for the container, the kubelet would find yourself following the symlink to the host’s /and so on as an alternative of the container’s /and so on, unknowingly exposing the host filesystem to the container. A earlier repair made positive that the subpath mount location is resolved and validated to level to a location inside the bottom quantity and that it isn’t changeable by the consumer in between the time the trail was validated and when the container runtime bind mounts it. This race situation is named time of verify to time of use (TOCTOU) the place the topic being validated modifications after it has been validated.These validations and others are summarized within the following container lifecycle sequence diagram.Quantity subpath validations earlier than the container startupA New TOCTOU Vulnerability: CVE-2021-25741The newest vulnerability was found by performing a symlink assault much like the one defined above, with the distinction being that it continuously swapped the symlink with a listing in a good loop, utilizing the RENAME_EXCHANGE possibility with renameat(2). If the timing is excellent, the kubelet will see the trail as a listing and cross the validation verify. Then the mount utility could discover that the trail is a symlink pointing to the host and comply with it, exposing the host filesystem to the container. That is visualized within the following diagram:The expectation and the assault outcomeThe GKE Safety and Storage groups labored carefully to revise the repair executed beforehand to discover a resolution. The earlier repair takes a number of steps to make sure that the listing being mounted is safely opened and validated. After the file is opened and validated, the kubelet makes use of the magic-link path beneath /proc/[pid]/fd listing for all subsequent operations to make sure the file stays unchanged. Nevertheless, we came upon that the entire efforts have been undone by the mount(8) linux utility which was dereferencing the procfs magic-link by default. As soon as the issue was understood, the repair concerned ensuring that the mount utility would not dereference the magic-links through the use of the –no-canonicalize flag within the mount command.The repair is inOnce the issue was effectively understood, we fastened it inside Kubernetes and shortly launched the repair to GKE and Anthos. If GKE auto-upgrade is enabled in your clusters there isn’t any motion in your half for this vulnerability, your nodes have already been patched. We strongly advocate that prospects make the most of auto-upgrades. Auto-upgrade offers peace of thoughts that your clusters are operating with the newest patches.GKE launched a Google Kubernetes Engine safety bulletin on this vulnerability, which detailed what prospects can do to right away remediate this problem throughout GKE and Anthos. We additionally offered steerage to prospects who manually handle their node variations, guaranteeing that fastened releases have been out there in each area for our Static and Launch Channels.Shifting forwardGoogle continues to speculate closely within the safety of GKE and Kubernetes. We encourage customers fascinated about discovering vulnerabilities to take part within the Kubernetes bug bounty program and within the Google Vulnerability Rewards Program (VRP) which was lately expanded to cowl GKE vulnerabilities. For the newest steerage on safety points, please comply with our GKE Safety Bulletins.

[ad_2]