GTKWave VCD sorted bsearch arbitrary write vulnerabilities
GTKWave's VCD parser fails to check whether the sorted symbol table is initialised before calling bsearch, allowing a crafted .vcd file to cause an out-of-bounds read that can be turned into an arbitrary write. An attacker could achieve arbitrary code execution by convincing a victim to open a malicious file.
Originally disclosed on Cisco Talos
Multiple arbitrary write vulnerabilities exist in the VCD sorted bsearch 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 calls bsearch on the sorted array without checking that it was initialised, because the indexed hash table path was taken instead.
Impact
A crafted .vcd file could lead to arbitrary code execution, though the report notes that controlling the required memory may be easier in 32-bit mode.
What the attacker needed
Victim opens a malicious .vcd file; use of a vulnerable GTKWave version
The fix
The issue was fixed in version 3.3.118 by adding a check that the sorted buffer is initialised before calling bsearch.
How it was found
- Create a .vcd file with many $var declarations that all share the same identifier.
- Include a port dump line that references a different identifier.
- Open the file with a vulnerable GTKWave conversion utility.
- The parser calls bsearch on an uninitialised sorted array, causing an out-of-bounds read.
- If the attacker controls the memory at the computed address, an arbitrary vcdsymbol is returned.
- The subsequent value-change parsing writes attacker-controlled data to an arbitrary address.
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 bug in how it reads a particular file format lets a malicious file trick the program into reading and writing memory it shouldn't, which can let an attacker run their own code on the victim's computer. The victim just has to open the 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.