CVE-2021-3402

9.1 CRITICAL

📋 TL;DR

CVE-2021-3402 is an integer overflow and buffer overflow vulnerability in YARA's Mach-O file parser that allows attackers to cause denial of service or information disclosure by processing malicious Mach-O files. This affects all systems running YARA versions before 4.0.4. Security tools and systems using YARA for file analysis are particularly vulnerable.

💻 Affected Systems

Products:
  • YARA
  • Security tools using YARA library
Versions: All versions before libyara 4.0.4
Operating Systems: All platforms running vulnerable YARA versions
Default Config Vulnerable: ⚠️ Yes
Notes: Any system using YARA to scan Mach-O files is vulnerable. This includes security tools, malware analysis systems, and file scanning services.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution leading to complete system compromise if combined with other vulnerabilities, though CWE-190 typically results in crashes or information leaks.

🟠

Likely Case

Denial of service through application crashes or information disclosure via memory leaks when processing malicious Mach-O files.

🟢

If Mitigated

Limited impact with proper input validation and sandboxing, though crashes may still occur.

🌐 Internet-Facing: MEDIUM - Only affects systems that process untrusted Mach-O files from external sources.
🏢 Internal Only: LOW - Requires processing of malicious Mach-O files, which is less common in internal-only environments.

🎯 Exploit Status

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

Exploitation requires providing a malicious Mach-O file to YARA for processing. Public proof-of-concept exists in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: libyara 4.0.4 and later

Vendor Advisory: https://www.x41-dsec.de/lab/advisories/x41-2021-001-yara/

Restart Required: Yes

Instructions:

1. Update YARA to version 4.0.4 or later. 2. For Linux systems: Use package manager (apt-get update && apt-get upgrade yara, yum update yara, etc.). 3. For source installations: Download and compile from https://github.com/VirusTotal/yara/releases. 4. Restart any services using YARA.

🔧 Temporary Workarounds

Disable Mach-O module

all

Disable YARA's Mach-O module to prevent processing of Mach-O files

yara --disable-module=macho

Sandbox YARA processing

linux

Run YARA in a container or sandbox with limited privileges

docker run --read-only --cap-drop=ALL -v /scans:/scans:ro yara:latest

🧯 If You Can't Patch

  • Implement strict input validation to reject suspicious Mach-O files before YARA processing
  • Isolate YARA processing to dedicated systems with no sensitive data access

🔍 How to Verify

Check if Vulnerable:

Check YARA version: yara --version. If output shows version earlier than 4.0.4, system is vulnerable.

Check Version:

yara --version

Verify Fix Applied:

Run yara --version and confirm version is 4.0.4 or later. Test with known safe Mach-O files to ensure functionality.

📡 Detection & Monitoring

Log Indicators:

  • YARA process crashes or segmentation faults
  • Unusual memory consumption patterns in YARA processes
  • Repeated failed Mach-O file parsing attempts

Network Indicators:

  • Unusual Mach-O file downloads to systems running YARA
  • Network traffic to/from YARA processing systems with Mach-O files

SIEM Query:

process_name:"yara" AND (event_type:"crash" OR memory_usage:>threshold)

🔗 References

📤 Share & Export