GTKWave VCD parse_valuechange portdump out-of-bounds write vulnerabilities
GTKWave's VCD parser has an off-by-one heap buffer overflow when handling port dump values, allowing a crafted .vcd file to write a null byte out of bounds. An attacker could exploit this to execute arbitrary code when a victim opens the malicious file.
Originally disclosed on Cisco Talos
Multiple out-of-bounds write vulnerabilities exist in the VCD parsevaluechange portdump functionality of GTKWave 3.3.115. A specially crafted .vcd 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 checks if the buffer size is less than the required size, but it should check if it is less than or equal to, because the string copy also writes a null terminator.
Impact
A crafted .vcd file could lead to arbitrary code execution, though the report notes that heap massaging is required and the write is only a single null byte.
What the attacker needed
Victim opens a malicious .vcd file; GTKWave version 3.3.115 or similar
The fix
The buffer size check should be changed to use less-than-or-equal, and the vendor fixed the issue in version 3.3.118.
How it was found
- Create a VCD file with a $var declaration for a port with a specific size.
- Include a $enddefinitions token to mark the end of the header.
- Add a value change line starting with 'p' followed by a port value and an identifier that matches the declared port.
- Open the file with GTKWave or a conversion utility 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. A specially crafted trace file can cause the program to write one byte past the end of a memory buffer, which can crash it or, with extra work, let an attacker run their own code. The victim just needs to open the malicious file.
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.