CVE-2021-36159

9.1 CRITICAL

📋 TL;DR

CVE-2021-36159 is an out-of-bounds read vulnerability in libfetch's FTP passive mode implementation that occurs when parsing numeric strings. This vulnerability affects systems using libfetch (such as apk-tools, xbps, and other products) and could allow attackers to read sensitive memory contents. The issue stems from improper boundary checking when using strtol to parse address bytes.

💻 Affected Systems

Products:
  • apk-tools
  • xbps
  • other products using libfetch
Versions: libfetch versions before 2021-07-26
Operating Systems: Alpine Linux, FreeBSD, other systems using affected packages
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerable when using FTP or HTTP protocols through libfetch library.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution or sensitive information disclosure through memory read operations, potentially leading to full system compromise.

🟠

Likely Case

Information disclosure through memory reads, potentially exposing sensitive data like credentials or cryptographic keys.

🟢

If Mitigated

Limited impact with proper network segmentation and minimal exposure of affected services.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires network access to FTP/HTTP services using vulnerable libfetch implementation.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: libfetch 2021-07-26 or later

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

Restart Required: Yes

Instructions:

1. Update libfetch to version 2021-07-26 or later. 2. Update dependent packages (apk-tools, xbps). 3. Restart affected services.

🔧 Temporary Workarounds

Disable FTP passive mode

all

Configure FTP clients to not use passive mode where possible

Network segmentation

all

Restrict network access to affected services

🧯 If You Can't Patch

  • Implement strict network access controls to limit exposure
  • Monitor for unusual FTP/HTTP traffic patterns and memory access attempts

🔍 How to Verify

Check if Vulnerable:

Check libfetch version: grep -r 'libfetch' /etc/apk/world or check package manager for libfetch version

Check Version:

apk info -a libfetch | grep version

Verify Fix Applied:

Verify libfetch version is 2021-07-26 or later: apk version libfetch or equivalent package manager command

📡 Detection & Monitoring

Log Indicators:

  • Unusual FTP passive mode connection attempts
  • Memory access errors in system logs

Network Indicators:

  • Suspicious FTP PORT/PASV command sequences
  • Unexpected outbound connections from affected services

SIEM Query:

source="*ftp*" AND ("PASV" OR "PORT") AND dest_ip="[internal_ip]"

🔗 References

📤 Share & Export