NASA CFITSIO `ffghbn` and `ffghtb` Stack Overflow Code Execution Vulnerabilities
Two functions in the CFITSIO library copy a header keyword value from a FITS file into a fixed-size stack buffer using sprintf without bounds checking. A crafted FITS image can overflow that buffer and overwrite stack data, potentially leading to code execution.
Originally disclosed on Cisco Talos
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.
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, and the user-controlled keyword value plus the message prefix can exceed that size.
Impact
An attacker could deliver a crafted FITS image to trigger the overflow and potentially gain code execution, though the text does not demonstrate a working exploit.
What the attacker needed
Victim opens a crafted FITS file; application uses CFITSIO 3.42
The fix
The vulnerable sprintf calls should be replaced with a bounded formatting function such as snprintf; the text states the vendor patched the issue.
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 starts with text labels called header keywords. The library copies one of those labels into a small fixed-size box in memory without checking its length, so a long label spills past the box and overwrites nearby memory. An attacker who can get a victim to open a malicious file could use this to crash the program or possibly 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.