Description
CImg Library is a C++ library for image processing. Prior to version 4.0.0 in `_load_analyze()`, the header_size field is read as an `unsigned int` from the first 4 bytes of an Analyze/NIfTI file and passed directly to `new unsigned char[header_size]` without being bounded against the actual file size. A value up to ~4 GB is accepted. If the subsequent `fread` returns `short` as it will for any malformed file), the function throws a `CImgIOException` and the allocated buffer is never freed. A 6-byte crafted file is sufficient to trigger an allocation of ~1.3 GB per call, with the full allocation leaked on every error path. The issue is reachable via `load_analyze()` and the generic `load()` when the file extension is .hdr, .img, or .nii. Version 4.0.0 fixes the issue.
Published: 2026-07-21
Score: 7.5 High
EPSS: < 1% Very Low
KEV: No
Impact: n/a
Action: n/a
AI Analysis

Impact

The vulnerability is an uncontrolled memory allocation and memory leak in the `_load_analyze()` routine of the CImg image processing library. Prior to version 4.0.0, the library reads the `header_size` field as an `unsigned int` from the first 4 bytes of an Analyze/NIfTI file and uses it directly to allocate a new `unsigned char[header_size]` buffer without being bounded against the actual file size. A value up to ~4 GB is accepted. When the subsequent `fread` returns a short value—typically for any malformed file—the function throws a `CImgIOException` and the allocated buffer is never freed, leaking the full allocation on every error path. A six‑byte crafted file is sufficient to trigger an allocation of ~1.3 GB per call, with the allocation being leaked on each error. The issue is reachable via `load_analyze()` and the generic `load()` when the file extension is .hdr, .img, or .nii. Version 4.0.0 fixes the issue.

Affected Systems

The flaw exists in the CImg image processing library supplied by GreycLab. All versions earlier than 4.0.0 are affected, including the common 3.x releases that many scientific and medical imaging applications rely upon. The issue is triggered by calls to `load_analyze()` or the generic `load()` function when handling files with .hdr, .img, or .nii extensions. Version 4.0.0 and later contain a boxed allocation guard that prevents the over-allocation.

Risk and Exploitability

The CVSS score of 7.5 indicates a high‑severity impact. The EPSS score is below 1% and the vulnerability is not listed in CISA KEV, implying a low to moderate exploitation probability under current threat information. Attackers would need to supply a crafted Analyze/NIfTI file, either locally or via an application that processes user‑supplied imaging data. In a local context the impact is direct memory exhaustion leading to a crash or denial of service; in a remote setting an application that uses CImg in a privileged or network‑exposed role could be affected if it accepts untrusted files. No privilege escalation or code execution paths are evident from the description.

Generated by OpenCVE AI on July 30, 2026 at 16:36 UTC.

Remediation

No vendor fix or workaround currently provided.

OpenCVE Recommended Actions

  • Upgrade the CImg library to version 4.0.0 or later, which includes a bounds check before allocating the header buffer.
  • If an upgrade is not yet feasible, validate the header size and file size before invoking `load_analyze()` or `load()`, rejecting headers that request more memory than the file provides.
  • Run any application that processes external image files in a restricted environment or sandbox to limit memory usage, mitigating the DoS impact of an exploit.

Generated by OpenCVE AI on July 30, 2026 at 16:36 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories yet.

History

Thu, 23 Jul 2026 15:30:00 +0000

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'poc', 'Technical Impact': 'partial'}, 'version': '2.0.3'}


Thu, 23 Jul 2026 05:45:00 +0000

Type Values Removed Values Added
First Time appeared Greyclab
Greyclab cimg
Vendors & Products Greyclab
Greyclab cimg

Tue, 21 Jul 2026 20:15:00 +0000

Type Values Removed Values Added
Description CImg Library is a C++ library for image processing. Prior to version 4.0.0 in `_load_analyze()`, the header_size field is read as an `unsigned int` from the first 4 bytes of an Analyze/NIfTI file and passed directly to `new unsigned char[header_size]` without being bounded against the actual file size. A value up to ~4 GB is accepted. If the subsequent `fread` returns `short` as it will for any malformed file), the function throws a `CImgIOException` and the allocated buffer is never freed. A 6-byte crafted file is sufficient to trigger an allocation of ~1.3 GB per call, with the full allocation leaked on every error path. The issue is reachable via `load_analyze()` and the generic `load()` when the file extension is .hdr, .img, or .nii. Version 4.0.0 fixes the issue.
Title CImg Library: Uncontrolled Memory Allocation and Memory Leak in `_load_analyze()` via Crafted NIfTI/Analyze Header
Weaknesses CWE-1284
CWE-401
CWE-789
References
Metrics cvssV3_1

{'score': 7.5, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H'}


cve-icon MITRE

Status: PUBLISHED

Assigner: GitHub_M

Published:

Updated: 2026-07-23T14:13:10.735Z

Reserved: 2026-05-19T21:10:38.797Z

Link: CVE-2026-47667

cve-icon Vulnrichment

Updated: 2026-07-23T14:12:47.137Z

cve-icon NVD

No data.

cve-icon Redhat

No data.

cve-icon OpenCVE Enrichment

Updated: 2026-07-30T16:45:04Z

Weaknesses
  • CWE-1284

    Improper Validation of Specified Quantity in Input

  • CWE-401

    Missing Release of Memory after Effective Lifetime

  • CWE-789

    Memory Allocation with Excessive Size Value