CVE-2022-43759: Github.com/rancher/rancher Privilege Escalation Vulnerability

HIGH
Advisory Identifier: GHSA-7m72-mh5r-6j3r
CVSS 7.2
CWE-284 CWE-269
Published
Advisory Summary

CVE-2022-43759 is a HIGH (CVSS 7.2) privilege escalation vulnerability (CWE-284: Improper Access Control) affecting Github.com/rancher/rancher libraries in the Go ecosystem. The issue involves privilege escalation in project role template binding (prtb) and -promoted roles. Remediation is available by upgrading affected packages to version 2.5.17, 2.6.10.

CVE-2022-43759 at a Glance

CVE Identifier CVE-2022-43759
GHSA Identifier GHSA-7m72-mh5r-6j3r
Severity HIGH
CVSS v3.1 Base Score 7.2
CWE Classification CWE-284: Improper Access Control
Affected Product Github.com/rancher/rancher
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-43759

To remediate this vulnerability, upgrade all affected Github.com/rancher/rancher dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/rancher/rancher fixed: 2.5.17
Upgrade github.com/rancher/rancher to 2.5.17
github.com/rancher/rancher fixed: 2.6.10
Upgrade github.com/rancher/rancher to 2.6.10
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/rancher/rancher

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-43759, inspect your project dependencies for Github.com/rancher/rancher:

inspect dependencies for github.com/rancher/rancher

