VYPR
Moderate severityNVD Advisory· Published Mar 3, 2022· Updated Aug 3, 2024

CVE-2021-3602

CVE-2021-3602

Description

An information disclosure flaw was found in Buildah, when building containers using chroot isolation. Running processes in container builds (e.g. Dockerfile RUN commands) can access environment variables from parent and grandparent processes. When run in a container in a CI/CD environment, environment variables may include sensitive information that was shared with the container in order to be used only by Buildah itself (e.g. container registry credentials).

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
github.com/containers/buildahGo
< 1.16.81.16.8
github.com/containers/buildahGo
>= 1.17.0, < 1.17.21.17.2
github.com/containers/buildahGo
>= 1.18.0, < 1.19.91.19.9
github.com/containers/buildahGo
>= 1.20.0, < 1.21.31.21.3

Affected products

1
  • Range: Affects v1.21.2, v1.20.0, v1.19.8, v1.18.0, v1.17.1, v1.16.7, Fixed in v1.21.3, v1.19.9, v1.17.2, v1.16.8, v1.22.0 and above.

Patches

1
a468ce0ffd34

chroot: fix environment value leakage to intermediate processes

https://github.com/containers/buildahNalin DahyabhaiJun 2, 2021via ghsa
4 files changed · +26 24
  • chroot/run.go+5 10 modified
    @@ -161,7 +161,7 @@ func RunUsingChroot(spec *specs.Spec, bundlePath, homeDir string, stdin io.Reade
     	cmd := unshare.Command(runUsingChrootCommand)
     	cmd.Stdin, cmd.Stdout, cmd.Stderr = stdin, stdout, stderr
     	cmd.Dir = "/"
    -	cmd.Env = append([]string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}, os.Environ()...)
    +	cmd.Env = []string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}
     
     	logrus.Debugf("Running %#v in %#v", cmd.Cmd, cmd)
     	confwg.Add(1)
    @@ -207,7 +207,7 @@ func runUsingChrootMain() {
     		os.Exit(1)
     	}
     
    -	if options.Spec == nil {
    +	if options.Spec == nil || options.Spec.Process == nil {
     		fmt.Fprintf(os.Stderr, "invalid options spec in runUsingChrootMain\n")
     		os.Exit(1)
     	}
    @@ -573,7 +573,7 @@ func runUsingChroot(spec *specs.Spec, bundlePath string, ctty *os.File, stdin io
     	cmd := unshare.Command(append([]string{runUsingChrootExecCommand}, spec.Process.Args...)...)
     	cmd.Stdin, cmd.Stdout, cmd.Stderr = stdin, stdout, stderr
     	cmd.Dir = "/"
    -	cmd.Env = append([]string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}, os.Environ()...)
    +	cmd.Env = []string{fmt.Sprintf("LOGLEVEL=%d", logrus.GetLevel())}
     	cmd.UnshareFlags = syscall.CLONE_NEWUTS | syscall.CLONE_NEWNS
     	requestedUserNS := false
     	for _, ns := range spec.Linux.Namespaces {
    @@ -663,7 +663,7 @@ func runUsingChrootExecMain() {
     	// Set the hostname.  We're already in a distinct UTS namespace and are admins in the user
     	// namespace which created it, so we shouldn't get a permissions error, but seccomp policy
     	// might deny our attempt to call sethostname() anyway, so log a debug message for that.
    -	if options.Spec == nil {
    +	if options.Spec == nil || options.Spec.Process == nil {
     		fmt.Fprintf(os.Stderr, "invalid options spec passed in\n")
     		os.Exit(1)
     	}
    @@ -819,7 +819,6 @@ func runUsingChrootExecMain() {
     // Output debug messages when that differs from what we're being asked to do.
     func logNamespaceDiagnostics(spec *specs.Spec) {
     	sawMountNS := false
    -	sawUserNS := false
     	sawUTSNS := false
     	for _, ns := range spec.Linux.Namespaces {
     		switch ns.Type {
    @@ -854,9 +853,8 @@ func logNamespaceDiagnostics(spec *specs.Spec) {
     			}
     		case specs.UserNamespace:
     			if ns.Path != "" {
    -				logrus.Debugf("unable to join user namespace %q, creating a new one", ns.Path)
    +				logrus.Debugf("unable to join user namespace, sorry about that")
     			}
    -			sawUserNS = true
     		case specs.UTSNamespace:
     			if ns.Path != "" {
     				logrus.Debugf("unable to join UTS namespace %q, creating a new one", ns.Path)
    @@ -867,9 +865,6 @@ func logNamespaceDiagnostics(spec *specs.Spec) {
     	if !sawMountNS {
     		logrus.Debugf("mount namespace not requested, but creating a new one anyway")
     	}
    -	if !sawUserNS {
    -		logrus.Debugf("user namespace not requested, but creating a new one anyway")
    -	}
     	if !sawUTSNS {
     		logrus.Debugf("UTS namespace not requested, but creating a new one anyway")
     	}
    
  • docs/buildah-bud.md+7 5 modified
    @@ -307,11 +307,13 @@ another process.
     Controls what type of isolation is used for running processes as part of `RUN`
     instructions.  Recognized types include *oci* (OCI-compatible runtime, the
     default), *rootless* (OCI-compatible runtime invoked using a modified
    -configuration, with *--no-new-keyring* added to its *create*
    -invocation, with network and UTS namespaces disabled, and IPC, PID,
    -and user namespaces enabled; the default for unprivileged users), and
    -*chroot* (an internal wrapper that leans more toward chroot(1) than
    -container technology).
    +configuration, with *--no-new-keyring* added to its *create* invocation,
    +reusing the host's network and UTS namespaces, and creating private IPC, PID,
    +mount, and user namespaces; the default for unprivileged users), and *chroot*
    +(an internal wrapper that leans more toward chroot(1) than container
    +technology, reusing the host's control group, network, IPC, and PID namespaces,
    +and creating private mount and UTS namespaces, and creating user namespaces
    +only when they're required for ID mapping).
     
     Note: You can also override the default isolation type by setting the
     BUILDAH\_ISOLATION environment variable.  `export BUILDAH_ISOLATION=oci`
    
  • docs/buildah-from.md+7 5 modified
    @@ -234,11 +234,13 @@ another process.
     Controls what type of isolation is used for running processes under `buildah
     run`.  Recognized types include *oci* (OCI-compatible runtime, the default),
     *rootless* (OCI-compatible runtime invoked using a modified
    -configuration, with *--no-new-keyring* added to its *create*
    -invocation, with network and UTS namespaces disabled, and IPC, PID,
    -and user namespaces enabled; the default for unprivileged users), and
    -*chroot* (an internal wrapper that leans more toward chroot(1) than
    -container technology).
    +configuration, with *--no-new-keyring* added to its *create* invocation,
    +reusing the host's network and UTS namespaces, and creating private IPC, PID,
    +mount, and user namespaces; the default for unprivileged users), and *chroot*
    +(an internal wrapper that leans more toward chroot(1) than container
    +technology, reusing the host's control group, network, IPC, and PID namespaces,
    +and creating private mount and UTS namespaces, and creating user namespaces
    +only when they're required for ID mapping).
     
     Note: You can also override the default isolation type by setting the
     BUILDAH\_ISOLATION environment variable.  `export BUILDAH_ISOLATION=oci`
    
  • docs/buildah-run.md+7 4 modified
    @@ -82,10 +82,13 @@ process.
     Controls what type of isolation is used for running the process.  Recognized
     types include *oci* (OCI-compatible runtime, the default), *rootless*
     (OCI-compatible runtime invoked using a modified configuration, with
    -*--no-new-keyring* added to its *create* invocation, with network and
    -UTS namespaces disabled, and IPC, PID, and user namespaces enabled;
    -the default for unprivileged users), and *chroot* (an internal wrapper
    -that leans more toward chroot(1) than container technology).
    +*--no-new-keyring* added to its *create* invocation, reusing the host's network
    +and UTS namespaces, and creating private IPC, PID, mount, and user namespaces;
    +the default for unprivileged users), and *chroot* (an internal wrapper that
    +leans more toward chroot(1) than container technology, reusing the host's
    +control group, network, IPC, and PID namespaces, and creating private mount and
    +UTS namespaces, and creating user namespaces only when they're required for ID
    +mapping).
     
     Note: You can also override the default isolation type by setting the
     BUILDAH\_ISOLATION environment variable.  `export BUILDAH_ISOLATION=oci`
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

7

News mentions

0

No linked articles in our index yet.