Gerbv RS-274X aperture definition tokenization use-after-free vulnerability
A use-after-free exists in Gerbv's RS-274X aperture definition parsing because the return value of gerb_fgetstring is not checked before being passed to strtok. An attacker could supply a crafted Gerber file to corrupt heap memory and potentially execute code.
Originally disclosed on Cisco Talos
A use-after-free vulnerability exists in the RS-274X aperture definition tokenization functionality of Gerbv 2.7.0 and dev (commit b5f1eacd) and Gerbv forked 2.7.1. A specially-crafted gerber file can lead to 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
Impact
This could allow an attacker to leak heap memory and, with careful heap manipulation, potentially execute arbitrary code.
What the attacker needed
Attacker supplies a crafted Gerber file; target uses Gerbv to process the file
How it was found
- Create a Gerber file that is recognised as RS-274X and contains an aperture definition with a comma.
- Add a second aperture definition line that has no terminating asterisk before the end of the file.
- Open the file with Gerbv using the export switch, which triggers the second strtok call on the freed 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.
Gerbv is a program that reads files describing printed circuit boards. A bug in how it reads one part of those files means a malicious file can make the program use memory it has already given back, which can crash it or 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.