Analyze the terminal output to locate any version of Github.com/rancher/rancher in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.17), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-284: Improper Access Control, where the product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. In Github.com/rancher/rancher, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact An issue was discovered in Rancher versions from 2.5.0 up to and including 2.5.16 and from 2.6.0 up to and including 2.6.9, where an authorization logic flaw allows privilege escalation via project role template binding (PRTB) and `-promoted` roles. This issue is not present in Rancher 2.7 releases. Note: Consult Rancher [documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/manage-role-based-access-control-rbac/cluster-and-project-roles) for more information about cluster and project roles and [KB 000020097](https://www.suse.com/support/kb/doc/?id=000020097) for information about `-promoted` roles. This privilege escalation is possible for users with access to the `escalate` verb on PRTBs (`projectroletemplatebindings.management.cattle.io`), including users with `*` verbs on PRTBs (see notes below for more information). These users can escalate permissions for any `-promoted` resource (see the table below for a full enumeration) in any cluster where they have a PRTB granting such permissions in at least one project in the cluster. On a default Rancher setup, only the following roles have such permissions: 1. Project Owner 2. Manage Project Members These roles have permissions to affect the following resources: | Resource | API Group | Affected Rancher version | | - | - | - | | navlinks | ui.cattle.io | 2.6 | | nodes | "" | 2.6 | | persistentvolumes | "" | 2.5, 2.6 | | persistentvolumes | core | 2.5, 2.6 | | storageclasses | storage.k8s.io | 2.5, 2.6 | | apiservices | apiregistration.k8s.io | 2.5, 2.6 | | clusterrepos | catalog.cattle.io | 2.5, 2.6 | | clusters (`local` only) | management.cattle.io | 2.5, 2.6 | Notes: 1. During the calculation of the CVSS score, `privileges required` was considered as `high` because, by default, `standard user` and `user-base` users in Rancher do not have `create`, `patch` and `update` permissions on `roletemplates`. 2. If a role template with access to those objects was already created by another user in the cluster, then this issue can be exploited by users without the mentioned permissions from point 1. ### Workarounds If updating Rancher to a patched version is not possible, then the following workarounds must be observed to mitigate this issue: 1. Only grant Project Owner and Manage Project Members roles to trusted users. 5. Minimize the creation of custom roles that contain the `escalate`, `*` or write verbs (`create`, `delete`, `patch`, `update`) on `projectroletemplatebindings` resource, and only grant such custom roles to trusted users. 6. Minimize the number of users that have permissions to `create`, `patch` and `update` `roletemplates`. ### Patches Patched versions include releases 2.5.17 and 2.6.10 and later versions. This issue is not present in Rancher 2.7 releases. ### Detection The following script was developed to list role template bindings that give written access to the affected resources listed above. It is highly recommended to run the script in your environment and review the list of identified roles and role template bindings for possible signs of exploitation of this issue. The script requires `jq` installed and a `kubeconfig` with access to Rancher local cluster; it can also be executed in Rancher's kubectl shell. ```shell #!/bin/bash help=" Usage: bash find_promoted_resource.sh \n \n Requires: \n - jq installed and on path \n - A kubeconfig pointing at rancher's local cluster (can also run from rancher's kubectl shell) \n \n Outputs a list of roletemplates and roletemplate bindings which give write access to promoted resources. " if [[ $1 == "-h" || $1 == "--help" ]] then echo -e $help exit 0 fi # first, get the current roletemplates so that we only issue a get once kubectl get roletemplates.management.cattle.io -o json >> script_templates.json # find roles which have write access to a promoted resource. Filter on roleTemplates which fulfill all requirements: # Have a project context # Have some rules # Have one/more of the target api groups, or a * in the api groups # Have one/more of the target resources, or a * in the resources # Have a verb that is not read access (i.e. a verb that is not get/list/watch) roles=$(jq --argjson apiGroups '["", "ui.cattle.io", "core", "storage.k8s.io", "apiregistration.k8s.io", "catalog.cattle.io", "management.cattle.io"]' --argjson resources '["navlinks", "persistentvolumes", "nodes", "storageclasses", "apiservices", "clusterrepos", "clusters"]' --argjson verbs '["get", "list", "watch"]' '.items[] | select(.context=="project" and (.rules | length >= 1)) | select( .rules[] | select( (($apiGroups - .apiGroups | length < 7) or (.apiGroups | index("*"))) and (($resources - .resources | length < 7) or (.resources | index("*"))) and (.verbs - $verbs | length > 0)) | length >= 1 ) | .metadata.name' script_templates.json | jq -s ) # log promoted roles which give direct write access so they can be easily fixed echo "The following role templates give direct write access to a promoted resource:" echo $roles echo -e "" # find any roles which inherit first-level roles. Mostly a BFS which radiates outward from the known bad roles old_roles="[]" new_roles="$roles" old_length=$(echo $old_roles | jq 'length') new_length=$(echo $new_roles | jq 'length') # if our last loop found nothing new, it's safe to stop while [[ $old_length != $new_length ]]; do # set old values to what we currently know about old_roles=$new_roles old_length=$new_length # update new values with anything that inherits a "bad" role we know about new_roles=$(jq --argjson roles "$old_roles" --argjson roleLen "$old_length" '.items[] | .metadata.name as $NAME | select (( $roles | index($NAME)) or ((.roleTemplateNames | length > 0 ) and ($roles - .roleTemplateNames | length < $roleLen))) | .metadata.name ' script_templates.json | jq -s) new_length=$(echo $new_roles | jq 'length') done roles=$new_roles # log all roles which can give write access, even if it's not first level echo -e "The following role templates give write access to a promoted resource directly or through inheritance:" echo $roles echo -e "" kubectl get projectroletemplatebindings.management.cattle.io -A -o json >> script_bindings.json role_template_bindings=$(jq --argjson roleTemplates "$roles" '.items[] | .roleTemplateName as $TemplateName | select($roleTemplates | index($TemplateName)) | .metadata.name' script_bindings.json | jq -s) # since these bindings could be for users or groups, we need to include all fields which could help identify the subject. But they won't all be present, which makes the list look less pretty echo -e "The following is a list of bindings which give access to promoted resource, with the format of: bindingName, projectName, userName, userPrincipalName, groupName, groupPrincipalName: " echo $(jq --argjson bindings "$role_template_bindings" '.items[] | .metadata.name as $BindingName | select ( $bindings | index($BindingName)) | .metadata.name, .projectName, .userName?, .userPrincipalName?, .groupName?, .groupPrincipalName?' script_bindings.json | jq -s) unset old_roles unset new_roles unset roles unset role_template_bindings rm script_templates.json rm script_bindings.json ``` ### For more information If you have any questions or comments about this advisory: * Reach out to [SUSE Rancher Security team](https://github.com/rancher/rancher/security/policy) for security related inquiries. * Open an issue in [Rancher](https://github.com/rancher/rancher/issues/new/choose) repository. * Verify our [support matrix](https://www.suse.com/suse-rancher/support-matrix/all-supported-versions/) and [product support lifecycle](https://www.suse.com/lifecycle/)

CVE-2022-43759 Affected Github.com/rancher/rancher Versions

2 component(s)
Fixed Versions:
2.5.172.6.10
Product / Package Ecosystem Affected Versions Fixed Version
github.com/rancher/rancher
Go
≥ 2.5.0
< 2.5.17
2.5.17
github.com/rancher/rancher
Go
≥ 2.6.0
< 2.6.10
2.6.10

References

Frequently Asked Questions

What is CVE-2022-43759?
CVE-2022-43759 is a security vulnerability in Github.com/rancher/rancher involving Privilege escalation in project role template binding (PRTB) and -promoted roles under CWE-284: Improper Access Control.
Which Github.com/rancher/rancher versions are affected?
Affected versions include releases prior to 2.5.17, 2.6.10 across affected packages: github.com/rancher/rancher.
What version fixes CVE-2022-43759?
Upgrading to 2.5.17, 2.6.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/rancher/rancher affected?
Yes, github.com/rancher/rancher is affected in releases prior to 2.5.17, 2.6.10. Upgrade your dependency to 2.5.17, 2.6.10 or later.
What is the CVSS score of CVE-2022-43759?
CVE-2022-43759 has a CVSS v3.1 base score of 7.2 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-43759?
CVE-2022-43759 is classified under CWE-284: Improper Access Control (The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor.).
How can I check Go dependencies for CVE-2022-43759?
Run the dependency tree command: 'inspect dependencies for github.com/rancher/rancher'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7m72-mh5r-6j3r",
  "modified" : "2023-02-15T22:01:37Z",
  "published" : "2023-01-25T19:35:02Z",
  "aliases" : [ "CVE-2022-43759" ],
  "summary" : "Privilege escalation in project role template binding (PRTB) and -promoted roles",
  "details" : "### Impact\n\nAn issue was discovered in Rancher versions from 2.5.0 up to and including 2.5.16 and from 2.6.0 up to and including 2.6.9, where an authorization logic flaw allows privilege escalation via project role template binding (PRTB) and `-promoted` roles. This issue is not present in Rancher 2.7 releases.\n\nNote: Consult Rancher [documentation](https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/authentication-permissions-and-global-configuration/manage-role-based-access-control-rbac/cluster-and-project-roles) for more information about cluster and project roles and [KB 000020097](https://www.suse.com/support/kb/doc/?id=000020097) for information about `-promoted` roles.\n\nThis privilege escalation is possible for users with access to the `escalate` verb on PRTBs (`projectroletemplatebindings.management.cattle.io`), including users with `*` verbs on PRTBs (see notes below for more information). These users can escalate permissions for any `-promoted` resource (see the table below for a full enumeration) in any cluster where they have a PRTB granting such permissions in at least one project in the cluster.\n\nOn a default Rancher setup, only the following roles have such permissions:\n\n1. Project Owner\n2. Manage Project Members\n\nThese roles have permissions to affect the following resources:\n\n| Resource | API Group | Affected Rancher version |\n| - | - | - |\n| navlinks | ui.cattle.io | 2.6 |\n| nodes | \"\" | 2.6 |\n| persistentvolumes | \"\" | 2.5, 2.6 |\n| persistentvolumes | core | 2.5, 2.6 |\n| storageclasses | storage.k8s.io | 2.5, 2.6 |\n| apiservices | apiregistration.k8s.io | 2.5, 2.6 |\n| clusterrepos | catalog.cattle.io | 2.5, 2.6 |\n| clusters (`local` only) | management.cattle.io | 2.5, 2.6 |\n\nNotes:\n\n1. During the calculation of the CVSS score, `privileges required` was considered  as `high` because, by default, `standard user` and `user-base` users in Rancher do not have  `create`, `patch` and `update` permissions on `roletemplates`.\n2. If a role template with access to those objects was already created by another user in the cluster, then this issue can be exploited by users without the mentioned permissions from point 1.\n\n### Workarounds\n\nIf updating Rancher to a patched version is not possible, then the following workarounds must be observed to mitigate this issue:\n\n1. Only grant Project Owner and Manage Project Members roles to trusted users.\n5. Minimize the creation of custom roles that contain the `escalate`, `*` or write verbs (`create`, `delete`, `patch`, `update`) on `projectroletemplatebindings` resource, and only grant such custom roles to trusted users.\n6. Minimize the number of users that have permissions to `create`, `patch` and `update` `roletemplates`.\n\n### Patches\n\nPatched versions include releases 2.5.17 and 2.6.10 and later versions. This issue is not present in Rancher 2.7 releases.\n\n### Detection\n\nThe following script was developed to list role template bindings that give written access to the affected resources listed above. It is highly recommended to run the script in your environment and review the list of identified roles and role template bindings for possible signs of exploitation of this issue. The script requires `jq` installed and a `kubeconfig` with access to Rancher local cluster; it can also be executed in Rancher's kubectl shell.\n\n```shell\n#!/bin/bash\n\nhelp=\"\nUsage: bash find_promoted_resource.sh \\n \\n\n\nRequires: \\n\n- jq installed and on path \\n\n- A kubeconfig pointing at rancher's local cluster (can also run from rancher's kubectl shell) \\n \\n\n\nOutputs a list of roletemplates and roletemplate bindings which give write access to promoted resources.\n\"\n\nif [[ $1 == \"-h\" || $1 == \"--help\" ]]\nthen\n\techo -e $help\n\texit 0\nfi\n\n# first, get the current roletemplates so that we only issue a get once\nkubectl get roletemplates.management.cattle.io -o json >> script_templates.json\n\n# find roles which have write access to a promoted resource. Filter on roleTemplates which fulfill all requirements:\n# Have a project context\n# Have some rules\n# Have one/more of the target api groups, or a * in the api groups\n# Have one/more of the target resources, or a * in the resources\n# Have a verb that is not read access (i.e. a verb that is not get/list/watch)\nroles=$(jq --argjson apiGroups '[\"\", \"ui.cattle.io\", \"core\", \"storage.k8s.io\", \"apiregistration.k8s.io\", \"catalog.cattle.io\", \"management.cattle.io\"]' --argjson resources '[\"navlinks\", \"persistentvolumes\", \"nodes\", \"storageclasses\", \"apiservices\", \"clusterrepos\", \"clusters\"]' --argjson verbs '[\"get\", \"list\", \"watch\"]' '.items[] | select(.context==\"project\" and (.rules | length >= 1)) | select( .rules[] | select( (($apiGroups - .apiGroups | length < 7) or (.apiGroups | index(\"*\"))) and (($resources - .resources | length < 7) or (.resources | index(\"*\"))) and (.verbs - $verbs  | length > 0)) | length >= 1 ) | .metadata.name' script_templates.json | jq -s )\n\n# log promoted roles which give direct write access so they can be easily fixed\necho \"The following role templates give direct write access to a promoted resource:\"\necho $roles\necho -e \"\"\n\n# find any roles which inherit first-level roles. Mostly a BFS which radiates outward from the known bad roles \nold_roles=\"[]\"\nnew_roles=\"$roles\"\nold_length=$(echo $old_roles | jq 'length')\nnew_length=$(echo $new_roles | jq 'length')\n# if our last loop found nothing new, it's safe to stop\nwhile [[ $old_length != $new_length ]];\ndo\n\t# set old values to what we currently know about\n\told_roles=$new_roles\n\told_length=$new_length\n\t# update new values with anything that inherits a \"bad\" role we know about\n\tnew_roles=$(jq --argjson roles \"$old_roles\" --argjson roleLen \"$old_length\" '.items[] | .metadata.name as $NAME | select (( $roles | index($NAME)) or ((.roleTemplateNames | length > 0 ) and ($roles - .roleTemplateNames | length < $roleLen))) | .metadata.name ' script_templates.json | jq -s)\n\tnew_length=$(echo $new_roles | jq 'length')\ndone\n\nroles=$new_roles\n\n# log all roles which can give write access, even if it's not first level\necho -e \"The following role templates give write access to a promoted resource directly or through inheritance:\"\necho $roles\necho -e \"\"\n\nkubectl get projectroletemplatebindings.management.cattle.io -A -o json >> script_bindings.json\nrole_template_bindings=$(jq --argjson roleTemplates \"$roles\" '.items[] | .roleTemplateName as $TemplateName | select($roleTemplates | index($TemplateName)) | .metadata.name' script_bindings.json | jq -s)\n\n# since these bindings could be for users or groups, we need to include all fields which could help identify the subject. But they won't all be present, which makes the list look less pretty\necho -e \"The following is a list of bindings which give access to promoted resource, with the format of: bindingName, projectName, userName, userPrincipalName, groupName, groupPrincipalName: \"\necho $(jq --argjson bindings \"$role_template_bindings\" '.items[] | .metadata.name as $BindingName | select ( $bindings | index($BindingName)) | .metadata.name, .projectName, .userName?, .userPrincipalName?, .groupName?, .groupPrincipalName?' script_bindings.json | jq -s)\n\nunset old_roles\nunset new_roles\nunset roles\nunset role_template_bindings\nrm script_templates.json\nrm script_bindings.json\n```\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* Reach out to [SUSE Rancher Security team](https://github.com/rancher/rancher/security/policy) for security related inquiries.\n* Open an issue in [Rancher](https://github.com/rancher/rancher/issues/new/choose) repository.\n* Verify our [support matrix](https://www.suse.com/suse-rancher/support-matrix/all-supported-versions/) and [product support lifecycle](https://www.suse.com/lifecycle/)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/rancher/rancher"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.5.0"
      }, {
        "fixed" : "2.5.17"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/rancher/rancher"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.6.0"
      }, {
        "fixed" : "2.6.10"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/rancher/rancher/security/advisories/GHSA-7m72-mh5r-6j3r"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-43759"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.suse.com/show_bug.cgi?id=1205293"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rancher/rancher"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-269", "CWE-284" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-01-25T19:35:02Z",
    "nvd_published_at" : "2023-02-07T13:15:00Z"
  }
}