CVE-2021-20294

7.8 HIGH

📋 TL;DR

A stack buffer overflow vulnerability in binutils readelf 2.35 allows attackers to execute arbitrary code by tricking users into processing malicious files. This affects systems where readelf is used to analyze untrusted binary files. The vulnerability impacts confidentiality, integrity, and availability through potential remote code execution.

💻 Affected Systems

Products:
  • binutils
  • readelf
Versions: binutils 2.35 and potentially earlier versions
Operating Systems: Linux, Unix-like systems
Default Config Vulnerable: ⚠️ Yes
Notes: Any system with vulnerable binutils package where readelf processes untrusted files is affected. Common in development environments and security toolchains.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution with the privileges of the user running readelf, potentially leading to full system compromise if run with elevated privileges.

🟠

Likely Case

Local privilege escalation or denial of service when processing crafted files from untrusted sources.

🟢

If Mitigated

Limited impact if readelf is not used on untrusted files or runs with minimal privileges.

🌐 Internet-Facing: LOW - readelf is typically not exposed directly to internet-facing services.
🏢 Internal Only: MEDIUM - risk exists when users process untrusted binary files internally, especially in development or security analysis workflows.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires user interaction to process malicious files. Public proof-of-concept exists in bug reports.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: binutils 2.36 or later

Vendor Advisory: https://sourceware.org/bugzilla/show_bug.cgi?id=26929

Restart Required: No

Instructions:

1. Update binutils package using system package manager. 2. For Linux: 'sudo apt update && sudo apt upgrade binutils' (Debian/Ubuntu) or 'sudo yum update binutils' (RHEL/CentOS). 3. Verify update with 'readelf --version'.

🔧 Temporary Workarounds

Restrict readelf usage

linux

Limit readelf execution to trusted users and environments

chmod 750 /usr/bin/readelf
setfacl -m u:trusteduser:rx /usr/bin/readelf

Sandbox execution

linux

Run readelf in restricted environments when processing untrusted files

firejail --net=none readelf [file]
bubblewrap --ro-bind / / --dev /dev --proc /proc readelf [file]

🧯 If You Can't Patch

  • Implement strict file validation policies - only allow readelf on verified, trusted files
  • Run readelf with minimal privileges using SELinux/AppArmor or unprivileged user accounts

🔍 How to Verify

Check if Vulnerable:

Check binutils version: 'readelf --version | head -1' and compare to vulnerable version 2.35

Check Version:

readelf --version | head -1

Verify Fix Applied:

Verify updated version: 'readelf --version | head -1' should show 2.36 or later

📡 Detection & Monitoring

Log Indicators:

  • Abnormal process crashes of readelf
  • Unexpected file processing by readelf in audit logs

Network Indicators:

  • Unusual file downloads followed by readelf execution

SIEM Query:

process.name='readelf' AND (event.action='crashed' OR file.path CONTAINS '.tmp' OR file.path CONTAINS 'download')

🔗 References

📤 Share & Export