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

LibreCad libdxfrw dwgCompressor::decompress18() out-of-bounds write vulnerability

A heap out-of-bounds write exists in the dwgCompressor::decompress18() function of LibreCad libdxfrw when processing a specially crafted .dwg file. An attacker could exploit this to achieve code execution 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::decompress18() functionality of LibreCad libdxfrw 2.2.0-rc2-19-ge02f3580. A specially-crafted .dwg file can lead to an out-of-bounds write.

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 function uses a literal length read from the file without validating it against the destination buffer size, leading to a heap out-of-bounds write.

Impact

An attacker could achieve code execution by convincing a user 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, as indicated in the timeline.

How it was found

  1. Craft a .dwg file with a SysPage at the offset specified in the file header.
  2. Set the compressed size and decompressed size fields to controlled values.
  3. Provide compressed data that causes litLength18() to return a large literal length.
  4. Open the file in LibreCad, triggering decompress18() and the out-of-bounds write.

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 .dwg file, it writes data past the end of a buffer, which can crash the program or let an attacker run their own code. The flaw is that the program trusts a length value from the file without checking it against the buffer size.

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.