October 2, 2023

The most recent model of Kubernetes launched final month contains 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 said about the vulnerability he found and which triggered the invention of two different comparable points. “To use this vulnerability, the attacker wants to use a malicious YAML file on the cluster.”

Assault YAML

Kubernetes is a broadly in style container orchestration system that’s utilized by organizations to automate the deployment and administration of functions operating in containers. YAML is a language used to write 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 option to push person 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 person 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 analyze the difficulty additional.

Kubernetes permits mounting a listing from the host system inside a container via a property referred to as quantity. It is a broadly used characteristic 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 supplied 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 may connect PowerShell code to the subPath string the place it could be executed.

“PowerShell permits customers to guage values inside strings earlier than they’re used,” the researcher defined. “This may be completed by including $(<experssion_to_be_evaluated>) to your string […]. Any PowerShell command could be inserted between the parentheses and can be evaluated — reminiscent of $(Begin-Course of cmd), $(Invoke-Expression exp), and different PowerShell treats.”