7.5high
CImg Library: Uncontrolled Memory Allocation and Memory Leak in `_load_analyze()` via Crafted NIfTI/Analyze Header
- Severity
- 7.5high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.61% (higher than 43% of CVEs)
- Published
- Last changed
- Assigned by
- GitHub_M
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.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| GreycLab CImg | < 4.0.0 | CVE List |
Classification
What each source says
CVE List
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.
NVD (es)
La Biblioteca CImg es una biblioteca de C++ para procesamiento de imágenes. Antes de la versión 4.0.0 en ’_load_analyze()’, el campo header_size se lee como un ’unsigned int’ de los primeros 4 bytes de un archivo Analyze/NIfTI y se pasa directamente a ’new unsigned char[header_size]’ sin ser acotado contra el tamaño real del archivo. Se acepta un valor de hasta ~4 GB. Si el ’fread’ subsiguiente devuelve ’short’ (como ocurrirá para cualquier archivo malformado), la función lanza una ’CImgIOException’ y el búfer asignado nunca se libera. Un archivo manipulado de 6 bytes es suficiente para activar una asignación de ~1.3 GB por llamada, con la asignación completa filtrada en cada ruta de error. El problema es alcanzable a través de ’load_analyze()’ y el ’load()’ genérico cuando la extensión del archivo es .hdr, .img o .nii. La versión 4.0.0 soluciona el problema.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-47667 changed 2026-07-23 | CVE Terms of Use |
| NVD | CVE-2026-47667 changed 2026-10-24 | Public domain |