LibreCad libdxfrw dwgCompressor::copyCompBytes21 heap-based buffer overflow vulnerability
A heap-based buffer overflow exists in the dwgCompressor::copyCompBytes21 function of LibreCad libdxfrw when processing a specially crafted .dwg file. An attacker could exploit this to execute arbitrary code by providing a malicious file.
Originally disclosed on Cisco Talos
A code execution vulnerability exists in the dwgCompressor::copyCompBytes21 functionality of LibreCad libdxfrw 2.2.0-rc2-19-ge02f3580. A specially-crafted .dwg file can lead to a heap buffer overflow.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The decompression routine copies data into a fixed-size heap buffer without checking the length of the data being copied, allowing a heap overflow.
Impact
An attacker could execute arbitrary code by convincing a victim to open a malicious .dwg file.
What the attacker needed
Victim opens a malicious .dwg file
The fix
The vulnerability was fixed by the vendor.
How it was found
- Craft a .dwg file with the AC1021 header and a controlled fileHdrCompLength value.
- The file header is read and decoded, setting fileHdrCompLength from the file.
- The compressed header data is decompressed into a fixed 0x110-byte buffer.
- During decompression, a length larger than the buffer is used in copyCompBytes21, causing a heap overflow.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This report describes a memory corruption bug in a library that reads CAD files. When the program opens a malicious file, it writes more data into a small memory buffer than it can hold, which can crash the program or let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.