libigl readOFF stack-based buffer overflow vulnerability
Multiple stack-based buffer overflows exist in libigl's readOFF function because it uses fscanf to read strings into fixed-size 1000-byte buffers without bounds checking. An attacker can provide a malicious .off file to trigger a stack buffer overflow, potentially leading to code execution.
Originally disclosed on Cisco Talos
Multiple stack-based buffer overflow vulnerabilities exist in the readOFF functionality of libigl v2.5.0. A specially crafted .off file can lead to stack-based 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
The code uses fscanf with %s or %[^\n] to read unbounded input into fixed-size stack buffers of 1000 bytes, without limiting the number of characters read.
Impact
A crafted .off file could cause a stack-based buffer overflow, potentially leading to code execution or a crash.
What the attacker needed
Victim opens a malicious .off file
How it was found
- Create a .off file with a header line longer than 1000 bytes.
- Open the file with libigl's readOFF function.
- The fscanf call reads the long header into the 1000-byte header buffer, causing a stack overflow.
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 stack-based buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, overwriting nearby data. In this case, libigl reads text from a .off file into small buffers without checking length, so a very long line can corrupt memory. An attacker could use this to crash the program or possibly 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.