CVE-2021-30139

7.5 HIGH

📋 TL;DR

This vulnerability in Alpine Linux's apk-tools package manager allows a buffer overflow when parsing malicious tarball files, potentially leading to application crashes or arbitrary code execution. It affects Alpine Linux systems using apk-tools before version 2.12.5. The vulnerability can be triggered by processing specially crafted APK package files.

💻 Affected Systems

Products:
  • Alpine Linux apk-tools
Versions: All versions before 2.12.5
Operating Systems: Alpine Linux
Default Config Vulnerable: ⚠️ Yes
Notes: Any system using apk-tools for package management is vulnerable when processing APK packages.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution with the privileges of the apk-tools process, potentially leading to full system compromise if apk-tools runs with elevated privileges.

🟠

Likely Case

Denial of service through application crashes when processing malicious package files, disrupting package management operations.

🟢

If Mitigated

Limited impact if apk-tools runs with minimal privileges and proper input validation is in place elsewhere.

🌐 Internet-Facing: MEDIUM - Requires processing malicious package files, which could come from untrusted repositories or user uploads.
🏢 Internal Only: LOW - Typically requires local access or interaction with malicious package files.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires crafting a malicious tarball file that triggers the buffer overflow, which requires understanding of the tarball parser implementation.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.12.5 and later

Vendor Advisory: https://gitlab.alpinelinux.org/alpine/apk-tools/-/issues/10741

Restart Required: No

Instructions:

1. Update apk-tools: 'apk update && apk upgrade apk-tools' 2. Verify installation: 'apk --version' should show 2.12.5 or higher

🔧 Temporary Workarounds

Restrict package sources

linux

Only use trusted APK repositories and avoid processing packages from untrusted sources.

Edit /etc/apk/repositories to include only trusted repositories

🧯 If You Can't Patch

  • Run apk-tools with minimal privileges using principle of least privilege
  • Implement strict input validation for any tarball processing in custom applications

🔍 How to Verify

Check if Vulnerable:

Run 'apk --version' and check if version is below 2.12.5

Check Version:

apk --version

Verify Fix Applied:

Run 'apk --version' and confirm version is 2.12.5 or higher

📡 Detection & Monitoring

Log Indicators:

  • Segmentation fault or crash logs from apk-tools processes
  • Unexpected termination of package management operations

Network Indicators:

  • Unusual network traffic to/from package repositories
  • Downloads of unusually large or malformed package files

SIEM Query:

process.name:"apk" AND (event.action:"segmentation_fault" OR event.action:"crash")

🔗 References

📤 Share & Export