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.
Originally disclosed on Cisco Talos
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.
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
- Craft a .dwg file with a SysPage at the offset specified in the file header.
- Set the compressed size and decompressed size fields to controlled values.
- Provide compressed data that causes litLength18() to return a large literal length.
- 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.