{"id":"CVE-2025-65955","aliases":["CVE-2025-65955","GHSA-q3hc-j9x5-mp9m"],"related":[],"kind":"vulnerability","state":"published","title":"ImageMagick has a use-after-free/double-free risk in Options::fontFamily when clearing family","summary":"ImageMagick is free and open-source software used for editing and manipulating digital images. Prior to 7.1.2-9 and 6.9.13-34, there is a vulnerability in ImageMagick’s Magick++ layer that manifests when Options::fontFamily is invoked with an empty string. Clearing a font family calls RelinquishMagickMemory on _drawInfo->font, freeing the font string but leaving _drawInfo->font pointing to freed memory while _drawInfo->family is set to that (now-invalid) pointer. Any later cleanup or reuse of _drawInfo->font re-frees or dereferences dangling memory. DestroyDrawInfo and other setters (Options::font, Image::font) assume _drawInfo->font remains valid, so destruction or subsequent updates trigger crashes or heap corruption. This vulnerability is fixed in 7.1.2-9 and 6.9.13-34.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"ImageMagick is free and open-source software used for editing and manipulating digital images. Prior to 7.1.2-9 and 6.9.13-34, there is a vulnerability in ImageMagick’s Magick++ layer that manifests when Options::fontFamily is invoked with an empty string. Clearing a font family calls RelinquishMagickMemory on _drawInfo->font, freeing the font string but leaving _drawInfo->font pointing to freed memory while _drawInfo->family is set to that (now-invalid) pointer. Any later cleanup or reuse of _drawInfo->font re-frees or dereferences dangling memory. DestroyDrawInfo and other setters (Options::font, Image::font) assume _drawInfo->font remains valid, so destruction or subsequent updates trigger crashes or heap corruption. This vulnerability is fixed in 7.1.2-9 and 6.9.13-34.","source":"cvelist"},{"lang":"en","text":"## Withdrawn Advisory\nThis advisory has been withdrawn because it does not affect the ImageMagick project's NuGet packages.\n\n### Original Description\nWe believe that we have discovered a potential security vulnerability in ImageMagick’s Magick++ layer that manifests when `Options::fontFamily` is invoked with an empty string.\n\n**Vulnerability Details**\n- Clearing a font family calls `RelinquishMagickMemory` on `_drawInfo->font`, freeing the font string but leaving `_drawInfo->font` pointing to freed memory while `_drawInfo->family` is set to that (now-invalid) pointer. Any later cleanup or reuse of `_drawInfo->font` re-frees or dereferences dangling memory.\n- `DestroyDrawInfo` and other setters (`Options::font`, `Image::font`) assume `_drawInfo->font` remains valid, so destruction or subsequent updates trigger crashes or heap corruption.\n\n```cpp\nif (family_.length() == 0)\n  {\n    _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->font);\n    DestroyString(RemoveImageOption(imageInfo(),\"family\"));\n  }\n```\n\n- **CWE-416 (Use After Free):** `_drawInfo->font` is left dangling yet still reachable through the Options object.\n- **CWE-415 (Double Free):** DrawInfo teardown frees `_drawInfo->font` again, provoking allocator aborts.\n\n**Affected Versions**\n- Introduced by commit `6409f34d637a34a1c643632aa849371ec8b3b5a8` (“Added fontFamily to the Image class of Magick++”, 2015-08-01, blame line 313).\n- Present in all releases that include that commit, at least ImageMagick 7.0.1-0 and later (likely late 6.9 builds with Magick++ font family support as well). Older releases without `fontFamily` are unaffected.\n\n**Command Line Triggerability**\nThis vulnerability cannot be triggered from the command line interface. The bug is specific to the Magick++ C++ API, specifically the `Options::fontFamily()` method. The command-line utilities (such as `convert`, `magick`, etc.) do not expose this particular code path, as they operate through different internal mechanisms that do not directly call `Options::fontFamily()` with an empty string in a way that would trigger the use-after-free condition.\n\n**Proposed Fix**\n```diff\ndiff --git a/Magick++/lib/Options.cpp b/Magick++/lib/Options.cpp\n@@ void Magick::Options::fontFamily(const std::string &family_)\n-      _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->font);\n+      _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->family);\n```\nThis frees only the actual family string, leaving `_drawInfo->font` untouched. Optionally nulling `_drawInfo->font` when clearing `font()` itself maintains allocator hygiene.","format":"markdown","source":"ghsa"},{"lang":"es","text":"ImageMagick es un software libre y de código abierto utilizado para editar y manipular imágenes digitales. Versiones anteriores a 7.1.2-9 y 6.9.13-34, existe una vulnerabilidad en la capa Magick++ de ImageMagick que se manifiesta cuando se invoca Options::fontFamily con una cadena vacía. Al borrar una familia de fuentes, se llama a RelinquishMagickMemory en _drawInfo -> font, liberando la cadena de la fuente pero dejando _drawInfo -> font apuntando a memoria liberada, mientras que _drawInfo -> family se establece a ese puntero (ahora inválido). Cualquier limpieza o reutilización posterior de _drawInfo -> font vuelve a liberar o desreferencia memoria colgante. DestroyDrawInfo y otros setters (Options::font, Image::font) asumen que _drawInfo -> font permanece válido, por lo que la destrucción o las actualizaciones posteriores desencadenan fallos o corrupción del heap. Esta vulnerabilidad se ha corregido en 7.1.2-9 y 6.9.13-34.","source":"nvd"}],"published":"2025-12-02T23:02:58.856Z","modified":"2026-11-04T22:10:00.210Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L","score":4.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L","score":4.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L","score":4.9,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:H","score":6.1,"rating":"MEDIUM"}],"cwes":["CWE-415","CWE-416"],"affected":[{"ranges":[{"version":">= 7.0.1-0, < 7.1.2-9","status":"affected"},{"version":"< 6.9.13-34","status":"affected"}],"vendor":"ImageMagick","product":"ImageMagick","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-AnyCPU","purl":"pkg:nuget/Magick.NET-Q16-AnyCPU","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-HDRI-AnyCPU","purl":"pkg:nuget/Magick.NET-Q16-HDRI-AnyCPU","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-HDRI-OpenMP-arm64","purl":"pkg:nuget/Magick.NET-Q16-HDRI-OpenMP-arm64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-HDRI-OpenMP-x64","purl":"pkg:nuget/Magick.NET-Q16-HDRI-OpenMP-x64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-HDRI-arm64","purl":"pkg:nuget/Magick.NET-Q16-HDRI-arm64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-HDRI-x64","purl":"pkg:nuget/Magick.NET-Q16-HDRI-x64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-HDRI-x86","purl":"pkg:nuget/Magick.NET-Q16-HDRI-x86","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-OpenMP-arm64","purl":"pkg:nuget/Magick.NET-Q16-OpenMP-arm64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-OpenMP-x64","purl":"pkg:nuget/Magick.NET-Q16-OpenMP-x64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-arm64","purl":"pkg:nuget/Magick.NET-Q16-arm64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-x64","purl":"pkg:nuget/Magick.NET-Q16-x64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q16-x86","purl":"pkg:nuget/Magick.NET-Q16-x86","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q8-AnyCPU","purl":"pkg:nuget/Magick.NET-Q8-AnyCPU","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q8-OpenMP-arm64","purl":"pkg:nuget/Magick.NET-Q8-OpenMP-arm64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q8-OpenMP-x64","purl":"pkg:nuget/Magick.NET-Q8-OpenMP-x64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q8-arm64","purl":"pkg:nuget/Magick.NET-Q8-arm64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q8-x64","purl":"pkg:nuget/Magick.NET-Q8-x64","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"14.9.1"}],"ecosystem":"NuGet","package":"Magick.NET-Q8-x86","purl":"pkg:nuget/Magick.NET-Q8-x86","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"6.9.13-34"},{"status":"affected","introduced":"7.0.0-0","fixed":"7.1.2-9"}],"vendor":"imagemagick","product":"imagemagick","cpe":"cpe:2.3:a:imagemagick:imagemagick:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-q3hc-j9x5-mp9m","tags":["vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ImageMagick/ImageMagick/commit/6409f34d637a34a1c643632aa849371ec8b3b5a8","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/ImageMagick/ImageMagick/commit/6f81eb15f822ad86e8255be75efad6f9762c32f8","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2025-65955","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/ImageMagick/ImageMagick","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2025-12-03T14:55:39.239Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2025-65955","url":"https://www.cve.org/CVERecord?id=CVE-2025-65955","licence":"CVE Terms of Use","modified":"2026-06-23T16:10:14.599Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-q3hc-j9x5-mp9m","url":"https://github.com/advisories/GHSA-q3hc-j9x5-mp9m","licence":"CC-BY-4.0","modified":"2025-12-11T21:03:56.469Z"},{"source":"nvd","name":"NVD","id":"CVE-2025-65955","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-65955","licence":"Public domain","modified":"2026-11-04T22:10:00.210Z"}],"updatedAt":"2026-11-25T22:59:08.215Z","epss":{"score":0.00171,"percentile":0.06749,"date":"2026-12-01T12:00:22.000Z"}}