Skip to content
Memory corruption Advisory Advanced CVE-2021-21899

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.

Lilith >_> Follow

Originally disclosed on Cisco Talos

High 8.8 View original

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.

Lilith >_>, on Cisco Talos

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

  1. Craft a .dwg file with the AC1021 header and a controlled fileHdrCompLength value.
  2. The file header is read and decoded, setting fileHdrCompLength from the file.
  3. The compressed header data is decompressed into a fixed 0x110-byte buffer.
  4. 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.

More by Lilith >_>

View all

148 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.