CVE-2021-3602: Github.com/containers/buildah Buildah Processes Using Chroot Isolation Vulnerability

MODERATE
Advisory Identifier: GHSA-7638-r9r3-rmjj
CVSS 5.5
CWE-212 CWE-200
Published
Advisory Summary

CVE-2021-3602 is a MODERATE (CVSS 5.5) buildah processes using chroot isolation vulnerability (CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer) affecting Github.com/containers/buildah libraries in the Go ecosystem. The issue involves buildah processes using chroot isolation may leak environment values to intermediate processes. Remediation is available by upgrading affected packages to version 1.16.8, 1.17.2, 1.19.9, 1.21.3.

CVE-2021-3602 at a Glance

CVE Identifier CVE-2021-3602
GHSA Identifier GHSA-7638-r9r3-rmjj
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer
Affected Product Github.com/containers/buildah
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.5

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

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

How to Fix CVE-2021-3602

To remediate this vulnerability, upgrade all affected Github.com/containers/buildah 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/containers/buildah fixed: 1.16.8
Upgrade github.com/containers/buildah to 1.16.8
github.com/containers/buildah fixed: 1.17.2
Upgrade github.com/containers/buildah to 1.17.2
github.com/containers/buildah fixed: 1.19.9
Upgrade github.com/containers/buildah to 1.19.9
github.com/containers/buildah fixed: 1.21.3
Upgrade github.com/containers/buildah to 1.21.3
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/containers/buildah

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-3602, inspect your project dependencies for Github.com/containers/buildah:

inspect dependencies for github.com/containers/buildah

Analyze the terminal output to locate any version of Github.com/containers/buildah in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.16.8), 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-212: Improper Removal of Sensitive Information Before Storage or Transfer, where the product stores, transfers, or shares a resource that contains sensitive information, but it does not properly remove that information before the product makes the resource available to unauthorized actors. In Github.com/containers/buildah, 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 When running processes using "chroot" isolation, the process being run can examine the environment variables of its immediate parent and grandparent processes (CVE-2021-3602). This isolation type is often used when running `buildah` in unprivileged containers, and it is often used to do so in CI/CD environments. If sensitive information is exposed to the original `buildah` process through its environment, that information will unintentionally be shared with child processes which it starts as part of handling RUN instructions or during `buildah run`. The commands that `buildah` is instructed to run can read that information if they choose to. ### Patches Users should upgrade packages, or images which contain packages, to include version 1.21.3 or later. ### Workarounds As a workaround, invoking `buildah` in a container under `env -i` to have it started with a reinitialized environment should prevent the leakage. ### For more information If you have any questions or comments about this advisory: * Open an issue in [buildah](https://github.com/containers/buildah/issues) * Email us at [the buildah general mailing list](mailto:buildah@lists.buildah.io), or [the podman security mailing list](mailto:security@lists.podman.io) if it's sensitive.

CVE-2021-3602 Affected Github.com/containers/buildah Versions

4 component(s)
Fixed Versions:
1.16.81.17.21.19.91.21.3
Product / Package Ecosystem Affected Versions Fixed Version
github.com/containers/buildah
Go
< 1.16.8
1.16.8
github.com/containers/buildah
Go
≥ 1.17.0
< 1.17.2
1.17.2
github.com/containers/buildah
Go
≥ 1.18.0
< 1.19.9
1.19.9
github.com/containers/buildah
Go
≥ 1.20.0
< 1.21.3
1.21.3

References

Frequently Asked Questions

What is CVE-2021-3602?
CVE-2021-3602 is a security vulnerability in Github.com/containers/buildah involving Buildah processes using chroot isolation may leak environment values to intermediate processes under CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer.
Which Github.com/containers/buildah versions are affected?
Affected versions include releases prior to 1.16.8, 1.17.2, 1.19.9, 1.21.3 across affected packages: github.com/containers/buildah.
What version fixes CVE-2021-3602?
Upgrading to 1.16.8, 1.17.2, 1.19.9, 1.21.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/containers/buildah affected?
Yes, github.com/containers/buildah is affected in releases prior to 1.16.8, 1.17.2, 1.19.9, 1.21.3. Upgrade your dependency to 1.16.8, 1.17.2, 1.19.9, 1.21.3 or later.
What is the CVSS score of CVE-2021-3602?
CVE-2021-3602 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2021-3602?
CVE-2021-3602 is classified under CWE-212: Improper Removal of Sensitive Information Before Storage or Transfer (The product stores, transfers, or shares a resource that contains sensitive information, but it does not properly remove that information before the product makes the resource available to unauthorized actors.).
How can I check Go dependencies for CVE-2021-3602?
Run the dependency tree command: 'inspect dependencies for github.com/containers/buildah'. 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-7638-r9r3-rmjj",
  "modified" : "2023-08-29T18:32:51Z",
  "published" : "2021-07-19T15:19:09Z",
  "aliases" : [ "CVE-2021-3602" ],
  "summary" : "Buildah processes using chroot isolation may leak environment values to intermediate processes",
  "details" : "### Impact\nWhen running processes using \"chroot\" isolation, the process being run can examine the environment variables of its immediate parent and grandparent processes (CVE-2021-3602).  This isolation type is often used when running `buildah` in unprivileged containers, and it is often used to do so in CI/CD environments.  If sensitive information is exposed to the original `buildah` process through its environment, that information will unintentionally be shared with child processes which it starts as part of handling RUN instructions or during `buildah run`.  The commands that `buildah` is instructed to run can read that information if they choose to.\n\n### Patches\nUsers should upgrade packages, or images which contain packages, to include version 1.21.3 or later.\n\n### Workarounds\nAs a workaround, invoking `buildah` in a container under `env -i` to have it started with a reinitialized environment should prevent the leakage.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [buildah](https://github.com/containers/buildah/issues)\n* Email us at [the buildah general mailing list](mailto:buildah@lists.buildah.io), or [the podman security mailing list](mailto:security@lists.podman.io) if it's sensitive.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/containers/buildah"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.16.8"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.16.7"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/containers/buildah"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.17.0"
      }, {
        "fixed" : "1.17.2"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.17.1"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/containers/buildah"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.18.0"
      }, {
        "fixed" : "1.19.9"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.19.8"
    }
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/containers/buildah"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.20.0"
      }, {
        "fixed" : "1.21.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 1.21.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/containers/buildah/security/advisories/GHSA-7638-r9r3-rmjj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-3602"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/containers/buildah/commit/a468ce0ffd347035d53ee0e26c205ef604097fb0"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=1969264"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/containers/buildah"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2022-0345"
  }, {
    "type" : "WEB",
    "url" : "https://ubuntu.com/security/CVE-2021-3602"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-200", "CWE-212" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-07-15T20:26:57Z",
    "nvd_published_at" : "2022-03-03T19:15:00Z"
  }
}