On this page (7 sections)
The Python imaging library Pillow has fixed three security flaws in release 13.0.0. Each can crash or hang a worker that processes untrusted images or PDFs: a double free in Image.transform(), an infinite loop when counting frames in a crafted MIC file, and unbounded recursion in the PDF parser used when appending to an existing PDF.
If your site or API accepts uploads and runs them through Pillow (thumbnails, galleries, document stamping, image conversion), check your version. Linux distributions may ship their own fixed Pillow packages, so if you install Pillow through your distribution rather than pip, check your vendor's updates.
What was fixed
All three issues are fixed in Pillow 13.0.0. They are separate bugs in separate components, so exposure depends on which Pillow features your application actually calls.
| CVE | Weakness | Trigger | Impact |
|---|---|---|---|
| CVE-2026-112402 | Double free (CWE-416) | Image.transform() with EXTENT or pure scale/translate AFFINE, default NEAREST resampling, under memory pressure | Process crash, possible memory corruption |
| CVE-2026-112390 | Infinite loop (CWE-835) | Reading n_frames or saving all frames of a crafted MIC file, with olefile installed | Worker stuck at full CPU |
| CVE-2026-112391 | Unbounded recursion (listed as CWE-835) | Saving an image as PDF with append enabled onto an attacker-supplied PDF | RecursionError or worker termination |
Technical details in plain terms
Double free in Image.transform() (CVE-2026-112402)
A double free means the same block of memory is released twice, which can crash a program and may corrupt its heap. According to the GitHub advisory, when a secondary allocation (a per-column lookup table) fails inside ImagingScaleAffine(), the error path frees the output image, and Python's normal cleanup frees it again. Instead of a clean MemoryError, the process crashes.
The advisory is explicit about the limits. Triggering it requires someone who can choose the output size passed to Image.transform(), and it only works on a worker with a memory limit (such as an address-space limit set with ulimit -v, uwsgi --limit-as or systemd LimitAS=) or a 32-bit process. The maintainers describe the heap corruption as not shown to be controllable. resize(), thumbnail() and rotate() are not affected. The fix, in this commit, removes the extra free in the error path.
MIC frame-count infinite loop (CVE-2026-112390)
Per the advisory, a small crafted Microsoft Image Composer (MIC) file can make Pillow loop forever at 100% CPU when an application reads n_frames. This only affects installations with the optional olefile package. Common code paths such as an "is this image animated?" check or saving all frames to TIFF, PDF or WebP can reach it. Opening, loading, thumbnailing, converting, is_animated and ImageSequence iteration do not hang on this file. The call never returns and raises no exception, so only an external watchdog or timeout stops it. The fix ensures n_frames, once set, is not reset.
Unbounded PDF recursion (CVE-2026-112391)
The advisory explains that a recursion-depth guard in PdfParser.get_value() never actually fired, so a deeply nested PDF object can raise an uncaught RecursionError or terminate the worker. Pillow cannot open PDFs for reading through Image.open(); the parser is only reached when saving with PDF format and append=True onto an existing file, for example when stamping or watermarking a document. The advisory rates confidentiality and integrity impact as none. The fix sets a default nesting limit of 900.
Who is realistically exposed
- Upload-handling sites and APIs that let users influence image dimensions or transform parameters, especially on workers with memory limits or 32-bit processes.
- Services that read n_frames or save multi-frame images from untrusted files while olefile is installed.
- Document tools that append image pages to PDFs supplied by users.
- Pipelines that only use resize(), thumbnail() or rotate() and never append to PDFs are far less exposed, but updating is still the simplest answer.
All three are primarily availability problems: crashed or stuck workers. For a small site this can mean failed uploads or exhausted worker pools. The research reports no in-the-wild exploitation, and only one independent publisher (the Pillow project's own advisories) covers this so far, so treat details as vendor-reported.
How to check your exposure
Run this in the same Python environment your application uses. It prints the installed Pillow version; anything below 13.0.0 is affected by at least two of the flaws.
python -m pip show PillowThis shows whether olefile is installed, which determines exposure to the MIC loop. An error saying the package was not found means it is not installed in that environment.
python -m pip show olefileThen search your own code for the risky calls so you know which flaws apply. Matches mean the code path exists, not that it is exploitable.
grep -rnE "\.transform\(|n_frames|append=True|save_all" --include=*.py .What to do now
- Find every environment that installs Pillow (web apps, background workers, containers, CI images) and note the versions.
- Upgrade to 13.0.0 or later with pip and rebuild any container images that pin an older version.
- Restart application workers so the new library is loaded.
- Check that your Python version is supported by 13.0.0 (Python 3.10 support was dropped).
- If you cannot upgrade immediately, validate or cap user-supplied output sizes before calling Image.transform(), avoid reading n_frames on untrusted MIC files, and do not append to user-supplied PDFs.
- Set request timeouts and a worker watchdog so a hung worker is killed and replaced.
- If you get Pillow from a distribution package instead of pip, check your vendor for an updated package that includes these fixes.
Upgrade command for pip-managed environments, run inside the application's virtualenv:
python -m pip install --upgrade PillowFor the confirmation step, re-run the version check above and look for 13.0.0 or higher.
Detection and monitoring afterwards
Because these bugs cause crashes and hangs rather than data theft, the signs are operational. Watch for workers killed by SIGSEGV after a MemoryError, processes pinned at 100% CPU that never finish an image job, and RecursionError entries in logs near PDF-append code. A sudden pattern of crashes tied to one uploader or IP address is worth investigating.
Keep dependencies current as a routine: track Pillow in your dependency scanner and subscribe to the project's advisories. For uptime visibility on public endpoints, a service such as Webforta Monitor can alert you when a site stops responding, and the uptime monitoring guide explains what to watch. For broader hygiene, see the small business website security guide.
Timeline
- Oct 16: Pillow 13.0.0 released (per the release page, which shows no year).
- Oct 17, 2026: GitHub advisories published in the Pillow repository.
- Oct 19, 2026: The three CVE records are listed as published.
- Oct 21, 2026: GitHub advisories updated and reviewed.
Sources
This article is based on the public sources below. Details can change as vendors and researchers publish more; check the original advisories before acting on version numbers.
- CVE-2026-112402 - GitHub Advisory Database
- Avoid double free after affine transform allocation failure · python-pillow/Pillow@aafa6c7
- Release 13.0.0 · python-pillow/Pillow
- CVE-2026-112390 - GitHub Advisory Database
- Do not change MicImageFile _n_frames or is_animated in TiffImageFile … · python-pillow/Pillow@26cb3ed
- CVE-2026-112391 - GitHub Advisory Database
- Set PdfParser default max_nesting limit to 900 (#10127) · python-pillow/Pillow@94cb11c
