GTKWave FST LEB128 varint stack-based buffer overflow vulnerabilities
Three stack-based buffer overflow vulnerabilities exist in GTKWave's FST LEB128 varint parsing functions because the loops that read bytes from a file have no bound on the number of bytes written to fixed-size stack buffers. An attacker could craft a malicious .fst file that, when opened by a victim, leads to arbitrary code execution.
Originally disclosed on Cisco Talos
Multiple stack-based buffer overflow vulnerabilities exist in the FST LEB128 varint functionality of GTKWave 3.3.115. A specially crafted .fst file can lead to arbitrary 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
The varint decoding functions use a do-while loop that writes each byte read from the file into a fixed-size stack buffer without checking the buffer's length, so a long sequence of bytes with the high bit set causes a stack buffer overflow.
Impact
A specially crafted .fst file could lead to arbitrary code execution when opened by a victim.
What the attacker needed
Victim opens a malicious .fst file
The fix
The vulnerabilities were fixed in GTKWave version 3.3.118.
How it was found
- Create a .fst file that starts with a header sector (0x00) and sets start_time or end_time to a non-zero value so hdr_incomplete stays 0.
- Include a blackout section (0x02) or a VCDATA section whose varint field contains a long sequence of bytes with the high bit set.
- Open the crafted .fst file in GTKWave (for example by double-clicking it) to trigger the 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.
GTKWave is a program for viewing signal traces from electronic simulations. It reads files in a format called FST, and when it reads numbers from those files it uses a small fixed-size space on the stack (a temporary memory area). Because it keeps writing bytes into that space without checking how many it has written, a malicious file can overflow the space and overwrite other memory, potentially letting an attacker 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.