CVE-2021-21898

8.8 HIGH

📋 TL;DR

This vulnerability allows remote code execution through a specially crafted DWG file in LibreCAD's libdxfrw library. Attackers can exploit an out-of-bounds write in the decompression function to execute arbitrary code. Users who open malicious DWG files with affected LibreCAD versions are at risk.

💻 Affected Systems

Products:
  • LibreCAD
  • libdxfrw
Versions: libdxfrw 2.2.0-rc2-19-ge02f3580 and earlier
Operating Systems: Linux, Windows, macOS
Default Config Vulnerable: ⚠️ Yes
Notes: Any application using the vulnerable libdxfrw library to process DWG files is affected. The vulnerability is triggered when opening malicious DWG files.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise with attacker gaining full control of the victim's machine, potentially leading to data theft, ransomware deployment, or lateral movement within the network.

🟠

Likely Case

Local privilege escalation or arbitrary code execution in the context of the user opening the malicious file, potentially leading to data exfiltration or malware installation.

🟢

If Mitigated

Application crash or denial of service if exploit fails or is blocked by security controls.

🌐 Internet-Facing: MEDIUM
🏢 Internal Only: HIGH

🎯 Exploit Status

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

Exploitation requires user interaction to open a malicious file. The vulnerability is well-documented with public proof-of-concept available.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: libdxfrw versions after 2.2.0-rc2-19-ge02f3580

Vendor Advisory: https://security.gentoo.org/glsa/202305-26

Restart Required: No

Instructions:

1. Update LibreCAD to the latest version from official repositories. 2. For Linux distributions, use package manager: 'sudo apt update && sudo apt upgrade librecad' (Debian/Ubuntu) or 'sudo yum update librecad' (RHEL/Fedora). 3. For Windows/macOS, download latest version from LibreCAD website.

🔧 Temporary Workarounds

File Type Restriction

all

Block or restrict opening of DWG files from untrusted sources

Application Sandboxing

linux

Run LibreCAD in a sandboxed environment to limit potential damage

firejail librecad
bwrap --unshare-all --share-net librecad

🧯 If You Can't Patch

  • Implement application whitelisting to prevent execution of unauthorized binaries
  • Use network segmentation to isolate systems running vulnerable versions

🔍 How to Verify

Check if Vulnerable:

Check libdxfrw version: 'ldconfig -p | grep libdxfrw' or check LibreCAD about dialog for version information

Check Version:

librecad --version 2>/dev/null || echo "Check About dialog in GUI"

Verify Fix Applied:

Verify updated version: 'librecad --version' should show version newer than affected range

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with segmentation faults
  • Unexpected child processes spawned from LibreCAD

Network Indicators:

  • Unusual outbound connections from LibreCAD process
  • DNS requests to suspicious domains

SIEM Query:

process_name:"librecad" AND (event_type:"crash" OR parent_process_name!="explorer.exe")

🔗 References

📤 Share & Export