---
id: CVE-2026-96778
title: >-
  Pillow: Heap buffer overflow writing JPEG comment after ICC profile fills
  buffer
summary: >-
  Pillow is a Python imaging library. From 9.4.0 until 13.0.0,
  ImagingJpegEncode() in src/libImaging/JpegEncode.c can call
  jpeg_write_marker() for a JPEG COM comment when an ICC profile has exactly
  filled the 65536-byte encoder buffer. lib…
severity: high
cvss: 7.7
cvssVector: 'CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N'
cvssSource: cna
cwe:
  - CWE-787
vendor: python-pillow
product: Pillow
affected:
  - 'Pillow >= 9.4.0, < 13.0.0'
published: '2026-10-21'
updated: '2026-10-21'
sourceUpdated: '2026-10-21T20:58:24.238Z'
source: CVEORG
sourceUrl: 'https://www.cve.org/CVERecord?id=CVE-2026-96778'
references:
  - url: >-
      https://github.com/python-pillow/Pillow/security/advisories/GHSA-g7cr-3p24-7wf7
    label: >-
      https://github.com/python-pillow/Pillow/security/advisories/GHSA-g7cr-3p24-7wf7
  - url: 'https://github.com/python-pillow/Pillow/pull/10124'
    label: 'https://github.com/python-pillow/Pillow/pull/10124'
  - url: >-
      https://github.com/python-pillow/Pillow/commit/02561b8dc6117d5670d4b469fecdd02c70854f9b
    label: >-
      https://github.com/python-pillow/Pillow/commit/02561b8dc6117d5670d4b469fecdd02c70854f9b
  - url: 'https://github.com/python-pillow/Pillow/releases/tag/13.0.0'
    label: 'https://github.com/python-pillow/Pillow/releases/tag/13.0.0'
tags:
  - cve.org
ingestedAt: '2026-10-21T21:13:32.723Z'
---

## Overview

Pillow is a Python imaging library. From 9.4.0 until 13.0.0, ImagingJpegEncode() in src/libImaging/JpegEncode.c can call jpeg_write_marker() for a JPEG COM comment when an ICC profile has exactly filled the 65536-byte encoder buffer. libjpeg writes one byte before checking the exhausted free_in_buffer counter, which then wraps and permits the attacker-controlled comment and subsequent compressed image data to overwrite adjacent heap memory. Re-saving an untrusted image as JPEG while preserving its ICC profile and forwarded comment can crash the process and may enable code execution in suitable runtime and heap layouts. This issue is fixed in version 13.0.0.

## Affected

- `Pillow >= 9.4.0, < 13.0.0`

## Remediation

Refer to the linked advisories for vendor-supplied fixes and affected version ranges.
