mediumCVSS 6.5Vulnerability

GHSA-qp59-x883-77qv

### Summary A memory leak vulnerability exists in the `LoadOpenCLDeviceBenchmark()` function in `MagickCore/opencl.c`. When parsing a malformed OpenCL device profile XML file that contains `<device` elements without proper `/>` closing tags, the function fails to release allocated memory for string members (`platform_name`, `vendor_name`, `name`, `version`), leading to memory leaks that could result in resource exhaustion. **Affected Version**: ImageMagick 7.1.2-12 and possibly earlier versions --- ### Details The vulnerability is located in `MagickCore/opencl.c`, function `LoadOpenCLDeviceBenchmark()` (lines 754-911). **Root Cause Analysis:** 1. When a `<device` tag is encountered, a `MagickCLDeviceBenchmark` structure is allocated (line 807-812) 2. String attributes (`platform`, `vendor`, `name`, `version`) are allocated via `ConstantString()` (lines 878, 885, 898, 900) 3. These strings are **only freed** when a `/>` closing tag is encountered (lines 840-849) 4. At function exit (lines 908-910), only the `device_benchmark` structure is freed, but **its member variables are not freed** if `/>` was never parsed **Vulnerable Code (lines 908-910):** ```c token=(char *) RelinquishMagickMemory(token); device_benchmark=(MagickCLDeviceBenchmark *) RelinquishMagickMemory( device_benchmark); // BUG: members (platform_name, vendor_name, name, version) not freed! ``` **Correct cleanup (only executed when `/>` is found, lines 840-849):** ```c device_benchmark->platform_name=(char *) RelinquishMagickMemory(device_benchmark->platform_name); device_benchmark->vendor_name=(char *) RelinquishMagickMemory(device_benchmark->vendor_name); device_benchmark->name=(char *) RelinquishMagickMemory(device_benchmark->name); device_benchmark->version=(char *) RelinquishMagickMemory(device_benchmark->version); device_benchmark=(MagickCLDeviceBenchmark *) RelinquishMagickMemory(device_benchmark); ``` --- ### PoC **Environment:** - OS: Ubuntu 22.04.5 LTS (Linux 6.8.0-87-generic

Properties

ghsa_id
GHSA-qp59-x883-77qv
severity
medium
summary
ImageMagick has a Memory Leak in LoadOpenCLDeviceBenchmark() when parsing malformed XML
cvss_score
6.5
cve_id
GHSA-qp59-x883-77qv
cvss_vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:H
is_ghsa_only
true
ghsa_published
2026-01-21T01:06:34Z
source_url
https://github.com/advisories/GHSA-qp59-x883-77qv
ghsa_updated
2026-01-21T01:06:35Z

Related Entities (22)

INVOLVES (1)

[EmergentSignal]

REPORTED_BY (1)

[Source]GitHub Advisory Database

AFFECTS (19)

[Software]nuget/Magick.NET-Q16-HDRI-x86
[Software]nuget/Magick.NET-Q16-OpenMP-x86
[Software]nuget/Magick.NET-Q8-OpenMP-arm64
[Software]nuget/Magick.NET-Q8-AnyCPU
[Software]nuget/Magick.NET-Q16-arm64
[Software]nuget/Magick.NET-Q16-HDRI-AnyCPU
[Software]nuget/Magick.NET-Q16-HDRI-arm64
[Software]nuget/Magick.NET-Q16-HDRI-x64
[Software]nuget/Magick.NET-Q8-arm64
[Software]nuget/Magick.NET-Q16-x86
[Software]nuget/Magick.NET-Q8-OpenMP-x64
[Software]nuget/Magick.NET-Q16-AnyCPU
[Software]nuget/Magick.NET-Q16-x64
[Software]nuget/Magick.NET-Q8-x86
[Software]nuget/Magick.NET-Q8-x64
[Software]nuget/Magick.NET-Q16-HDRI-OpenMP-x64
[Software]nuget/Magick.NET-Q16-HDRI-OpenMP-arm64
[Software]nuget/Magick.NET-Q16-OpenMP-arm64
[Software]nuget/Magick.NET-Q16-OpenMP-x64

HAS_WEAKNESS (1)

[Weakness]Release of Invalid Pointer or Reference

Explore deeper with Ninja Signal's threat intelligence graph

GHSA-qp59-x883-77qv (CVSS 6.5) — Ninja Signal Threat Intelligence | Ninja Signal