CVE-2021-21898
📋 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
- LibreCAD
- libdxfrw
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Libdxfrw by Librecad
⚠️ 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.
🎯 Exploit Status
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
allBlock or restrict opening of DWG files from untrusted sources
Application Sandboxing
linuxRun 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
- https://lists.debian.org/debian-lts-announce/2021/12/msg00002.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/RDI3HCTCACMIC7I4ILB3NRU6DCMADI5H/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZTIAMP7QJDKV4ADDLR4GVVX2TXYLHVOZ/
- https://security.gentoo.org/glsa/202305-26
- https://talosintelligence.com/vulnerability_reports/TALOS-2021-1349
- https://www.debian.org/security/2022/dsa-5077
- https://lists.debian.org/debian-lts-announce/2021/12/msg00002.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/RDI3HCTCACMIC7I4ILB3NRU6DCMADI5H/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZTIAMP7QJDKV4ADDLR4GVVX2TXYLHVOZ/
- https://security.gentoo.org/glsa/202305-26
- https://talosintelligence.com/vulnerability_reports/TALOS-2021-1349
- https://www.debian.org/security/2022/dsa-5077