GTKWave LXT2 zlib block decompression out-of-bounds write vulnerability
A heap out-of-bounds write exists in GTKWave's LXT2 file parsing because the destination buffer size is taken from one file field while the decompressed length is taken from another, allowing a crafted file to overflow the buffer. An attacker could achieve arbitrary code execution by convincing a victim to open a malicious .lxt2 file.
Originally disclosed on Cisco Talos
An out-of-bounds write vulnerability exists in the LXT2 zlib block decompression functionality 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
Likely the code allocates the destination buffer using the file-controlled b->uncompressed_siz field but sets the zlib output length from a different file-controlled unclen field without verifying they are equal, so decompression can write beyond the allocated buffer.
Impact
A crafted .lxt2 file could cause heap corruption and potentially arbitrary code execution when opened by a victim.
What the attacker needed
Victim opens a malicious .lxt2 file
The fix
The vulnerability was fixed in version 3.3.118.
How it was found
- Craft an LXT2 file with a block header where uncompressed_siz is small (e.g. 1) and the compressed data decompresses to a larger unclen value.
- Open the crafted file in GTKWave or a tool that parses LXT2 files.
- The parser allocates a small buffer based on uncompressed_siz and then decompresses the block into it, causing an 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. When it opens a trace file, it reads a size value from the file and uses that to reserve memory for decompressed data, but it never checks that this size matches the actual amount of data that will be decompressed. A malicious file can claim a tiny size but contain a large compressed block, so the decompression writes past the end of the reserved memory and can corrupt the program, potentially letting 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.