Vulnerabilities in pkg:pypi/Pillow

PACKAGE
Advisory Identifier: GHSA-58r4-6rv3-gfh8
Advisory Summary

CVE-2026-112397 is a HIGH out-of-bounds access vulnerability (CWE-787: Out-of-bounds Write) affecting Pillow libraries in the PyPI ecosystem. The issue involves out-of-bounds access in _imagingmorph on a zero-width image. Remediation is available by upgrading affected packages to version 13.0.0.

22 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/Pillow

22 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-58r4-6rv3-gfh8 CVE-2026-112397 HIGH Pillow: Out-of-bounds access in _imagingmorph on a zero-width image
GHSA-65qm-jvmh-6pqg CVE-2026-112400 HIGH Pillow: GIF seek keeps rejected size after DecompressionBombError, allowing DoS
GHSA-vx6w-vv9f-6gvg CVE-2026-112899 MODERATE Pillow: EPS load(scale) lets Ghostscript render past the decompression bomb limit
GHSA-q45j-58j2-45rg CVE-2026-112897 HIGH Pillow: TiffDecode returns uninitialized memory as pixels for short JPEG strips
GHSA-pchr-8j38-3x4p CVE-2026-112896 HIGH Pillow: TIFF encoder ColorMap plane-size mismatch causes a heap out-of-bounds read
GHSA-c6hw-5grf-ff96 CVE-2026-112404 HIGH Pillow: OOB read in TiffDecode.c tile and RGBA paths leaks heap memory into pixels
GHSA-8g5g-8vmr-9782 CVE-2026-112403 CRITICAL Pillow: Heap buffer overflow in ImagingJpegDecode
GHSA-jjj6-mw9f-p565 CVE-2026-59200 HIGH Pillow: Decompression Bomb DoS via PdfParser.PdfStream.decode()
GHSA-6r8x-57c9-28j4 CVE-2026-59199 HIGH Pillow: Heap out-of-bounds write `Image.paste()` / `Image.crop()` via signed coordinate overflow
GHSA-fj7v-r99m-22gq CVE-2026-59198 MODERATE Pillow TGA RLE encoder can serialize up to ~57 KB of adjacent heap data into generated images
GHSA-xj96-63gp-2gmr CVE-2026-59197 HIGH Pillow: Heap out-of-bounds write in `ImageFilter.RankFilter` via integer overflow in `ImagingExpand`
GHSA-4x4j-2g7c-83w6 CVE-2026-55798 MODERATE Pillow: WindowsViewer.get_command() OS command injection via unescaped shell path
GHSA-f4w8-cv6p-x6r5 CVE-2021-27921 HIGH Pillow Denial of Service by Uncontrolled Resource Consumption
GHSA-j7hp-h8jx-5ppr CVE-2023-4863 HIGH libwebp: OOB write in BuildHuffmanTable
GHSA-hr8g-f6r6-mr22 CVE-2022-30595 HIGH Buffer over-flow in Pillow
GHSA-3f63-hfp8-52jq CVE-2023-50447 CRITICAL Arbitrary Code Execution in Pillow
GHSA-hjfx-8p6c-g7gx CVE-2021-28678 MODERATE Insufficient Verification of Data Authenticity in Pillow
GHSA-9j59-75qj-795w CVE-2022-24303 HIGH Path traversal in Pillow
GHSA-p43w-g3c5-g5mq CVE-2021-25293 HIGH Out of bounds read in Pillow
GHSA-w4vg-rf63-f3j3 CVE-2016-9190 HIGH Arbitrary code using "crafted image file" approach affecting Pillow
GHSA-hj69-c76v-86wr CVE-2020-5313 HIGH Out-of-bounds Read in Pillow
GHSA-4fx9-vc88-q2xc - LOW Infinite loop in Pillow

CVE-2026-112397 at a Glance

CVE Identifier CVE-2026-112397
GHSA Identifier GHSA-58r4-6rv3-gfh8
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-787: Out-of-bounds Write
Affected Product Pillow
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-112397

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-112397, 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-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

