Now on Demand Ransomware Resilience & Recovery Summit - All Sessions Available
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.

Join the session as we discuss the challenges and best practices for cybersecurity leaders managing cloud identities.

Register

SecurityWeek’s Ransomware Resilience and Recovery Summit helps businesses to plan, prepare, and recover from a ransomware incident.

Register

People on the Move

Bill Dunnion has joined telecommunications giant Mitel as Chief Information Security Officer.

MSSP Dataprise has appointed Nima Khamooshi as Vice President of Cybersecurity.

Backup and recovery firm Keepit has hired Kim Larsen as CISO.

More People On The Move

Expert Insights

Related Content

Vulnerabilities

Less than a week after announcing that it would suspended service indefinitely due to a conflict with an (at the time) unnamed security researcher...

Data Breaches

OpenAI has confirmed a ChatGPT data breach on the same day a security firm reported seeing the use of a component affected by an...

IoT Security

A group of seven security researchers have discovered numerous vulnerabilities in vehicles from 16 car makers, including bugs that allowed them to control car...

Vulnerabilities

A researcher at IOActive discovered that home security systems from SimpliSafe are plagued by a vulnerability that allows tech savvy burglars to remotely disable...

Risk Management

The supply chain threat is directly linked to attack surface management, but the supply chain must be known and understood before it can be...

Cybercrime

Patch Tuesday: Microsoft calls attention to a series of zero-day remote code execution attacks hitting its Office productivity suite.

Vulnerabilities

Patch Tuesday: Microsoft warns vulnerability (CVE-2023-23397) could lead to exploitation before an email is viewed in the Preview Pane.

IoT Security

A vulnerability affecting Dahua cameras and video recorders can be exploited by threat actors to modify a device’s system time.