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.
| Package | Affected versions | Patched versions |
|---|---|---|
github.com/containers/buildahGo | < 1.16.8 | 1.16.8 |
github.com/containers/buildahGo | >= 1.17.0, < 1.17.2 | 1.17.2 |
github.com/containers/buildahGo | >= 1.18.0, < 1.19.9 | 1.19.9 |
github.com/containers/buildahGo | >= 1.20.0, < 1.21.3 | 1.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
1a468ce0ffd34chroot: fix environment value leakage to intermediate processes
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- github.com/advisories/GHSA-7638-r9r3-rmjjghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-3602ghsaADVISORY
- bugzilla.redhat.com/show_bug.cgighsax_refsource_MISCWEB
- github.com/containers/buildah/commit/a468ce0ffd347035d53ee0e26c205ef604097fb0ghsax_refsource_MISCWEB
- github.com/containers/buildah/security/advisories/GHSA-7638-r9r3-rmjjghsax_refsource_MISCWEB
- pkg.go.dev/vuln/GO-2022-0345ghsaWEB
- ubuntu.com/security/CVE-2021-3602ghsax_refsource_MISCWEB
News mentions
0No linked articles in our index yet.