{"slug": "ghostscript-s-font-bug-reached-10-apps-through-a-png", "title": "Ghostscript's font bug reached 10 apps through a `.png`", "summary": "Security researchers at pwn.ai, working with Paulos Yibelo, disclosed CVE-2026-125396, a use-after-free in Ghostscript's Type 1 font loader that yields pre-auth remote code execution past the -dSAFER sandbox. The flaw in the .putgstringcopy helper lets a PostScript-bearing file reach Ghostscript through ten applications, with confirmed execution against Debian 13 CUPS, Roundcube, WordPress plugins, MediaWiki, and Google's document pipeline. The writeup credits the discovery to \"GPT 5.6 Sol, working with @PaulosYibelo.", "body_md": "`.png`\nA file named `.png` that contains PostScript can reach Ghostscript from ten different applications — and a use-after-free in Ghostscript's Type 1 font loader turns that into remote code execution, past the `-dSAFER` sandbox. CVE-2026-125396, published November 9. Pre-auth RCE was confirmed against Debian 13's CUPS, Roundcube, WordPress, and Google's own document pipeline.\n\nThe writeup is from pwn.ai (\"How We Hacked the Pipes\"), and it is unusually complete. The flaw is in `.putgstringcopy`, a helper in Ghostscript's `Resource/Init/gs_fonts.ps` that loads Type 1 fonts. Ghostscript implements parts of its own font loading in PostScript, and this helper needed to write into protected font dictionaries, so it used an internal operation called `.forceput`. The relevant sequence in the vulnerable version:\n\n```\ndup length string copy\n.forceput setglobal\n```\n\nThe helper never checked that its operands were of the expected types. The researchers registered a Type 1 font in `Fontmap`, loaded it with `findfont`, and used the font's loading code to swap the filename string on the loader's operand stack for a local array. `length` and the string allocation succeeded; `copy` then raised `typecheck` because its source was an array. Their error handler returned with the stack prepared for the *next* operation in the already-bound helper — the privileged `.forceput` — with attacker-chosen dictionary, key, and value on the stack. They never called the hidden operator directly; the error did the calling for them.\n\nA protected dictionary write alone is not native code execution. The next step broke a separate rule: a reference must not remain usable after its object has been reclaimed. `.forceput` temporarily treats `systemdict` as local while it stores the value, so the researchers could put a local array into a global dictionary that survives a later `restore`. After `restore` freed the local object, the dictionary still pointed at the storage — and reusing the allocation made the stale reference point at live interpreter memory. Their probe made the reuse visible before touching native memory:\n\n```\n/AttackSave save def\nuserdict /ForceValue 8 array put\nuserdict /ForceValue get 0 31337 put\n{ /GSLoaderProbe findfont pop } stopped pop\nAttackSave restore\n8 array userdict exch /Replacement exch put\nuserdict /Replacement get 0 4242 put\nsystemdict /GS_FORCEPUT_DANGLING_ARRAY get 1 5151 put\nuserdict /Replacement get 1 get ==\n```\n\nIf the freed allocation is reused, `Replacement[1]` reads `5151` — the write went through the stale reference, the read came back through the live one. Same bytes, two names. From there the native proof walks Ghostscript's own pointers (`currentdevice` → `psi_device_ref` → `gx_device` → `gs_memory_t` → `gs_lib_ctx` → `path_control_active`) and flips the flag that enforces `-dSAFER`. The sandbox is a check inside the interpreter, not a kernel filter — once you control interpreter memory, the check is just a byte.\n\nOne detail worth noting: the writeup credits the discovery to \"GPT 5.6 Sol, working with @PaulosYibelo.\" An AI model found the bug; the humans built the exploit chain around it. The Ubuntu advisory names Paulos Yibelo as the discoverer of the operand-validation flaw.\n\nThe researchers' index records ten application chains where execution was confirmed, not just theorized. The file never had to be a font or a PostScript document — it only had to reach a renderer:\n\n```\nDebian 13 CUPS        anonymous IPP print job to a shared queue   command as uid=7(lp)            20/20 local conversions\nRoundcube 1.7.2       external sender; recipient views message    command as uid=33(www-data)     5/5 trials, no click\nForminator 1.55.1     signed-out public PDF form, WP 7.0.2        command as uid=33(www-data)     5/5 HTTP trials\nElementor Addons 6.7  signed-out login/register widget upload     command as uid=33(www-data)     5/5 HTTP trials\nMediaWiki 1.46        anonymous PDF upload + thumbnail            command as uid=33(www-data)     5/5 HTTP trials\nDokuWiki 2026-07-14  open wiki upload + resize                   command as uid=33(www-data)     5/5 HTTP trials\nMayan EDMS 4.11.5     email to a configured POP3 inbox            command as uid=1000 in container 1 email run; parser 5/5\nResourceSpace 11.0    authenticated upload / upload-share         command in the preview worker    5/5 API trials\nWordPress Core        Author+ upload_files, Imagick + Ghostscript RCE confirmed, exact delegate as uid=33  10/10 trials\nPlesk Obsidian 18     Roundcube thumbnail path, Ghostscript 9.54  command as uid=995(roundcube_sysuser) 5/5 trials\n```\n\nRoundcube is the one that should worry you: no attachment click, no login — an external sender's email gets thumbnailed when the recipient views the message, and the thumbnail path runs the proof as `www-data`. WordPress Core needed `upload_files` (Author+ by default), and the affected branches were 7.0.0–7.0.3 and 6.9.0–6.9.6; WordPress shipped its own fix as CVE-2026-65640. Google's image and document pipeline was reached with a signed-out request for an attacker-hosted file and mitigated November 10. Dropbox, Box, and Zoom are named in the teaser as reached; their individual case studies are still unpublished.\n\nThe common thread is not Ghostscript — it is the decoders in front of it. The researchers traced 145 benign calls across 29 image APIs. The ones that reached Ghostscript when handed EPS content, even named `.png`:\n\n``` php\nPillow Image.load() / crop()          Pillow EPS decoder -> Ghostscript directly\nimageio.imread() / skimage.io.imread() image reader -> Pillow -> Ghostscript\nPHP Imagick::readImage()              ImageMagick PostScript delegate -> Ghostscript\nlibvips thumbnail()                   magickload -> ImageMagick -> Ghostscript (build dependent)\nQt QImageReader.read()                KImageFormats EPS plugin -> Ghostscript (plugin dependent)\n```\n\nPHP GD, OpenCV, prebuilt Sharp, Jimp, Java ImageIO, and Go's standard decoders did not start Ghostscript for these inputs. Copying or storing a file did not render it either — the later preview or conversion is the step to inspect. `Image.open()` alone only identifies the file; loading pixels is what starts the renderer.\n\nI did not run the exploit — the proof-of-concept is not public and the writeup omits the font setup. What I ran is the route, on a stock Ubuntu 24.04 box with nothing pre-installed:\n\n``` bash\n$ apt-get install -y ghostscript\n$ gs --version\n10.02.1\n```\n\nFirst, the version question. Ubuntu's USN-8949-1 (October 21) lists exactly `10.02.1~dfsg1-0ubuntu7.10` as the fixed build for 24.04 noble — the version apt just installed. The vulnerable versions in the researchers' index were 10.05.1 (Debian 13, WordPress, Roundcube), 10.05.0 (Google), and 9.54.0 (Plesk). Upstream fixed it in 10.08.0 on September 8; Debian shipped `10.05.1~dfsg-1+deb13u3` on October 10.\n\nSecond, the fix itself, visible in the installed file. The patched `.putgstringcopy` in `/usr/share/ghostscript/10.02.1/Resource/Init/gs_fonts.ps` opens with the check the writeup says was missing:\n\n```\n/.putgstringcopy  %   <dict> <name> <string> .putgstringcopy -\n{\n  % Check operand types\n  dup type /stringtype eq 2 index type /nametype eq and 3 index type /dicttype eq and {\n    ...\n      dup length string copy\n      .forceput setglobal\n    ...\n  }\n  {\n      /.putgstringcopy cvx /typecheck signalerror\n  } ifelse\n} .bind executeonly odef\n```\n\nSame two lines — `dup length string copy`, `.forceput setglobal` — but now they only run after the operand types are verified, and a wrong type signals `typecheck` immediately, before any partial state exists for an error handler to resume into. The fix is a type check, not a sandbox redesign. That is the whole patch, and you can read it in a file your distro already ships.\n\nThird, the Pillow route, end to end. I wrote a 100×100 EPS file, named it `fake.png`, and ran the exact call pattern from the writeup with Pillow 10.2.0:\n\n``` python\n$ python3 -c \"from PIL import Image; im = Image.open('fake.png'); im.load()\"\nformat: EPS size: (100, 100)\nPillow load OK, mode: RGB\n```\n\nPillow trusts the bytes, not the name — it identified EPS content under a `.png` name and rendered it. To prove Ghostscript was the renderer and not something else, I hid `gs` from the PATH and ran the same code again:\n\n```\nload FAILED without gs: OSError Unable to locate Ghostscript on paths\n```\n\nSame file, same calls, only `gs` missing: the load fails. The route is live on this machine with the patched Ghostscript underneath it — which is exactly the configuration the researchers' matrix describes.\n\nFourth, the sandbox itself, on the patched build. A PostScript file that tries to read `/etc/passwd`:\n\n``` bash\n$ gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=txtwrite -sOutputFile=- safer_probe.ps\nError: /invalidfileaccess in --file--\n```\n\n`-dSAFER` holds. The point of Upload2Shell is that the sandbox was never the weak part — the font loader was. A memory-safety bug in the interpreter lets an untrusted document rewrite the flag the sandbox checks, and then the sandbox is a byte that says yes.\n\nUpdate Ghostscript. The fixed versions: upstream 10.08.0, Debian `10.05.1~dfsg-1+deb13u3`, Ubuntu USN-8949-1 (noble: `10.02.1~dfsg1-0ubuntu7.10`). Then audit the route, not the extension: any upload path that thumbnails, previews, crops, or converts images can hand EPS bytes to Ghostscript regardless of the filename. If your stack renders user-supplied images with Pillow, ImageMagick, libvips, or Qt image readers, the question is not \"do we accept PostScript\" — it is \"does our decoder reach Ghostscript.\" The researchers' matrix is the checklist: Pillow, imageio, Imagick, libvips, and Qt's EPS plugin do; GD, OpenCV, Sharp, Jimp, Java ImageIO, and Go's standard decoders do not.\n\n`0x12345678`), and the structure offsets are the researchers', from their writeup.\nSources: [pwn.ai, \"How We Hacked the Pipes — Upload2Shell\" (technical writeup)](https://pwn.ai/upload2shell/research.html); [pwn.ai, \"Upload2Shell · CVE-2026-125396\" (evidence index)](https://pwn.ai/upload2shell); [Ubuntu USN-8949-1: Ghostscript vulnerabilities](https://ubuntu.com/security/notices/USN-8949-1) (Oct 21, 2026); [CVE-2026-125396](https://www.cve.org/CVERecord?id=CVE-2026-125396). All local results are from my own Ubuntu 24.04 machine, November 21, 2026.", "url": "https://wpnews.pro/news/ghostscript-s-font-bug-reached-10-apps-through-a-png", "canonical_source": "https://dev.to/frankchu/ghostscripts-font-bug-reached-10-apps-through-a-png-jgb", "published_at": "2026-11-22 00:40:00+00:00", "updated_at": "2026-11-22 00:41:40.525001+00:00", "lang": "en", "topics": ["ai-safety", "ai-research"], "entities": ["Ghostscript", "pwn.ai", "Paulos Yibelo", "GPT 5.6 Sol", "Debian", "CUPS", "Roundcube", "WordPress"], "also_reported_by": [], "takeaway": "A typecheck error inside Ghostscript's .putgstringcopy font helper left a privileged .forceput on the stack, and pairing that protected-dictionary write with a use-after-free after restore let researchers flip path_control_active and defeat -dSAFER.", "recommendation": {"advice": "Treat any file reaching a renderer as hostile: patch Ghostscript past CVE-2026-125396 and audit PostScript/Type 1 font handling in CUPS, webmail and CMS upload paths.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/ghostscript-s-font-bug-reached-10-apps-through-a-png", "markdown": "https://wpnews.pro/news/ghostscript-s-font-bug-reached-10-apps-through-a-png.md", "text": "https://wpnews.pro/news/ghostscript-s-font-bug-reached-10-apps-through-a-png.txt", "jsonld": "https://wpnews.pro/news/ghostscript-s-font-bug-reached-10-apps-through-a-png.jsonld"}}