GTKWave FST fstReaderIterBlocks2 VCDATA parsing heap-based buffer overflow vulnerabilities
GTKWave's FST file parser has multiple heap-based buffer overflows in the VCDATA parsing function because it does not check that decompressed or copied data fits within the allocated buffer. An attacker can craft a malicious .fst file that, when opened, may lead to arbitrary code execution.
Originally disclosed on Cisco Talos
Multiple heap-based buffer overflow vulnerabilities exist in the fstReaderIterBlocks2 VCDATA parsing 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 code fails to verify that the decompressed or copied length (destlen) fits within the remaining space of the destination buffer (mem_for_traversal), which is sized independently from the file-controlled length.
Impact
A victim opening a malicious .fst file could have arbitrary code executed on their system, though the CVSS vector indicates user interaction is required.
What the attacker needed
Victim opens a malicious .fst file
The fix
The vulnerabilities were fixed in version 3.3.118 by adding bounds checks to ensure decompressed or copied data does not exceed the destination buffer.
How it was found
- Craft an FST file starting with a header block (sectype 0x00) that sets hdr_seen to 1 and keeps hdr_incomplete at 0.
- Include a VCDATA block (sectype FST_BL_VCDATA, FST_BL_VCDATA_DYN_ALIAS, or FST_BL_VCDATA_DYN_ALIAS2) with a small mem_required_for_traversal value to allocate a small destination buffer.
- Manipulate the chain section to define offsets and lengths for VC elements, ensuring the compressed or uncompressed data length exceeds the allocated buffer size.
- Open the crafted .fst file in GTKWave or with a command-line tool such as fst2vcd 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.
GTKWave is a program for viewing signal traces from electronic simulations. It reads files in a format called FST. The program reserves a small memory area for unpacking data from the file but does not check whether the unpacked data is larger than that area. If a malicious file contains data that expands too much, it can overwrite other memory and potentially let 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.