Notice on the Vulnerability of Kubernetes subPath Symlink Exchange (CVE-2021-25741)
A security issue was spotted in Kubernetes where a user may be able to create a container with subPath volume mounted to access files and directories outside of the volume, including those on the host file system.
Vulnerability Details
| Vulnerability Type | CVE-ID | Discovered |
|---|---|---|
| Resource management flaw | 2021-09-15 |
Threat Severity
Medium
Impact and Risks
- If a malicious user creates a container with a subPath volume mounted, the user can access files and directories outside the volume, including those on the host file system.
- Clusters for which the cluster administrator has restricted the ability to create hostPath mounts are most severely affected. An attacker can exploit this vulnerability to perform access similar to hostPath without using the hostPath function, thereby bypassing the restriction.
- In the default Kubernetes environment, vulnerability exploitation can be used to mask the abuse of granted privileges.
Trigger Conditions
The VolumeSubpath feature is enabled by default.
Root Cause
When a container uses subPath to mount some files or directories, attackers may use Symlink Exchange to access directories other than the mount directory or files on the host, causing unauthorized operations.
Identification Method
This vulnerability has been fixed for clusters of version 1.19.10 in CN South-Guangzhou, CN North-Beijing4, CN Southwest-Guiyang1, CN East-Shanghai2, CN East-Shanghai1, and CN North-Beijing1. Clusters of v1.19.10 in these regions are not affected.
Log in to the node and run the following command to check BuidDate. If BuidDate is later than August 20, 2021, the vulnerability has been fixed and the system is not affected by the vulnerability.

Workarounds and Mitigation Measures
You can disable VolumeSubpath feature gate on kubelet and delete any existing pods that use the subPath function.
- Log in to each CCE node as user root.
- Modify the kubelet configuration parameter to disable the VolumeSubpath feature.
vi /opt/cloud/cce/kubernetes/kubelet/kubelet_config.yaml
Add the VolumeSubpath: false field.

- Restart kubelet.
systemctl restart kubelet
- Ensure that the new kubelet process is started and VolumeSubpath is disabled.
vi /var/paas/sys/log/kubernetes/kubelet.log
Search for VolumeSubpath=false. If it can be found, the function is successfully disabled.

- Delete any pod that uses the subPath function.
Enabling or Rolling Back the VolumeSubpath Feature
- Modify the kubelet configuration file and delete the VolumeSubpath field.
vi /opt/cloud/cce/kubernetes/kubelet/kubelet_config.yaml
- Restart kubelet.
systemctl restart kubelet
- Check that the new kubelet process is started and the kubelet.log file does not contain VolumeSubpath=false.
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.