{"id":"CVE-2026-47667","state":"PUBLISHED","title":"CImg Library: Uncontrolled Memory Allocation and Memory Leak in `_load_analyze()` via Crafted NIfTI/Analyze Header","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.","publishedAt":"2026-07-21T19:57:49.446Z","updatedAt":"2026-07-23T14:13:10.735Z","severity":{"score":7.5,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","source":"GitHub_M"},"assigner":"GitHub_M","products":["GreycLab CImg"],"affected":[{"vendor":"GreycLab","product":"CImg","versions":[{"version":"< 4.0.0","status":"affected"}]}],"references":["https://github.com/GreycLab/CImg/security/advisories/GHSA-rmfc-grgj-qwhv","https://github.com/GreycLab/CImg/issues/480","https://github.com/GreycLab/CImg/commit/6a69bf725ffd111a4c7dc61cc15e3661abd158ee"],"weaknesses":["CWE-401","CWE-789","CWE-1284"],"ingestedAt":"2026-10-29T20:12:07.131Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/47xxx/CVE-2026-47667.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-47667","state":"PUBLISHED","datePublished":"2026-07-21T19:57:49.446Z","dateUpdated":"2026-07-23T14:13:10.735Z","assignerShortName":"GitHub_M","assignerOrgId":"a0819718-46f1-4df5-94e2-005712e83aaa","dateReserved":"2026-05-19T21:10:38.797Z"},"containers":{"cna":{"title":"CImg Library: Uncontrolled Memory Allocation and Memory Leak in `_load_analyze()` via Crafted NIfTI/Analyze Header","descriptions":[{"lang":"en","value":"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":[{"vendor":"GreycLab","product":"CImg","versions":[{"version":"< 4.0.0","status":"affected"}]}],"references":[{"url":"https://github.com/GreycLab/CImg/security/advisories/GHSA-rmfc-grgj-qwhv","name":"https://github.com/GreycLab/CImg/security/advisories/GHSA-rmfc-grgj-qwhv","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/GreycLab/CImg/issues/480","name":"https://github.com/GreycLab/CImg/issues/480","tags":["x_refsource_MISC"]},{"url":"https://github.com/GreycLab/CImg/commit/6a69bf725ffd111a4c7dc61cc15e3661abd158ee","name":"https://github.com/GreycLab/CImg/commit/6a69bf725ffd111a4c7dc61cc15e3661abd158ee","tags":["x_refsource_MISC"]}],"metrics":[{"cvssV3_1":{"attackComplexity":"LOW","attackVector":"NETWORK","availabilityImpact":"HIGH","baseScore":7.5,"baseSeverity":"HIGH","confidentialityImpact":"NONE","integrityImpact":"NONE","privilegesRequired":"NONE","scope":"UNCHANGED","userInteraction":"NONE","vectorString":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","version":"3.1"}}],"problemTypes":[{"descriptions":[{"cweId":"CWE-401","lang":"en","description":"CWE-401: Missing Release of Memory after Effective Lifetime","type":"CWE"}]},{"descriptions":[{"cweId":"CWE-789","lang":"en","description":"CWE-789: Memory Allocation with Excessive Size Value","type":"CWE"}]},{"descriptions":[{"cweId":"CWE-1284","lang":"en","description":"CWE-1284: Improper Validation of Specified Quantity in Input","type":"CWE"}]}],"providerMetadata":{"shortName":"GitHub_M","orgId":"a0819718-46f1-4df5-94e2-005712e83aaa","dateUpdated":"2026-07-21T19:57:49.446Z"},"source":{"advisory":"GHSA-rmfc-grgj-qwhv","discovery":"UNKNOWN"}},"adp":[{"title":"CISA ADP Vulnrichment","references":[{"url":"https://github.com/GreycLab/CImg/issues/480","tags":["exploit"]}],"metrics":[{"other":{"type":"ssvc","content":{"timestamp":"2026-07-23T14:12:55.547375Z","id":"CVE-2026-47667","options":[{"Exploitation":"poc"},{"Automatable":"yes"},{"Technical Impact":"partial"}],"role":"CISA Coordinator","version":"2.0.3"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-07-23T14:13:10.735Z"}}]}}}