Vulnerability · Published May 4, 2026 · Assigned by GitHub_M
CVE-2026-42146CImg Library: Uncontrolled memory allocation via nb_colors field in _load_bmp
Medium 5.5
In plain English
A medium-severity security flaw in CImg from GreycLab. Proof-of-concept exploit code is public. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 8% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.
Official description
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.
Affected packages & fixed versions
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | cimg | no fix listed | DEBIAN-CVE-2026-42146 |
| Debian:13 | cimg | 3.5.2+dfsg-1+deb13u1 | DEBIAN-CVE-2026-42146 |
| Debian:14 | cimg | 3.5.2+dfsg-2 | DEBIAN-CVE-2026-42146 |
| Ubuntu:25.10 | cimg | no fix listed | UBUNTU-CVE-2026-42146 |
| Ubuntu:26.04:LTS | cimg | no fix listed | UBUNTU-CVE-2026-42146 |
| Ubuntu:26.10 | cimg | no fix listed | UBUNTU-CVE-2026-42146 |
Affected products (as reported)
Weakness: CWE-789 · Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
References
- https://github.com/GreycLab/CImg/security/advisories/GHSA-g54r-qmgx-c6fv x_refsource_CONFIRM
- https://github.com/GreycLab/CImg/issues/477 x_refsource_MISC
- https://github.com/GreycLab/CImg/commit/c3aacf5b96ac1e54b7af1957c6737dbf3949f6d3 x_refsource_MISC
- https://github.com/GreycLab/CImg/releases/tag/v.3.7.5 x_refsource_MISC