Connect with us

Hi, what are you looking for?

SecurityWeekSecurityWeek

Vulnerabilities

Code Execution in Alpine Linux Impacts Containers

A security researcher discovered several vulnerabilities in Alpine Linux, a distribution commonly used with Docker, including one that could allow for arbitrary code execution. 

Based on musl and BusyBox, the Alpine Linux distribution has a small size and is heavily used in containers, including Docker, as it provides fast boot times. 

A security researcher discovered several vulnerabilities in Alpine Linux, a distribution commonly used with Docker, including one that could allow for arbitrary code execution. 

Based on musl and BusyBox, the Alpine Linux distribution has a small size and is heavily used in containers, including Docker, as it provides fast boot times. 

APK, the default package manager in Alpine, is impacted by several bugs, security researcher Max Justicz has discovered. The most important of them, the researcher says, could allow a network man-in-the-middle (or a malicious package mirror) to execute arbitrary code on the user’s machine. 

“This is especially bad because packages aren’t served over TLS when using the default repositories,” Justicz notes

An attacker could target a Docker container based on Alpine for code execution, the security researcher reveals. Justicz also published a video detailing such an attack. 

The issue, the researcher explains, is that the package manager extracts packages (which are gzipped tar files distributed as apks) before checking their hashes. If the downloaded package’s hash doesn’t match, the APK then attempts to unlink all extracted files and directories. 

The APK’s commit hooks feature allows an attacker to turn persistent arbitrary file writes into code execution, as long as the files survive the cleanup process. Thus, the files are executed before apk exits.

For that, the attacker needs to be in control of the downloaded tar file and ensure that the APK won’t be able to unlink the payload and its directory during the cleanup process. 

Advertisement. Scroll to continue reading.

The next step is to make the APK process exit successfully, which requires the return of exit code 0. Normally, it “will return an exit code equal to the number of packages it has failed to install, which is now at least one,” the researcher explains. 

However, the value can overflow and, if the number of errors % 256 == 0, the process returns exit code 0, meaning the attack was successful. The researcher was also able to write shellcode to exit(0) directly into memory and have it executed. 

The bug likely impacts all those who use Alpine Linux in a production environment. All Alpine-derived container images should be rebuilt to eliminate the issue, the researcher points out. 

Alpine Linux, the researcher says, is used by probably hundreds of organizations, all of which could have been affected by this bug. 

“Some of those organizations almost certainly have bug bounty programs that would pay generously if a similar bug had been written by one of their own developers. If the goal of a bug bounty program is to help secure an organization, shouldn’t critical bugs in dependencies qualify to some extent?” Justicz concludes.

Related: Microsoft Patches Critical Flaw in Open Source Container Library

Written By

Ionut Arghire is an international correspondent for SecurityWeek.

Click to comment

Trending

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest threats, trends, and technology, along with insightful columns from industry experts.

Learn how the LOtL threat landscape has evolved, why traditional endpoint hardening methods fall short, and how adaptive, user-aware approaches can reduce risk.

Watch Now

Join the summit to explore critical threats to public cloud infrastructure, APIs, and identity systems through discussions, case studies, and insights into emerging technologies like AI and LLMs.

Register

People on the Move

Coro, a provider of cybersecurity solutions for SMBs, has appointed Joe Sykora as CEO.

SonicWall has hired Rajnish Mishra as Senior Vice President and Chief Development Officer.

Kenna Security co-founder Ed Bellis has joined Empirical Security as Chief Executive Officer.

More People On The Move

Expert Insights

Daily Briefing Newsletter

Subscribe to the SecurityWeek Email Briefing to stay informed on the latest cybersecurity news, threats, and expert insights. Unsubscribe at any time.