ghsa-6m9f-pj6w-w87g
Vulnerability from github
Published
2023-04-24 22:34
Modified
2023-04-25 18:09
Severity ?
Summary
Rancher Webhook is misconfigured during upgrade process
Details

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:

```sh $ 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.

```yaml

!/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

  • https://github.com/rancher/webhook/pull/216/commits/a4a498613b43a3ee93c5ab06742a3bc8adace45d

For more information

If you have any questions or comments about this advisory:

Show details on source website


{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/rancher/rancher"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "2.7.2"
            },
            {
              "fixed": "2.7.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ],
      "versions": [
        "2.7.2"
      ]
    }
  ],
  "aliases": [
    "CVE-2023-22651"
  ],
  "database_specific": {
    "cwe_ids": [],
    "github_reviewed": true,
    "github_reviewed_at": "2023-04-24T22:34:59Z",
    "nvd_published_at": "2023-05-04T08:15:22Z",
    "severity": "CRITICAL"
  },
  "details": "### Impact\n\nA failure in the update logic of Rancher\u0027s 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.\n\nWhen the Webhook is operating in a degraded state, it no longer validates any resources, which may result in severe privilege escalations and data corruption.\n\nThe 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.\n\nThe command below can be executed on the `local` cluster to determine whether the cluster is affected by this issue:\n\n```sh\n$ kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io\n\nNAME                WEBHOOKS   AGE\nrancher.cattle.io   0         19h\n```\n\nIf the resulting webhook quantity is `0`, the Rancher instance is affected.\n\n### Patches\n\nPatched versions include release `2.7.3` and later versions.\n\n### Workarounds\n\nIf 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.\n\n```yaml\n#!/bin/bash\n\nset -euo pipefail\n\nfunction prereqs() {\n    if ! [ -x \"$(command -v kubectl)\" ]; then\n      echo \"error: kubectl is not installed.\" \u003e\u00262\n      exit 1\n    fi\n\n    if [[ -z \"$(kubectl config view -o jsonpath=\u0027{.clusters[].cluster.server}\u0027)\" ]]; then\n        echo \"error: No kubernetes cluster found on kubeconfig.\" \u003e\u00262\n        exit 1\n    fi\n}\n\nfunction restart_deployment(){\n    kubectl rollout restart deployment rancher-webhook -n cattle-system\n    kubectl rollout status deployment rancher-webhook -n cattle-system --timeout=30s\n}\n\nfunction workaround() {\n    echo \"Cluster: $(kubectl config view -o jsonpath=\u0027{.clusters[].cluster.server}\u0027)\"\n\n    if ! kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io \u003e /dev/null 2\u003e\u00261; then\n        echo \"webhook rancher.cattle.io not found, restarting deployment:\"\n        restart_deployment\n\n        echo \"waiting for webhook configuration\"\n        sleep 15s\n    fi\n\n    local -i webhooks\n    webhooks=\"$(kubectl get validatingwebhookconfigurations.admissionregistration.k8s.io rancher.cattle.io --no-headers | awk \u0027{ print $2 }\u0027)\"\n\n    if [ \"${webhooks}\" == \"0\" ]; then\n        echo \"Webhook misconfiguration status: Cluster is affected by CVE-2023-22651\"\n        \n        echo \"Running workaround:\"\n        kubectl delete validatingwebhookconfiguration rancher.cattle.io\n        restart_deployment\n\n        ret=$?\n        if [ $ret -eq 0 ]; then\n            echo \"Webhook restored, CVE-2023-22651 is fixed\"\n        else\n            echo \"error trying to restart deployment. try again in a few seconds.\"\n        fi\n    else\n        echo \"Webhook misconfiguration status: not present (skipping)\"\n    fi\n\n    echo \"Done\"\n}\n\nfunction main() {\n    prereqs\n    workaround\n}\n\nmain\n```\n\n### References\n- https://github.com/rancher/webhook/pull/216/commits/a4a498613b43a3ee93c5ab06742a3bc8adace45d\n\n### For more information\nIf you have any questions or comments about this advisory:\n\n- Reach out to the [SUSE Rancher Security team](https://github.com/rancher/rancher/security/policy) for security related inquiries.\n- Open an issue in the [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/).",
  "id": "GHSA-6m9f-pj6w-w87g",
  "modified": "2023-04-25T18:09:03Z",
  "published": "2023-04-24T22:34:59Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/rancher/rancher/security/advisories/GHSA-6m9f-pj6w-w87g"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/rancher/rancher"
    },
    {
      "type": "WEB",
      "url": "https://github.com/rancher/rancher/releases/tag/v2.7.3"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Rancher Webhook is misconfigured during upgrade process"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading...

Loading...

Loading...

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
  • Confirmed: The vulnerability is confirmed from an analyst perspective.
  • Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
  • Patched: This vulnerability was successfully patched by the user reporting the sighting.
  • Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
  • Not confirmed: The user expresses doubt about the veracity of the vulnerability.
  • Not patched: This vulnerability was not successfully patched by the user reporting the sighting.