Skip to content

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

Moderate severity GitHub Reviewed Published Dec 2, 2025 in ImageMagick/ImageMagick • Updated Dec 3, 2025

Package

nuget Magick.NET-Q16-AnyCPU (NuGet)

Affected versions

<= 14.9.1

Patched versions

None
nuget Magick.NET-Q16-HDRI-AnyCPU (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-HDRI-OpenMP-arm64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-HDRI-OpenMP-x64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-HDRI-arm64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-HDRI-x64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-HDRI-x86 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-OpenMP-arm64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-OpenMP-x64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-arm64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-x64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q16-x86 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q8-AnyCPU (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q8-OpenMP-arm64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q8-OpenMP-x64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q8-arm64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q8-x64 (NuGet)
<= 14.9.1
None
nuget Magick.NET-Q8-x86 (NuGet)
<= 14.9.1
None

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.

References

@dlemstra dlemstra published to ImageMagick/ImageMagick Dec 2, 2025
Published by the National Vulnerability Database Dec 2, 2025
Published to the GitHub Advisory Database Dec 3, 2025
Reviewed Dec 3, 2025
Last updated Dec 3, 2025

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
High
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(1st percentile)

Weaknesses

Double Free

The product calls free() twice on the same memory address, potentially leading to modification of unexpected memory locations. Learn more on MITRE.

CVE ID

CVE-2025-65955

GHSA ID

GHSA-q3hc-j9x5-mp9m

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.