PatchSiren

PatchSiren cyber security CVE debrief

CVE-2026-96778 python-pillow CVE debrief

A heap buffer overflow in Pillow's JPEG encoder allows writing up to 64 KB of chosen bytes past a 64 KB heap buffer when saving an image as JPEG with its color profile. This reliably crashes the Python process and may allow code execution due to overwritten function pointers. The bug is located in ImagingJpegEncode() in src/libImaging/JpegEncode.c, specifically at line 330 where jpeg_write_marker() is called for the COM comment marker without checking output buffer room. Defenders should prioritize verifying exposure in image processing workflows, especially where untrusted images are re-saved as JPEG.

Vendor
python-pillow
Product
pillow
CVSS
HIGH 7.7
CISA KEV
Not listed in stored evidence
Original CVE published
2026-10-22
Original CVE updated
2026-10-22
Advisory published
2026-10-22
Advisory updated
2026-10-22

Who should care

Defenders responsible for image processing systems, especially those using Pillow for JPEG encoding, should assess exposure and prioritize updates or compensating controls. This includes reviewing relevant monitoring, detection, and logs for exposed assets that need extra review, and tracking exceptions, retesting remediated assets, and closing the item only after evidence is documented.

Why it matters

CVE-2026-96778 is a heap buffer overflow in Pillow's JPEG encoder that can lead to process crashes and potentially code execution. Defenders should prioritize verifying exposure, especially in image processing workflows using affected Pillow versions, and update to version 13.0.0 or later.

  • Potential code execution due to overwritten function pointers
  • Reliable process crash when handling specially crafted images
  • Need for verification of exposure in image processing workflows
  • Priority on updating or patching affected Pillow versions

Technical summary

The bug is in ImagingJpegEncode() in src/libImaging/JpegEncode.c. State 4 (line 330) calls jpeg_write_marker() for the COM comment marker without checking that the output buffer has room. This allows writing up to 64 KB of chosen bytes past a 64 KB heap buffer when saving an image as JPEG with its color profile. The reliable result is that the Python process is killed outright rather than raising an exception. Because the overwritten memory sits directly in front of function pointers that the encoder calls next, this could allow code execution, though the attached reproducer demonstrates only the crash.

Defensive priority

Defenders should prioritize verifying exposure in image processing workflows, especially where untrusted images are re-saved as JPEG. Assess Pillow versions 9.4.0 to 12.3.0 for potential vulnerability.

Recommended defensive actions

  • Verify and update Pillow to version 13.0.0 or later
  • Assess exposure in image processing workflows using affected Pillow versions
  • Implement compensating controls for untrusted image processing
  • Review relevant monitoring, detection, and logs for exposed assets that need extra review
  • Track exceptions, retest remediated assets, and close the item only after evidence is documented
  • Confirm whether affected product deployments exist in managed environments and assign an owner for follow-up
  • Plan vendor-supported updates or mitigations through normal change control where exposure is confirmed

Evidence notes

The issue is confirmed in Pillow's JPEG encoder, specifically in ImagingJpegEncode() at src/libImaging/JpegEncode.c:330. A reproducer demonstrates the crash, but code execution is speculative. The reliable result is that the Python process is killed outright rather than raising an exception. Because the overwritten memory sits directly in front of function pointers that the encoder calls next, this could allow code execution, though the attached reproducer demonstrates only the crash.

Sources and references

Verified primary and authoritative sources

  • CVE-2026-96778 CVE Program record

    Publisher, destination, and source semantics verified

    URL: https://www.cve.org/CVERecord?id=CVE-2026-96778

    CVE Program - Official CVE Program record with source-provided CVE metadata.

  • CVE-2026-96778 NVD vulnerability detail

    Publisher, destination, and source semantics verified

    URL: https://nvd.nist.gov/vuln/detail/CVE-2026-96778

    NIST National Vulnerability Database - Official NIST NVD detail page and source-specific vulnerability assessment.

Supplemental references

  • Pillow: Heap buffer overflow writing JPEG comment after ICC profile fills buffer

    Unverified legacy reference

    URL: https://storage.googleapis.com/osv-vulnerabilities/PyPI/GHSA-g7cr-3p24-7wf7.json

    osv_dev

  • Source reference

    Unverified legacy reference

    URL: https://github.com/python-pillow/Pillow/security/advisories/GHSA-g7cr-3p24-7wf7

    Supplemental source

  • Source reference

    Unverified legacy reference

    URL: https://github.com/python-pillow/Pillow/pull/10124

    Supplemental source

  • Source reference

    Unverified legacy reference

    URL: https://github.com/python-pillow/Pillow/commit/02561b8dc6117d5670d4b469fecdd02c70854f9b

    Supplemental source

  • Source reference

    Unverified legacy reference

    URL: https://github.com/python-pillow/Pillow

    Supplemental source

  • Source reference

    Unverified legacy reference

    URL: https://github.com/python-pillow/Pillow/releases/tag/13.0.0

    Supplemental source

Methodology and review provenance

AI-assisted synthesis based on stored public vulnerability evidence. System validation, approval state, and publication status do not by themselves establish human review of this revision. PatchSiren helps prioritize defensive review and does not prove exposure or remediation on any system.