GTKWave LXT2 lxt2_rd_expand_integer_to_bits stack-based buffer overflow vulnerability
A stack-based buffer overflow in GTKWave's LXT2 file parser allows an attacker to overwrite the stack by crafting a malicious .lxt2 file with large msb/lsb values, leading to arbitrary code execution when the victim opens the file.
Originally disclosed on Cisco Talos
A stack-based buffer overflow vulnerability exists in the LXT2 lxt2rdexpandintegertobits function of GTKWave 3.3.115. A specially crafted .lxt2 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 function lxt2_rd_expand_integer_to_bits copies a variable-length bit string into a fixed-size 33-byte stack buffer without checking the length, and the length is derived from attacker-controlled msb and lsb values in the file.
Impact
This issue can be exploited to overwrite the stack arbitrarily, leading to arbitrary code execution.
What the attacker needed
Victim opens a malicious .lxt2 file
The fix
Fixed in version 3.3.118.
How it was found
- Craft an LXT2 file with msb and lsb values that produce a length larger than 33.
- Open the file with GTKWave or its command-line tools.
- The parser calls lxt2_rd_expand_integer_to_bits with the oversized length, overflowing the stack 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 electronic simulations. A bug in how it reads a certain file format lets an attacker write past the end of a small memory buffer on the stack, which can crash the program or let the attacker run their own code. The victim just has to open a 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.