The most recent model of Kubernetes launched final month consists of patches for a whole class of vulnerabilities that enable attackers to abuse the subPath property of YAML configuration recordsdata to execute malicious instructions on Home windows hosts. “The vulnerability permits distant code execution with SYSTEM privileges on all Home windows endpoints inside a Kubernetes cluster,” Akamai researcher Tomer Peled mentioned in regards to the vulnerability he discovered and which triggered the invention of two different comparable points. “To take advantage of this vulnerability, the attacker wants to use a malicious YAML file on the cluster.”
Attack YAML
Kubernetes is a extensively in style container orchestration system that’s utilized by organizations to automate the deployment and administration of functions working in containers. YAML is a language used to jot down configuration and different administration recordsdata for Kubernetes. It due to this fact is sensible for it to be a goal for potential attackers because it’s a direct solution to push consumer enter to the Kubernetes engine and have it parsed and interpreted.
YAML parsing points have led to Kubernetes vulnerabilities earlier than. For instance the CVE-2022-1471 distant code execution vulnerability within the SnakeYaml parser impacted the Kubernetes Java consumer, whereas the CVE-2021-25749 flaw allowed misspelled consumer names to be included in a YAML file ensuing within the execution of workloads as root. The CVE-2017-1002101 and CVE-2021-25741 points then confirmed how the subPath subproperty in a YAML file can be utilized together with symbolic hyperlinks (symlinks) to entry recordsdata outdoors the container, breaking the isolation. It was these final two flaws that gave Peled the thought to research the problem additional.
Kubernetes permits mounting a listing from the host system inside a container by means of a property known as quantity. It is a extensively used function and comes with a number of subproperties to outline the trail of the listing on the host and the mount path contained in the container. The mountPath additional has a subPath property that when offered in a YAML file is processed by kubelet, a core Kubernetes service.
New path processing points permits PowerShell code execution
Peled discovered that when the subPath string is processed, kubelet additionally checks if it’s a symlink, which is a part of the defenses put in place for the older vulnerabilities. Nonetheless, it does this by means of a PowerShell command that’s invoked by the “exec.Command” perform name. This opens the likelihood that an attacker might connect PowerShell code to the subPath string the place it might be executed.
“PowerShell permits customers to judge values inside strings earlier than they’re used,” the researcher defined. “This may be finished by including $(<experssion_to_be_evaluated>) to your string […]. Any PowerShell command may be inserted between the parentheses and can be evaluated — akin to $(Begin-Course of cmd), $(Invoke-Expression exp), and different PowerShell treats.”