Openscad import_stl.cc:import_stl() out-of-bounds stack write vulnerability
An out-of-bounds write in the STL import function of OpenSCAD occurs when a malformed vertex line causes an index to be set to 10, leading to a write beyond the bounds of a stack array. An attacker could exploit this to execute arbitrary code by providing a specially crafted STL file.
Originally disclosed on Cisco Talos
An out-of-bounds write vulnerability exists in the importstl.cc:importstl() functionality of Openscad openscad-2020.12-RC2. A specially crafted STL file can lead to code execution.
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, the code fails to validate the index variable before using it to write into a fixed-size stack array, allowing an out-of-bounds write when a parsing error sets the index to an invalid value.
Impact
This could lead to code execution, as the overwrite can control a pointer in a boost::shared_ptr, allowing arbitrary actions during its destructor.
What the attacker needed
Victim opens a malicious STL file
How it was found
- Create an STL file with a vertex line containing a non-numeric coordinate to trigger a parsing error.
- Include a subsequent valid vertex line to cause the out-of-bounds write.
- Open the file in OpenSCAD using the import command to trigger the vulnerability.
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.
OpenSCAD is a program for creating 3D models. When it reads a file in STL format, it stores vertex coordinates in a small array on the stack. If a line contains an invalid number, the code sets an index to 10, which is outside the array, and the next valid vertex line writes data past the array, corrupting memory. This can allow an attacker to 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.