# CVE-2026-112397: Pillow buffer underflow in ImageMorph.MorphOp.apply

Source: https://junglewise.ai/threats/cve-2026-112397-pillow-is-a-python-imaging-library-prior-to-13-0-0-pillow-s  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-10-19. Updated: 2026-10-19  
License: CC BY 4.0 with a link back

CVE-2026-112397 · Severity: high · CVSS 4 · Published 2026-10-19

Pillow is a Python image processing library used in many web and document processing applications. A malicious or crafted PPM/PGM image file with zero width can trigger an out-of-bounds memory read when a morphology operation is applied, causing the application to crash and potentially denying service.

Technologies: [pillow (PyPI)](https://junglewise.ai/threats/technologies/pillow), [Python Pillow Pillow](https://junglewise.ai/threats/technologies/python-pillow-pillow). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi), [Python Pillow](https://junglewise.ai/threats/vendors/python-pillow).

## Quick answers

**Is CVE-2026-112397 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-112397 being exploited in the wild.

**How severe is CVE-2026-112397?** High severity, with a CVSS score of 4, published 19 October 2026.

**Which products and versions are affected?** pillow (PyPI) <= 12.3.0, ECOSYSTEM:introduced=0,fixed=13.0.0; Python Pillow Pillow before 13.0.0.

**Is there a fix for CVE-2026-112397?** Yes. pillow (PyPI): upgrade to 13.0.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-112397 attacked?** It is attacked over the network or with local access.

**Am I affected by CVE-2026-112397?** Check whether you run pillow (PyPI) or Python Pillow Pillow at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- pillow (PyPI): upgrade to 13.0.0 or later

  ```sh
  pip install "pillow>=13.0.0"
  ```


## Technical details

The vulnerability is a buffer underflow in ImageMorph.MorphOp.apply() that occurs when processing zero-width images created by PPM or PGM input formats. The native morphology routine attempts to access outrow[width - 1] without bounds checking, leading to out-of-bounds memory access. An attacker can supply a crafted image to trigger a crash in any application that applies morphology operations.

## Affected products

- python-pillow Pillow before 13.0.0

## Identifiers

- CVE-2026-112397
- BIT-PILLOW-2026-112397
- GHSA-58r4-6rv3-gfh8
- PYSEC-2026-4329

## Timeline

- 2026-10-19: disclosed
- 2026-10-16: patched

## References

- [https://github.com/python-pillow/Pillow/commit/18f7c0dfee93063c51db6ed0ca8c4da2999dcb64](https://github.com/python-pillow/Pillow/commit/18f7c0dfee93063c51db6ed0ca8c4da2999dcb64)
- [https://github.com/python-pillow/Pillow/releases/tag/13.0.0](https://github.com/python-pillow/Pillow/releases/tag/13.0.0)

## Related threats

- [Pillow heap buffer overflow in TIFF encoder with mismatched geometry tags](https://junglewise.ai/threats/cve-2026-128067-pillow-heap-buffer-overflow-saving-tiff-with-libtiff-when-tags)
- [Pillow memory denial of service in TIFF and EXIF parsing](https://junglewise.ai/threats/cve-2026-128066-pillow-memory-dos-in-tiff-and-exif-ifd-parsing-via-overlapping)
- [Pillow libtiff encoder memory disclosure and crash via crafted TIFF tags](https://junglewise.ai/threats/cve-2026-112902-pillow-memory-disclosure-and-segfault-in-libtiff-encoder-via)
- [Pillow EPS load decompression bomb check bypass in Ghostscript scaling](https://junglewise.ai/threats/cve-2026-112899-pillow-eps-load-scale-lets-ghostscript-render-past-the)
- [Pillow heap buffer overflow in bundled libopenjp2](https://junglewise.ai/threats/pillow-bundled-libopenjp2-2-5-4-in-all-wheels-since-11-1-0-carries-osv-cd00a842)
