Skip to main content

CImg Library CVE-2026-42146

| EUVDEUVD-2026-27077 MEDIUM
Memory Allocation with Excessive Size Value (CWE-789)
2026-05-04 security-advisories@github.com
5.5
CVSS 3.1 · Vendor: github
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Create malicious BMP file
  2. Delivery
    Deliver file to target (upload, email, USB)
  3. Exploit
    Victim opens file with CImg application
  4. Install
    CImg reads unchecked nb_colors field
  5. C2
    Allocates excessive memory
  6. Execute
    System runs out of memory
  7. Impact
    Application crashes
  8. Step 8
    Denial of service achieved

Vulnerability Assessment

Weakness
CWE
ASVS 5.0
V15 - Secure Coding and Architecture Memory allocation limits
Exploitation Conditions

The vulnerability requires three specific conditions: (1) The target application must use CImg Library (statically linked or header-only) from a version prior to 3.7.5 to load BMP files; (2) The BMP file must have a crafted nb_colors field value that exceeds the valid range (greater than 2^bpp for bpp < 16, or any large value causing memory exhaustion); (3) A user or automated process must attempt to open or process the malicious BMP file. The vulnerability does NOT trigger on default, valid BMP files. It is NOT exploitable remotely unless the application exposes BMP loading over a network interface (e.g., an image upload web service), in which case remote attackers could craft and submit malicious files. Local exploitation requires file system or application access to provide the malicious BMP.

Impact

This is a localized denial-of-service vector with moderate real-world risk despite the 5.5 CVSS score. The attack vector is local (AV:L) and requires user interaction (UI:R) - the victim must open a crafted BMP file - which significantly limits automated exploitation. However, the availability impact is high (A:H), guaranteeing application crash. The CVSS score appropriately reflects this: higher than typical DoS (due to guaranteed impact) but lower than remote or privileged exploits. The lack of confidentiality or integrity impact (C:N/I:N) further confirms pure availability damage. Real-world risk depends on deployment context: applications that automatically process untrusted BMP files from user uploads, email attachments, or web sources face genuine risk; air-gapped or controlled-input environments face minimal risk. No active exploitation signals (no KEV, no POC identified) suggest this remains a low-priority issue for most organizations, but should be addressed during normal patch cycles, especially for software that processes user-supplied images.

Exploit ScenarioDerived

An attacker creates a malicious BMP file with an oversized nb_colors field in the header (e.g., 0xFFFFFFFF) while keeping the file size small. When a user or automated process opens this file in an application using CImg for image loading, CImg attempts to allocate gigabytes of memory based on the unchecked header value, exhausting system memory and crashing the application. This is particularly effective against web applications or services that process user-uploaded images without pre-validation.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
No patch listed yet 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 04, 2026

Denial of service in CImg Library prior to version 3.7.5 allows local attackers to crash applications via crafted BMP files with oversized nb_colors header fields. The vulnerability stems from unchecked allocation of memory based on user-supplied file header data, causing out-of-memory conditions when loading untrusted BMP files. No authentication or network access required; user interaction (file opening) is the sole prerequisite.

RemediationAI

Upgrade to CImg Library version 3.7.5 or later, which includes the fix from commit c3aacf5b96ac1e54b7af1957c6737dbf3949f6d3. For applications embedding CImg.h as a header-only library, update the CImg.h file from the CImg GitHub repository (https://github.com/GreycLab/CImg/releases/tag/v.3.7.5). If immediate upgrade is not feasible, implement input validation at the application layer: reject BMP files with nb_colors values exceeding the theoretical maximum (2^bpp for bpp < 16) or larger than the declared file size. Additionally, consider sandboxing or rate-limiting image processing operations to mitigate resource exhaustion impact. Note that disabling BMP format support entirely eliminates the attack surface but may impact feature completeness.

Affected VersionsENISA

CImg < c3aacf5b96ac1e54b7af1957c6737dbf3949f6d3

Affects your stack

Find out whether the stacks and servers you run are on an affected version.

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

CImg is a C++ header-only library for image processing and manipulation. The vulnerability exists in BMP file parsing code within CImg.h, specifically in the image loading routine that reads the BMP color palette header field (nb_colors). The library uses this value directly to allocate memory for the palette without validating it against either the declared bits-per-pixel (bpp) or the remaining file size. For bpp values less than 16, the maximum valid palette size should be 2^bpp colors; the patch enforces this constraint. The root cause is CWE-789 (Memory Allocation with Excessive Size Value), where untrusted input directly determines allocation size without bounds checking.

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (github) PRIMARY 5.5 MEDIUM
AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H

Primary rating from Vendor (github) · only source for this CVE.

CVSS VectorVendor: github

Attack Vector
Local
Attack Complexity
Low
Privileges Required
None
User Interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

DescriptionCVE.org

CImg Library is a C++ library for image processing. Prior to commit c3aacf5, the nb_colors field read from the BMP file header is used directly to compute an allocation size without validating it against the remaining file size. A crafted BMP file with a large nb_colors value triggers an out-of-memory condition, crashing any application that uses CImg to load untrusted BMP files. This issue has been patched via commit c3aacf5.

Threat Intelligence Overview

EPSS Score
0.0%
Top 98% exploitable
Data Quality
6 sources
Confidence: High

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available No
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
Poc
System Exposure· derived
Small
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

28
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +28
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy