The newest 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.”
Assault YAML
Kubernetes is a extensively well-liked container orchestration system that’s utilized by organizations to automate the deployment and administration of purposes working in containers. YAML is a language used to write down configuration and different administration recordsdata for Kubernetes. It subsequently is sensible for it to be a goal for potential attackers because it’s a direct approach 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 exterior the container, breaking the isolation. It was these final two flaws that gave Peled the concept to analyze the difficulty additional.
Kubernetes permits mounting a listing from the host system inside a container via a property known as quantity. This can be 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. Nevertheless, it does this via a PowerShell command that’s invoked by the “exec.Command” perform name. This opens the chance 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 achieved by including $(<experssion_to_be_evaluated>) to your string […]. Any PowerShell command will be inserted between the parentheses and shall be evaluated — comparable to $(Begin-Course of cmd), $(Invoke-Expression exp), and different PowerShell treats.”