NewApp Monitoring is liveSign up free
AgentbeamBeta
Open-source package vulnerability · PyPI

CVE-2026-114501: Pillow: Arrow export leaks stale heap memory when PILLOW_ALIGNMENT > 1

mediumCVSS 4.0 6.3GHSA-654x-cwwv-5j9c

Pillow 11.2.1 up to 12.x leaks uninitialized heap memory when PILLOW_ALIGNMENT is set above 1 and an image is exported to Arrow. The exported buffer includes row padding and bytes before the first row, which can hold pixels from images freed earlier. Upgrade to Pillow 13.0.0, which rejects Arrow export from non-contiguous images.

Published Oct 23, 2026 · Analysis Nov 2, 2026

What an attacker can do

With PILLOW_ALIGNMENT above 1, Pillow's default allocator pads each row to an aligned line size and starts the first row at an aligned offset in the block. The Arrow export then hands out im->blocks[0].ptr as xsize * ysize tightly packed pixels. The result contains the padding bytes, and can include a few bytes from before the first row. That memory is not cleared, so it can be stale data.

The report's proof of concept frees a 64-pixel-wide image filled with 0x41. It then creates a 61-pixel-wide all-zero image. Exporting the second one through Image.fromarrow(...).tobytes() returns non-zero bytes. The reporter notes that leaking may depend on allocator configuration, and says it likely affects any image whose row length is not a multiple of the alignment.

The exposure is information disclosure only. A service that sets PILLOW_ALIGNMENT, handles images for several users and exports to Arrow, for example to feed pyarrow or dataframes, could return one user's pixels or other heap contents to another. Nothing in the advisory shows code execution or a crash. The attacker needs no privileges, but must be able to get the service to process and export their images.

Who is affected

Pillow >= 11.2.1, < 13.0.0, when the environment variable PILLOW_ALIGNMENT is set above 1 and code exports images to Arrow. The reporter tested 11.2.1 and 12.3.0. Without the variable, or without Arrow export, the described leak does not apply. Check:

pip show pillow

Then check whether your deployment sets PILLOW_ALIGNMENT and calls Arrow export (__arrow_c_array__, or pyarrow and Polars conversions of PIL images).

Pillow

Ecosystem
PyPI
Affected
>= 11.2.1, < 13.0.0
Fixed in
13.0.0
Check
pip show Pillow

How to fix it

Upgrade to Pillow 13.0.0:

pip install --upgrade "pillow>=13.0.0"

The fix (PR 10172, merged 12 October 2026) makes Arrow export reject non-contiguous images instead of leaking padding or stale bytes. Expect an error on such images instead of data. The sources do not name an exception type or give a workaround. If you cannot upgrade yet, the advisory implies that leaving PILLOW_ALIGNMENT unset (default 1) avoids the padded layout, but it does not state this as a workaround.

How to tell if you were hit

Look for deployments that set PILLOW_ALIGNMENT to a value above 1, in container specs, systemd units or app config. Then check code paths that call Arrow export. Stale-memory leaks leave no log line. You can test an image with the report's proof of concept: it raises RuntimeError when exported bytes differ from the pixel data, and prints "Not vulnerable" with a ValueError on patched builds.

Original advisory

From the GitHub Advisory Database (CC BY 4.0).

Summary

When `PILLOW_ALIGNMENT` is set above 1, exporting an image to Arrow returns uninitialized heap memory mixed in with the pixel data. That memory can include pixels from images the process freed earlier.

Details

With an alignment above 1, the default allocator pads each row up to aligned_linesize and starts the first row at an aligned offset into the block. It then exports im->blocks[0].ptr as xsize * ysize tightly packed pixels, so exported data includes the padding bytes, and can include a few bytes from before the first row.

Tested vulnerable on 11.2.1, 12.3.0, 4c1ed27a5.

PoC

Whether things leak may depend on allocator configuration. This does show a leak on my Mac.

import os

os.environ["PILLOW_ALIGNMENT"] = "64"

from PIL import Image

# Image A: 64 px wide, so its rows fill the whole aligned stride
a = Image.new("L", (64, 40), 0x41).transpose(Image.Transpose.FLIP_LEFT_RIGHT)
del a

# Image B: 61 px wide, so each row has 3 bytes of padding; its pixels are all 0
b = Image.new("L", (61, 40), 0).transpose(Image.Transpose.FLIP_LEFT_RIGHT)

try:
    exported = Image.fromarrow(b, b.mode, b.size).tobytes()
except ValueError as e:
    print("Not vulnerable:", e)
else:
    if leaked := len(exported) - exported.count(0):
        raise RuntimeError(f"{leaked} of {len(exported)} exported bytes are not B's pixels")

Impact

Information disclosure for applications that set PILLOW_ALIGNMENT and export images to Arrow. Likely any image whose row length isn't a multiple of the alignment will do. In a service handling several users' images, one user's exported data can contain pixels from another user's image, or other stale heap contents.

Credited to akx.

Questions

Does this affect Pillow if I never set PILLOW_ALIGNMENT?

The advisory describes the leak only for PILLOW_ALIGNMENT above 1, because that setting adds row padding and an aligned start offset. With the default, the described issue does not apply.

Can this leak data between users?

Yes, in principle. In a service handling several users' images, exported data can contain pixels from another user's earlier image or other stale heap contents. The reporter says results depend on allocator configuration.

Is CVE-2026-114501 exploited in the wild?

No source reports exploitation, and it is not in CISA's KEV catalog.

References

How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology

More PyPI vulnerabilities

All PyPI entries