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

Ribbonsoft dxflib DL_Dxf::handleLWPolylineData heap-based buffer overflow vulnerability

A heap-based buffer overflow exists in dxflib's handling of LWPOLYLINE entities in DXF files. An attacker can provide a malicious DXF file to trigger an out-of-bounds write, potentially leading to code execution.

Lilith >_> Follow

Originally disclosed on Cisco Talos

High 8.8 View original

A code execution vulnerability exists in the DLDxf::handleLWPolylineData functionality of Ribbonsoft dxflib 3.17.0. A specially-crafted .dxf 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

Likely an integer underflow: vertexIndex is initialised to -1 and the check vertexIndex<maxVertices passes for positive maxVertices, allowing a write to vertices[4*(-1)+3].

Impact

Depending on the heap implementation, overwriting this space can very quickly lead to code execution.

What the attacker needed

Victim opens a malicious DXF file

The fix

An update is now available in version 3.26.4.

How it was found

  1. Create a DXF file containing an LWPOLYLINE entity.
  2. Set group code 90 to a positive value to allocate a buffer.
  3. Omit group code 10 so vertexIndex remains -1.
  4. Include group code 42 with a controlled value to trigger 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.

A DXF file is a text-based format used by CAD software to describe drawings. The library dxflib reads these files and, when processing a particular shape called LWPOLYLINE, it can be tricked into writing data outside the memory buffer it allocated. This memory corruption could allow an attacker to run arbitrary code on the victim's computer.

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.