Cloudanix VulnDB

CVE-2021-40265

High · 8.8

CVSS

8.8

EPSS

0.9%

Published

Aug 22, 2023

CISA due date

—

Cloudanix analysis

Monitor only SSVC: Track

A flaw in a common picture-handling component can let attackers take control of programs that open images if someone opens a specially made file.

Exploit Available
Exploitation
Requires User Interaction
Attacker needs
User Interaction
Complexity
Low
Impact
Full Compromise
Component
Library
Class
Memory Corruption
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

Heap-based buffer overflow in the JPEG loading path that corrupts memory structures and can lead to arbitrary code execution or denial of service.

Why it matters to the business

Systems that process untrusted images with this library face elevated risk of remote compromise or service disruption; the library's wide reuse in applications increases overall exposure.

How an attack unfolds

An attacker supplies a specially crafted JPEG image to any application that invokes the vulnerable ofLoad function; the malformed data triggers the heap overflow, allowing the attacker to overwrite memory and execute arbitrary code. Public exploits are available and the flaw has existed for years.

How to fix it

Upgrade FreeImage to version 1.18.0 or later in all affected products and rebuild dependent applications against the fixed library.

How to confirm the fix worked

Confirm the installed FreeImage version is 1.18.0 or newer; recompile and test applications with the updated library; attempt to load known trigger images in a controlled environment to verify the overflow is no longer reachable.

Typical attack path

  1. Identify or reach an application that uses FreeImage to load JPEG files
  2. Deliver a malicious JPEG via file upload, email attachment, or web request
  3. Trigger image loading through the PluginJPEG.cpp ofLoad path
  4. Exploit the resulting heap overflow to achieve code execution or crash the process

How to detect it

Review application and system logs for unexpected crashes or heap-related errors during JPEG processing; search process memory dumps or crash reports for signs of corruption originating from image-loading code paths.

What your security team should do

  • Inventory all software that links against FreeImage and prioritize upgrades
  • Apply the 1.18.0 release immediately where the library is present
  • Add runtime image-size and format validation in front of the library until upgrades are complete
  • Monitor for new public exploits and update detection rules accordingly

The record

A heap overflow bug exists FreeImage before 1.18.0 via ofLoad function in PluginJPEG.cpp.

Affected packages

Ecosystem Package Introduced Fixed
Debian:11 freeimage 0 No fix
Debian:12 freeimage 0 No fix
Debian:13 freeimage 0 No fix
Ubuntu:20.04:LTS freeimage 0 No fix
Ubuntu:22.04:LTS freeimage 0 No fix
Ubuntu:24.04:LTS freeimage 0 No fix
Ubuntu:24.10 freeimage 0 No fix
Ubuntu:25.04 freeimage 0 No fix
Ubuntu:25.10 freeimage 0 No fix
Ubuntu:Pro:14.04:LTS freeimage 0 No fix
Ubuntu:Pro:16.04:LTS freeimage 0 No fix
Ubuntu:Pro:18.04:LTS freeimage 0 No fix
Ubuntu:Pro:20.04:LTS freeimage 0 No fix

Related vulnerabilities