Access Restriction Bypass Affecting github.com/rancher/rancher package, versions >=2.6.0 <2.7.3


Severity

Recommended
0.0
critical
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    EPSS
    0.09% (39th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-GOLANG-GITHUBCOMRANCHERRANCHER-5458971
  • published 25 Apr 2023
  • disclosed 24 Apr 2023
  • credit Unknown

How to fix?

Upgrade github.com/rancher/rancher to version 2.7.3 or higher.

Overview

Affected versions of this package are vulnerable to Access Restriction Bypass such that when the Webhook is operating in a degraded state, it no longer validates any resources, which may result in severe privilege escalations and data corruption.

Note: The issue only affects users that upgrade from 2.6.x or 2.7.x to 2.7.2. Users that did a fresh install of 2.7.2 (and did not follow an upgrade path) are not affected.

The command below can be executed on the local cluster to determine whether the cluster is affected by this issue:

$ kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io

If the resulting webhook quantity is 0, the Rancher instance is affected.

Workaround

Users who are unable to upgrade to the fixed version can manually reconfigure the Webhook with the script below. Please note that the script must be run from inside the local cluster or with a kubeconfig pointing to the local cluster which has admin permissions.

#!/bin/bash

set -euo pipefail

function prereqs() { if ! [ -x "$(command -v kubectl)" ]; then echo "error: kubectl is not installed." >&2 exit 1 fi

if [[ -z &quot;$(kubectl config view -o jsonpath=&#39;{.clusters[].cluster.server}&#39;)&quot; ]]; then
    echo &quot;error: No kubernetes cluster found on kubeconfig.&quot; &gt;&amp;2
    exit 1
fi

}

function restart_deployment(){ kubectl rollout restart deployment rancher-webhook -n cattle-system kubectl rollout status deployment rancher-webhook -n cattle-system --timeout=30s }

function workaround() { echo "Cluster: $(kubectl config view -o jsonpath='{.clusters[].cluster.server}')"

if ! kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io &gt; /dev/null 2&gt;&amp;1; then
    echo &quot;webhook rancher.cattle.io not found, restarting deployment:&quot;
    restart_deployment

    echo &quot;waiting for webhook configuration&quot;
    sleep 15s
fi

local -i webhooks
webhooks=&quot;$(kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io --no-headers | awk &#39;{ print $2 }&#39;)&quot;

if [ &quot;${webhooks}&quot; == &quot;0&quot; ]; then
    echo &quot;Webhook misconfiguration status: Cluster is affected by CVE-2023-22651&quot;
    
    echo &quot;Running workaround:&quot;
    kubectl delete validatingwebhookconfiguration rancher.cattle.io
    restart_deployment

    ret=$?
    if [ $ret -eq 0 ]; then
        echo &quot;Webhook restored, CVE-2023-22651 is fixed&quot;
    else
        echo &quot;error trying to restart deployment. try again in a few seconds.&quot;
    fi
else
    echo &quot;Webhook misconfiguration status: not present (skipping)&quot;
fi

echo &quot;Done&quot;

}

function main() { prereqs workaround }

main

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
9.9 critical
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    Low
  • User Interaction (UI)
    None
  • Scope (S)
    Changed
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High
Expand this section

NVD

9.9 critical