CVE-2022-24877: Github.com/fluxcd/kustomize controller Path Traversal Vulnerability

CRITICAL
Advisory Identifier: GHSA-j77r-2fxf-5jrw
CVSS 9.9
CWE-22
Published
Advisory Summary

CVE-2022-24877 is a CRITICAL (CVSS 9.9) path traversal vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Github.com/fluxcd/kustomize controller libraries in the Go ecosystem. The issue involves improper path handling in kustomization files allows path traversal. Remediation is available by upgrading affected packages to version 0.24.0, 0.29.0.

CVE-2022-24877 at a Glance

CVE Identifier CVE-2022-24877
GHSA Identifier GHSA-j77r-2fxf-5jrw
Severity CRITICAL
CVSS v3.1 Base Score 9.9
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Github.com/fluxcd/kustomize controller
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 9.9

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

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

How to Fix CVE-2022-24877

To remediate this vulnerability, upgrade all affected Github.com/fluxcd/kustomize controller 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/fluxcd/kustomize-controller fixed: 0.24.0
Upgrade github.com/fluxcd/kustomize-controller to 0.24.0
github.com/fluxcd/flux2 fixed: 0.29.0
Upgrade github.com/fluxcd/flux2 to 0.29.0
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/fluxcd/kustomize-controller

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-24877, inspect your project dependencies for Github.com/fluxcd/kustomize controller:

inspect dependencies for github.com/fluxcd/kustomize-controller

Analyze the terminal output to locate any version of Github.com/fluxcd/kustomize controller in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.24.0), 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-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Github.com/fluxcd/kustomize controller, 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

The kustomize-controller enables the use of Kustomize’s functionality when applying Kubernetes declarative state onto a cluster. A malicious user can use built-in features and a specially crafted `kustomization.yaml` to expose sensitive data from the controller’s pod filesystem. In multi-tenancy deployments this can lead to privilege escalation if the controller's service account has elevated permissions. Within the affected versions, users with write access to a Flux source are able to use built-in features to expose sensitive data from the controller’s pod filesystem using a malicious `kustomization.yaml` file. This vulnerability was fixed in kustomize-controller v0.24.0 and included in flux2 v0.29.0 released on 2022-04-20. The changes introduce a new Kustomize file system implementation which ensures that all files being handled are contained within the Kustomization working directory, blocking references to any files that do not meet that requirement. Automated tooling (e.g. conftest) could be employed as a workaround, as part of a user's CI/CD pipeline to ensure that their `kustomization.yaml` files conform with specific policies, blocking access to sensitive path locations.

CVE-2022-24877 Affected Github.com/fluxcd/kustomize controller Versions

2 component(s)
Fixed Versions:
0.24.00.29.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/fluxcd/kustomize-controller
Go
< 0.24.0
0.24.0
github.com/fluxcd/flux2
Go
< 0.29.0
0.29.0

References

Frequently Asked Questions

What is CVE-2022-24877?
CVE-2022-24877 is a security vulnerability in Github.com/fluxcd/kustomize controller involving Improper path handling in kustomization files allows path traversal under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Github.com/fluxcd/kustomize controller versions are affected?
Affected versions include releases prior to 0.24.0, 0.29.0 across affected packages: github.com/fluxcd/kustomize-controller, github.com/fluxcd/flux2.
What version fixes CVE-2022-24877?
Upgrading to 0.24.0, 0.29.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/fluxcd/kustomize-controller affected?
Yes, github.com/fluxcd/kustomize-controller is affected in releases prior to 0.24.0. Upgrade your dependency to 0.24.0 or later.
Is github.com/fluxcd/flux2 affected?
Yes, github.com/fluxcd/flux2 is affected in releases prior to 0.29.0. Upgrade your dependency to 0.29.0 or later.
What is the CVSS score of CVE-2022-24877?
CVE-2022-24877 has a CVSS v3.1 base score of 9.9 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2022-24877?
CVE-2022-24877 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check Go dependencies for CVE-2022-24877?
Run the dependency tree command: 'inspect dependencies for github.com/fluxcd/kustomize-controller'. 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-j77r-2fxf-5jrw",
  "modified" : "2022-06-02T17:41:47Z",
  "published" : "2022-05-04T18:04:07Z",
  "aliases" : [ "CVE-2022-24877" ],
  "summary" : "Improper path handling in kustomization files allows path traversal",
  "details" : "The kustomize-controller enables the use of Kustomize’s functionality when applying Kubernetes declarative state onto a cluster. A malicious user can use built-in features and a specially crafted `kustomization.yaml` to expose sensitive data from the controller’s pod filesystem. In multi-tenancy deployments this can lead to privilege escalation if the controller's service account has elevated permissions.\n\nWithin the affected versions, users with write access to a Flux source are able to use built-in features to expose sensitive data from the controller’s pod filesystem using a malicious `kustomization.yaml` file.\n\nThis vulnerability was fixed in kustomize-controller v0.24.0 and included in flux2 v0.29.0 released on 2022-04-20. The changes introduce a new Kustomize file system implementation which ensures that all files being handled are contained within the Kustomization working directory, blocking references to any files that do not meet that requirement.\n\nAutomated tooling (e.g. conftest) could be employed as a workaround, as part of a user's CI/CD pipeline to ensure that their `kustomization.yaml` files conform with specific policies, blocking access to sensitive path locations.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/fluxcd/kustomize-controller"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.24.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/fluxcd/flux2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.29.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fluxcd/flux2/security/advisories/GHSA-j77r-2fxf-5jrw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24877"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fluxcd/kustomize-controller/commit/f4528fb25d611da94e491346bea056d5c5c3611f"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fluxcd/pkg/commit/0ec014baf417fd3879d366a45503a548b9267d2a"
  }, {
    "type" : "PACKAGE",
    "url" : "github.com/fluxcd/kustomize-controller"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-05-04T18:04:07Z",
    "nvd_published_at" : "2022-05-06T01:15:00Z"
  }
}