GTKWave FST fstReaderIterBlocks2 temp_signal_value_buf allocation integer overflow vulnerability
An integer overflow in GTKWave's handling of the .fst file format's signal length values causes a tiny heap buffer to be allocated, which is then written past its end. A crafted .fst file opened by the victim could lead to arbitrary code execution.
Originally disclosed on Cisco Talos
An integer overflow vulnerability exists in the fstReaderIterBlocks2 tempsignalvaluebuf allocation 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 signal length read from the .hier section is used without validation, so a value of 0xffffffff makes the addition of one wrap to zero and malloc reserves a tiny buffer that later receives out-of-bounds writes.
Impact
Because both the length and the written data are attacker-controlled, the out-of-bounds heap write could lead to arbitrary code execution when the victim opens the file.
What the attacker needed
Victim opens a malicious .fst file; file opened via fst2vcd or GUI
The fix
It was fixed in version 3.3.118.
How it was found
- Craft an .fst file whose header section has a non-zero start or end time so the header is not marked incomplete.
- Include a .hier section declaring one signal with a large length and another with length 0xffffffff.
- Open the file with fst2vcd so the .hier section overwrites the signal lengths and triggers the tiny allocation.
- The VCDATA block for the large-length signal is then written past the end of the small buffer.
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 electronics simulations. It reads a file format where each signal declares its length, and it uses that length to size a scratch buffer. If a file declares a length of the largest possible number, adding one wraps around to zero, so almost no memory is reserved, yet the program later writes a long signal value into it, corrupting memory.
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.