CVE-2024-28581 Overview
CVE-2024-28581 is a stack-based buffer overflow [CWE-121] in the open source FreeImage library version 3.19.0 [r1909]. The flaw resides in the _assignPixel<>() template function invoked while parsing images in the Truevision TARGA (TGA) format. A local attacker who supplies a crafted TARGA file can trigger memory corruption and execute arbitrary code in the context of the process using FreeImage.
Critical Impact
Successful exploitation of CVE-2024-28581 permits arbitrary code execution with the privileges of the application processing the malicious TARGA image, compromising confidentiality, integrity, and availability.
Affected Products
- FreeImage 3.19.0 [r1909]
- Applications statically or dynamically linking the affected FreeImage build
- Image processing pipelines that accept untrusted TARGA (.tga) input via FreeImage
Discovery Timeline
- 2024-03-20 - CVE-2024-28581 published to the National Vulnerability Database
- 2026-06-17 - Last updated in the NVD database
Technical Details for CVE-2024-28581
Vulnerability Analysis
FreeImage is a widely used C++ library for decoding and manipulating image formats, including TARGA. The _assignPixel<>() template function copies pixel data from a decoded scanline buffer into a destination pixel structure during TGA decoding. The function relies on caller-supplied dimensions and pixel depth without validating that the source data fits the destination pixel type.
When a TARGA file declares mismatched or oversized pixel-depth and color-map parameters in its header, the decoder writes more bytes than the fixed-size destination pixel buffer can hold. This condition produces a stack-based buffer overflow, corrupting adjacent stack frames including saved return addresses.
Because the overflow occurs during file parsing, exploitation does not require authentication or user interaction beyond opening or processing the crafted image. See the GitHub Vulnerability Report Repository for the reporter's technical write-up.
Root Cause
The root cause is missing bounds enforcement in _assignPixel<>() when reconciling TARGA header fields against the fixed size of the destination pixel structure. FreeImage trusts the pixel-depth and image-descriptor values embedded in the TARGA header and dispatches to a template specialization sized for the expected pixel type.
Attack Vector
Exploitation requires local delivery of a crafted TARGA file to an application that uses FreeImage 3.19.0 for image loading. Typical delivery paths include command-line image conversion utilities, thumbnailers, game engine asset pipelines, and desktop editors. The overflow enables control-flow hijacking through corrupted stack metadata, leading to arbitrary code execution under the victim process's user context.
No public exploit or proof-of-concept exploit code has been released beyond the reporter's advisory. The EPSS model currently rates the probability of exploitation in the wild as low.
Detection Methods for CVE-2024-28581
Indicators of Compromise
- Unexpected process crashes or stack canary violations in applications that invoke FreeImage while loading .tga files.
- Presence of TARGA files with inconsistent header fields, such as mismatched pixel depth and color-map size, on user endpoints or asset shares.
- Child processes spawned by image viewers, converters, or game engines shortly after opening a TARGA file.
Detection Strategies
- Inventory endpoints and build systems for binaries statically linking FreeImage 3.19.0 or shipping FreeImage.dll / libfreeimage.so at that version.
- Enable Address Sanitizer or stack-protector telemetry in development and QA pipelines to surface the overflow during automated image fuzzing.
- Alert on image-parsing processes that transition to shell, script interpreter, or LOLBin execution.
Monitoring Recommendations
- Ingest endpoint process, file, and crash telemetry into a centralized data lake for retrospective hunting across TARGA-handling workloads.
- Monitor software supply chain scanners for dependency reports flagging freeimage_project:freeimage at version 3.19.0.
- Track exception and Windows Error Reporting entries referencing FreeImage modules for repeated faults tied to specific input files.
How to Mitigate CVE-2024-28581
Immediate Actions Required
- Identify all applications and container images embedding FreeImage 3.19.0 [r1909] using software composition analysis.
- Restrict processing of TARGA files from untrusted sources until an upstream fix is available.
- Sandbox image parsing workloads with reduced privileges, seccomp filters, or AppArmor / SELinux policies.
Patch Information
No official upstream patch has been published in the referenced advisory at the time of writing. Track the GitHub Vulnerability Report Repository and the FreeImage project for a corrected release that adds bounds validation inside _assignPixel<>() and the TARGA decoder. Rebuild and redistribute dependent applications once a fixed version is available.
Workarounds
- Disable TARGA support in FreeImage builds by removing the PluginTARGA loader from the plugin registration when the format is not required.
- Pre-validate TARGA headers with a hardened parser before passing files to FreeImage, rejecting files with anomalous pixel depth or color-map fields.
- Run image conversion workloads inside isolated containers or virtual machines with no network egress and least-privilege file system access.
# Configuration example: block TARGA files at an ingest gateway
find /var/uploads -type f \( -iname '*.tga' -o -iname '*.targa' -o -iname '*.icb' -o -iname '*.vda' -o -iname '*.vst' \) -print -delete
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

