Skip to content
Info disclosure Advisory Intermediate CVE-2021-40403

Gerbv pick-and-place rotation parsing use of uninitialized variable vulnerability

The pick-and-place file parser in Gerbv does not initialise a structure field for rotation, so a crafted file with a non-numeric rotation value leaves it uninitialised. An attacker could potentially leak limited memory contents by analysing the rotation of objects in the rendered image.

Claudio Bozzato Follow

Originally disclosed on Cisco Talos

Medium 5.8 View original

An information disclosure vulnerability exists in the pick-and-place rotation parsing functionality of Gerbv 2.7.0 and dev (commit b5f1eacd), and Gerbv forked 2.8.0. A specially-crafted pick-and-place file can exploit the missing initialization of a structure to leak memory contents.

Claudio Bozzato, on Cisco Talos

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 PnpPartData structure is not initialised, and the sscanf call that reads the rotation may fail without writing to the field, leaving it with an uninitialised stack value.

What the attacker needed

Ability to supply a crafted pick-and-place file; ability to view the rendered image

The fix

The structure should be initialised before use, for example by zeroing it or explicitly setting the rotation field to a default value.

How it was found

  1. Create a file that passes the pick-and-place file type check (printable characters, contains a comma, a reference designator like R1, and a board side indicator like 'top').
  2. Ensure the file has at least two lines, with the first line being a header that is skipped.
  3. In the second line, provide a rotation field that is empty or non-numeric so that sscanf fails to parse it.
  4. Open the file with Gerbv using the export option to render an image.
  5. Analyse the rendered image to observe the rotation of objects, which may reveal uninitialised memory contents.

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.

When a program reads a file, it sometimes stores values in a temporary structure. If a value is not set, it may contain leftover data from previous operations. Here, the rotation value is not set when the file has a non-numeric rotation, so the program uses whatever was in memory, which could leak information if the output image is visible.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More by Claudio Bozzato

View all

185 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.