CVE-2025-65955
JSON

4.9medium

ImageMagick has a use-after-free/double-free risk in Options::fontFamily when clearing family

Severity
4.9medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.17% (higher than 6% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-q3hc-j9x5-mp9m

Description

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.

Affected

Product or packageVersionsReported by
ImageMagick ImageMagick>= 7.0.1-0, < 7.1.2-9, < 6.9.13-34, before 6.9.13-34, from 7.0.0-0 before 7.1.2-9CVE List, NVD
Magick.NET-Q16-AnyCPU (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-HDRI-AnyCPU (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-HDRI-OpenMP-arm64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-HDRI-OpenMP-x64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-HDRI-arm64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-HDRI-x64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-HDRI-x86 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-OpenMP-arm64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-OpenMP-x64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-arm64 (NuGet)up to 14.9.1GitHub Advisory Database
Magick.NET-Q16-x64 (NuGet)up to 14.9.1GitHub Advisory Database

All scores

GitHub_M4.9medium CVSS:3.1CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L
GitHub4.9medium CVSS:3.1CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L
NVD6.1medium CVSS:3.1CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:H

Classification

CWE-415CWE-416

SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.

What each source says

CVE List

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.

GitHub Advisory Database

Withdrawn Advisory

This advisory has been withdrawn because it does not affect the ImageMagick project's NuGet packages.

Original Description

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

Vulnerability Details

  • 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.
if (family_.length() == 0)
  {
    _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->font);
    DestroyString(RemoveImageOption(imageInfo(),"family"));
  }
  • CWE-416 (Use After Free): _drawInfo->font is left dangling yet still reachable through the Options object.
  • CWE-415 (Double Free): DrawInfo teardown frees _drawInfo->font again, provoking allocator aborts.

Affected Versions

  • Introduced by commit 6409f34d637a34a1c643632aa849371ec8b3b5a8 (“Added fontFamily to the Image class of Magick++”, 2015-08-01, blame line 313).
  • 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.

Command Line Triggerability This 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.

Proposed Fix

diff --git a/Magick++/lib/Options.cpp b/Magick++/lib/Options.cpp
@@ void Magick::Options::fontFamily(const std::string &family_)
-      _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->font);
+      _drawInfo->family=(char *) RelinquishMagickMemory(_drawInfo->family);

This frees only the actual family string, leaving _drawInfo->font untouched. Optionally nulling _drawInfo->font when clearing font() itself maintains allocator hygiene.

NVD (es)

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.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-65955 changed 2026-06-23CVE Terms of Use
GitHub Advisory DatabaseGHSA-q3hc-j9x5-mp9m changed 2025-12-11CC-BY-4.0
NVDCVE-2025-65955 changed 2026-11-04Public domain