Gerbv RS-274X aperture macro outline primitive integer overflow vulnerability
An integer overflow in Gerbv's handling of the RS-274X aperture macro outline primitive allows a crafted Gerber file to cause a heap buffer overflow, potentially leading to code execution. An attacker can provide a malicious file to trigger this vulnerability.
Originally disclosed on Cisco Talos
An integer overflow vulnerability exists in the RS-274X aperture macro outline primitive functionality of Gerbv 2.7.0 and dev (commit b5f1eacd) and the forked version of Gerbv (commit 71493260). 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
Root cause
Likely an integer overflow in the calculation of the number of parameters for an outline primitive, which bypasses a size check and leads to an out-of-bounds memcpy.
Impact
A crafted file could cause a heap buffer overflow, potentially leading to code execution.
What the attacker needed
Ability to supply a crafted Gerber file
The fix
The vendor patched the vulnerability.
How it was found
- Create a Gerber file that is recognised as RS-274X (contains required markers and only printable characters).
- Define an aperture macro with an outline primitive (code 4) and a large number of vertices.
- Use an AD command to instantiate the macro, causing the virtual machine to execute the primitive.
- The integer overflow in nuf_parameters calculation bypasses the size check and leads to an out-of-bounds memcpy.
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 circuit boards. A specially made file can cause the program to write more data than it has space for, 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.