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.
Originally disclosed on Cisco Talos
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.
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
- Create a DXF file containing an LWPOLYLINE entity.
- Set group code 90 to a positive value to allocate a buffer.
- Omit group code 10 so vertexIndex remains -1.
- 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.