CVE-2022-31247: Rancher has downstream cluster privilege escalation through cluster and project role template binding (CRTB/PRTB)
An issue was discovered in Rancher versions up to and including 2.5.15 and 2.6.6 where a flaw with authorization logic allows privilege escalation through cluster role template binding (CRTB) and project role template binding (PRTB). This issue does not affect the local cluster, it affects only downstream clusters.
The vulnerability can be exploited by any user who has permissions to create/edit cluster role template bindings or project role template bindings (such as cluster-owner, manage cluster members, project-owner and manage project members) to gain owner permission in another project in the same cluster or in another project on a different downstream cluster.
The user must have
kubectlaccess in the local cluster to exploit this scenario.This can only be abused to gain
cluster-ownerpermission on a different downstream cluster if the user is alreadycluster-owneron at least one downstream cluster.Example of a modified CRTB (note: the
clusterNamepoints to the cluster ID of the cluster that the privileges will be escalated andnamespacepoints to the current cluster ID that the user has permissions):
kubectl edit clusterroletemplatebindings crtb-<crtb-ID> -n c-<cluster-ID>
---
apiVersion: management.cattle.io/v3
clusterName: <ID-of-the-cluster-to-escalate>
kind: ClusterRoleTemplateBinding
metadata:
annotations:
<omitted>
finalizers:
- <omitted>
generateName: crtb-
labels:
<omitted>
cattle.io/creator: norman
name: crtb-<crtb-ID>
namespace: c-<current-cluster-ID>
roleTemplateName: cluster-owner
userName: u-<user-ID>
userPrincipalName: local://u-<user-ID>
An artifact to flag the exploitation of this issue is that the namespace of the CRTB/PRTB will not match the cluster name (clusterName) of the CRTB/PRTB. For example, every CRTB in the c-123xyz namespace should have a cluster name of c-123xyz. If instead, the cluster name is c-abc567, for example, this is likely a result of a user exploiting this flaw.
References
Code Behaviors & Features
Detect and mitigate CVE-2022-31247 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →