In this long-read post, we will dive deep into the recently discovered vulnerability CVE-2022-27651. This vulnerability has affected two popular containerization technologies, Buildah and Moby (Docker Engine), by incorrectly allowing containers to start with non-empty default permissions. As a result, an attacker can potentially exploit this weakness to elevate their privileges and gain unauthorized access to sensitive data, thus compromising the confidentiality and integrity of the affected system.

To better understand the severity of this vulnerability, we will break down its components, including background on Buildah and Moby, the specific vulnerabilities in these two projects, code snippets showcasing the issue, and links to original references and resources. Furthermore, we will discuss the exploit details and potential impacts.

Background: Buildah and Moby (Docker Engine)

Buildah is an open-source container building tool designed to create and manage container images easily. It provides a more efficient and developer-friendly approach to building container images without the need for a separate daemon.

Moby, previously known as Docker Engine, is an open-source containerization technology that enables developers to automate the deployment, scaling, and management of applications within containers. It provides a platform for packaging and distributing applications as lightweight container images.

Flawed Permissions in Buildah

The vulnerability in Buildah revolves around its containers not starting properly due to incorrect default permissions. Ideally, containers should run in a confined environment with the least possible privilege, restricting access to potentially sensitive system resources. However, the flaw in Buildah causes containers to start with non-empty default permissions, allowing the potential for unauthorized access.

Code Snippet: Buildah Container Permission Issue

# Creating a new Buildah container with the affected version
buildah from registry.access.redhat.com/ubi8/ubi

# Checking the container's default permissions
buildah run <container_id> cat /proc/self/status

In the output of the /proc/self/status command, the "CapEff" (Effective Capabilities) field should be a hexadecimal value representing the effective capabilities of the process. A non-zero value indicates that the default permissions are not empty and the container is potentially vulnerable.

Flawed Capabilities Inheritance in Moby (Docker Engine)

The vulnerability in Moby (Docker Engine) is related to the incorrect inheritance of Linux process capabilities. In a containerized environment, processes are expected to inherit only a limited and necessary set of capabilities. However, the bug in Moby allows processes to inherit non-empty capabilities, thus providing the attacker an opportunity to elevate their privileges.

Code Snippet: Moby Capabilities Inheritance Issue

# Running a Docker container with the affected version
docker run --rm -it <image_id> /bin/bash

# Checking the container's inheritable process capabilities
cat /proc/self/status

In the output, you should check the "CapInh" (Inheritable Capabilities) field. A non-zero value for this field indicates that the container is incorrectly inheriting non-empty capabilities and is potentially vulnerable.

Original References and Resources

- Buildah GitHub Repository: https://github.com/containers/buildah
- Moby GitHub Repository: https://github.com/moby/moby
- CVE-2022-27651 Details: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-27651

Exploit Details and Potential Impact

An attacker who successfully exploits this vulnerability may gain unauthorized access to containers and elevate their privileges to obtain sensitive information or tamper with the system's integrity. With enough knowledge and resources, the attacker could potentially compromise an entire container infrastructure.

The vulnerable containers can expose both the host system and any interconnected nodes to malicious actions. Due to the nature of containerized environments, attacks can propagate through the network, leading to potential security breaches at an organizational level.

Conclusion

The recently discovered CVE-2022-27651 vulnerability in Buildah and Moby (Docker Engine) highlights the importance of securing containerized environments and ensuring that containers run with proper permissions and capabilities. To mitigate the risks associated with this vulnerability, users must ensure that they are using the latest version of Buildah and Moby (Docker Engine) with the necessary patches applied. Regularly updating your container infrastructure and closely monitoring for security vulnerability disclosures can help protect against potential exploits.

Timeline

Published on: 04/04/2022 20:15:00 UTC
Last modified on: 05/07/2022 07:15:00 UTC