Skip to content
Memory corruption Advisory Advanced CVE-2018-3847

NASA CFITSIO `ffgkyn` Stack Overflow Code Execution Vulnerability

The ffgkyn function in CFITSIO 3.42 copies a keyword name from a FITS image into a fixed 81-byte stack buffer using sprintf together with a longer error message, so a crafted image with an illegal keyword character overflows the buffer. An attacker could deliver such an image to overwrite stack data and potentially gain code execution.

Tyler Bohan Follow

Originally disclosed on Cisco Talos

High 8.8 View original

Multiple exploitable buffer overflow vulnerabilities exist in image parsing functionality of the CFITSIO library version 3.42. Specially crafted images parsed via the library, can cause a stack-based buffer overflow overwriting arbitrary data.

Tyler Bohan, 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 code uses sprintf to build an error message into an 81-byte stack buffer without bounds checking, and the message plus a 72-byte keyword can exceed that size.

Impact

A crafted FITS image could cause a stack-based buffer overflow and potentially lead to code execution.

What the attacker needed

Victim opens a crafted FITS image; library version 3.42

The fix

The vendor patched the issue; the text does not describe the exact change, but the safe approach is to use a bounded formatting function such as snprintf.

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.

A FITS file is a scientific image format that stores data in fixed-size records. The library reads a keyword from the file and, when it finds a bad character, builds an error message in a small fixed-size space on the stack without checking the length. Because the message plus the keyword can be longer than that space, the extra bytes spill over and can overwrite nearby memory, which may 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.

More by Tyler Bohan

View all

84 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.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.