### Summary A PPM or PGM file can declare a width of 0, which Pillow accepts, producing an image of size `(0, N)`. Passing that image to `ImageMorph.MorphOp.apply()` makes the native morphology code index a row buffer at `outrow[width - 1]`, which is `outrow[-1]` when the width is 0. The process crashes. ### Details The PPM parser reads width and height with no lower-bound check: - `src/PIL/PpmImagePlugin.py:119` The native `apply()` writes the row edges with no guard that the width is positive: - `src/_imagingmorph.c:81` sets `outrow[0] = outrow[width - 1] = 0;` `match()` and `get_on_pixels()` use the same edge-indexing pattern. ### PoC ```python from PIL import Image, ImageMorph # A width-0 image (also producible from a crafted PPM header). apply() indexes # outrow[width - 1] == outrow[-1] in native code. im = Image.new("L", (0, 5)) ImageMorph.MorphOp(op_name="dilation4").apply(im) ``` Run it: ``` $ python 03_poc.py Segmentation fault (core dumped) ``` Observed on a source build of commit `3e2ab96`. Under AddressSanitizer: ``` ==ERROR: AddressSanitizer: SEGV on unknown address (pc ... in apply) #0 apply src/_imagingmorph.c:81 SUMMARY: AddressSanitizer: SEGV src/_imagingmorph.c:81 in apply ``` With width 0 the `outrow[width - 1]` write lands on an unmapped page, so it surfaces as a SEGV pinned to the edge-write line rather than a redzone overflow. ### Impact Out-of-bounds write in a C extension. Affects any application that runs a morphology operation on an image opened from untrusted input. Result is a crash and possible memory corruption.

CVE-2026-112397 Affected Pillow Versions

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

References

Frequently Asked Questions

What is CVE-2026-112397?
CVE-2026-112397 is a security vulnerability in Pillow involving Out-of-bounds access in _imagingmorph on a zero-width image under CWE-787: Out-of-bounds Write.
Which Pillow versions are affected?
Affected versions include releases prior to 13.0.0 across affected packages: Pillow.
What version fixes CVE-2026-112397?
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-112397?
CVE-2026-112397 is classified under CWE-787: Out-of-bounds Write (The product writes data past the end, or before the beginning, of the intended buffer.).
How can I check PyPI dependencies for CVE-2026-112397?
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-58r4-6rv3-gfh8",
  "modified" : "2026-10-20T20:56:22Z",
  "published" : "2026-10-20T20:56:22Z",
  "aliases" : [ "CVE-2026-112397" ],
  "summary" : "Pillow: Out-of-bounds access in _imagingmorph on a zero-width image",
  "details" : "### Summary\nA PPM or PGM file can declare a width of 0, which Pillow accepts, producing an image of size `(0, N)`. Passing that image to `ImageMorph.MorphOp.apply()` makes the native morphology code index a row buffer at `outrow[width - 1]`, which is `outrow[-1]` when the width is 0. The process crashes.\n\n### Details\nThe PPM parser reads width and height with no lower-bound check:\n\n- `src/PIL/PpmImagePlugin.py:119`\n\nThe native `apply()` writes the row edges with no guard that the width is positive:\n\n- `src/_imagingmorph.c:81` sets `outrow[0] = outrow[width - 1] = 0;`\n\n`match()` and `get_on_pixels()` use the same edge-indexing pattern.\n\n### PoC\n```python\nfrom PIL import Image, ImageMorph\n\n# A width-0 image (also producible from a crafted PPM header). apply() indexes\n# outrow[width - 1] == outrow[-1] in native code.\nim = Image.new(\"L\", (0, 5))\nImageMorph.MorphOp(op_name=\"dilation4\").apply(im)\n```\n\nRun it:\n```\n$ python 03_poc.py\nSegmentation fault (core dumped)\n```\n\nObserved on a source build of commit `3e2ab96`.\n\nUnder AddressSanitizer:\n```\n==ERROR: AddressSanitizer: SEGV on unknown address (pc ... in apply)\n    #0 apply   src/_imagingmorph.c:81\nSUMMARY: AddressSanitizer: SEGV src/_imagingmorph.c:81 in apply\n```\nWith width 0 the `outrow[width - 1]` write lands on an unmapped page, so it surfaces as a SEGV pinned to the edge-write line rather than a redzone overflow.\n\n### Impact\nOut-of-bounds write in a C extension. Affects any application that runs a morphology operation on an image opened from untrusted input. Result is a crash and possible memory corruption.",
  "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" : "0"
      }, {
        "fixed" : "13.0.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 12.3.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/security/advisories/GHSA-58r4-6rv3-gfh8"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-112397"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/python-pillow/Pillow/commit/18f7c0dfee93063c51db6ed0ca8c4da2999dcb64"
  }, {
    "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-787" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-20T20:56:22Z",
    "nvd_published_at" : "2026-10-19T22:17:06Z"
  }
}