Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS02bTlmLXBqNnctdzg3Z84AAy88

Rancher Webhook is misconfigured during upgrade process

Impact

A failure in the update logic of Rancher's admission Webhook may lead to the misconfiguration of the Webhook. This component enforces validation rules and security checks before resources are admitted into the Kubernetes cluster.

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.

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

NAME                WEBHOOKS   AGE
rancher.cattle.io   0         19h

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

Patches

Patched versions include release 2.7.3 and later versions.

Workarounds

If you are affected and cannot update to a patched Rancher version, the recommended workaround is to 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 "$(kubectl config view -o jsonpath='{.clusters[].cluster.server}')" ]]; then
        echo "error: No kubernetes cluster found on kubeconfig." >&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 > /dev/null 2>&1; then
        echo "webhook rancher.cattle.io not found, restarting deployment:"
        restart_deployment

        echo "waiting for webhook configuration"
        sleep 15s
    fi

    local -i webhooks
    webhooks="$(kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io --no-headers | awk '{ print $2 }')"

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

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

    echo "Done"
}

function main() {
    prereqs
    workaround
}

main

References

For more information

If you have any questions or comments about this advisory:

Permalink: https://github.com/advisories/GHSA-6m9f-pj6w-w87g
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS02bTlmLXBqNnctdzg3Z84AAy88
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: over 1 year ago
Updated: about 1 year ago


CVSS Score: 10.0
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

Identifiers: GHSA-6m9f-pj6w-w87g, CVE-2023-22651
References: Repository: https://github.com/rancher/rancher
Blast Radius: 16.0

Affected Packages

go:github.com/rancher/rancher
Dependent packages: 30
Dependent repositories: 40
Downloads:
Affected Version Ranges: = 2.7.2
Fixed in: 2.7.3
All affected versions:
All unaffected versions: 0.4.0, 0.4.2, 0.4.3, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.10.1, 0.11.0, 0.11.1, 0.12.0, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.14.2, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.16.2, 0.16.3, 0.17.0, 0.17.1, 0.18.0, 0.18.1, 0.18.2, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.21.0, 0.21.1, 0.21.2, 0.21.3, 0.21.4, 0.24.0, 0.25.0, 0.28.0, 0.30.0, 0.31.0, 0.32.0, 0.34.0, 0.35.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