The TIM (PSX TIM) image parser in ImageMagick contains a critical integer overflow vulnerability in the ReadTIMImage function (coders/tim.c). The code reads width and height (16-bit values) from the file header and calculates image_size = 2 * width * height without checking for overflow.
On 32-bit systems (or where size_t is 32-bit), this calculation can overflow if width and height are large (e.g., 65535), wrapping around to a small value. This results in a small heap allocation via AcquireQuantumMemory and later operations relying on the dimensions can trigger an out of bounds read.
File: coders/tim.c
width=ReadBlobLSBShort(image);
height=ReadBlobLSBShort(image);
image_size=2*width*height; // Line 234 - NO OVERFLOW CHECK!
This vulnerability can lead to Arbitrary Memory Disclosure due to an out of bounds read on 32-bit systems.
{
"sources": [
{
"url": "https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2025-66628",
"published": "2025-12-10T22:16:28.660Z",
"html_url": "https://nvd.nist.gov/vuln/detail/CVE-2025-66628",
"imported": "2026-07-30T14:08:44.499Z",
"database_specific": {
"status": "Analyzed"
},
"id": "CVE-2025-66628",
"modified": "2026-06-17T09:57:07.850Z"
},
{
"url": "https://api.github.com/advisories/GHSA-6hjr-v6g4-3fm8",
"published": "2025-12-10T15:47:42Z",
"html_url": "https://github.com/advisories/GHSA-6hjr-v6g4-3fm8",
"imported": "2026-07-30T14:09:39.037Z",
"id": "GHSA-6hjr-v6g4-3fm8",
"modified": "2025-12-10T15:47:44Z"
},
{
"url": "https://euvdservices.enisa.europa.eu/api/enisaid?id=EUVD-2025-202428",
"published": "2025-12-10T22:04:49Z",
"html_url": "https://euvd.enisa.europa.eu/vulnerability/EUVD-2025-202428",
"imported": "2026-07-30T14:08:55.679Z",
"id": "EUVD-2025-202428",
"modified": "2025-12-11T15:38:56Z"
}
],
"license": "CC-BY-4.0"
}