A vulnerability has been identified within Rancher where a cluster or node driver can be used to escape the chroot jail and gain root access to the Rancher container itself. In production environments, further privilege escalation is possible based on living off the land within the Rancher container itself. For the test and development environments, based on a –privileged Docker container, it is possible to escape the Docker container and gain execution access on the host system.
This happens because:
/opt/drivers/management-state/bin directory to the PATH environment variable./usr/bin/rancher-machine, /usr/bin/helm_v3, and /usr/bin/kustomize are assigned a UID of 1001 and a GID of 127 instead of being owned by the root user.Please consult the associated MITRE ATT&CK - Technique - Privilege Escalation and MITRE ATT&CK - Technique - Execution for further information about this category of attack.
Since they run at a privileged level, it is recommended to use trusted drivers only.
The fix involves some key areas with the following changes:
Fixing the PATH environment variable:
/opt/drivers/management-state/bin to the PATH environment variable.Binaries permissions:
/usr/bin/rancher-machine, /usr/bin/helm_v3, and /usr/bin/kustomize so that they are owned by the root user.Improving Rancher jail security mechanism:
jail-accessors has been created, and the rancher user has been added to this group.jail-accessors group is granted read and execute permissions for the directories /var/lib/rancher, /var/lib/cattle, and /usr/local/bin.rancher user and the jail-accessors group. Additionally, a new setting, UnprivilegedJailUser, has been introduced to manage this behavior, allowing users to opt-out if they need to run drivers in a more privileged context.Fixing node driver registration:
NewPlugin(driver) function in the rancher/machine module has been updated to allow setting the UID and GID for starting the plugin server. If the environment variables MACHINE_PLUGIN_UID and MACHINE_PLUGIN_GID are set, their values will be used to configure the user credentials for launching the plugin server.NewPlugin(driver) function and then unsets them after retrieving the creation flags.Improvements on driver package:
driver package has been revised to verify that the downloaded driver binary is a regular file.driver package has been revised to verify that the target file in the downloaded tar file is a regular file.driver package now executes the downloaded driver binary within a jail, with a default timeout of 5 seconds.Other improvements:
nodeConfig package has been updated to ensure proper permissions are applied when extracting the node configuration.Patched versions include releases 2.7.16, 2.8.9 and 2.9.3.
If you can't upgrade to a fixed version, please make sure that:
If you have any questions or comments about this advisory:
{
"cwe_ids": [
"CWE-269"
],
"github_reviewed": true,
"github_reviewed_at": "2024-10-25T19:37:22Z",
"nvd_published_at": "2025-04-16T09:15:27Z",
"severity": "CRITICAL"
}