Executive brief
Pillow, a popular Python library for image processing, contains a vulnerability that can cause a system crash or allow unauthorized memory modification. By providing specific, extreme coordinates to image functions like cropping or pasting, an attacker could trigger a memory error. This could lead to application instability or potentially be used as a building block for more complex attacks if the application processes untrusted coordinate data.
Technical details
A heap out-of-bounds write exists in Pillow's native C extension due to signed integer overflow in coordinate arithmetic. In `src/libImaging/Paste.c`, the `ImagingPaste()` function calculates image dimensions using signed 32-bit integers; providing coordinates near `INT_MIN` or `INT_MAX` causes these calculations to wrap around, bypassing boundary checks. In 4-byte pixel modes like RGBA, this results in a controlled backward heap underwrite via `memcpy`. The vulnerability is reachable through public APIs including `Image.paste()`, `Image.crop()`, and `Image.alpha_composite()`. The issue is fixed in version 12.3.0 by implementing checked arithmetic and wider integer types for coordinate calculations.
Affected products
- python-pillow Pillow < 12.3.0
Timeline
- 2026-07-07: advisory: Initial GitHub Advisory published
- 2026-07-20: disclosed
- 12.3.0: patched