Buildah processes using chroot isolation may leak environment values to intermediate processes
### 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:[email protected]), or [the podman security mailing list](mailto:[email protected]) if it's sensitive.
02 / AFFECTED SOFTWARE
Affected packages
28 explicit affected versions
03 / CONNECTIONS
Connected vulnerabilities
04 / EVIDENCE
Source records
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).
### 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:[email protected]), or [the podman security mailing list](mailto:[email protected]) if it's sensitive.
The RunUsingChroot function unintentionally propagates environment variables from the current process to the child process.
05 / REFERENCES
Further evidence
- https://bugzilla.redhat.com/show_bug.cgi?id=1969264
- https://github.com/containers/buildah/commit/a468ce0ffd347035d53ee0e26c205ef604097fb0
- https://github.com/containers/buildah/security/advisories/GHSA-7638-r9r3-rmjj
- https://ubuntu.com/security/CVE-2021-3602
- https://github.com/containers/buildah
- https://nvd.nist.gov/vuln/detail/CVE-2021-3602
- https://pkg.go.dev/vuln/GO-2022-0345