Ghostscript -dSAFER bypass CVE-2026-125396 turns uploads into RCE
Ghostscript before 10.08.0 has a -dSAFER sandbox-escape (CVE-2026-125396, CVSS 8.5). A crafted file routed through ImageMagick, Pillow or a print queue runs code. Update to 10.08.0.
Ghostscript versions before 10.08.0 contain a -dSAFER bypass that leads to a use-after-free and arbitrary code execution, tracked as CVE-2026-125396. Security firm pwn.ai demonstrated reaching it remotely — through print jobs, webmail and public upload forms — in an attack chain it calls "upload2shell." The primary write-up is pwn.ai's impact index and technical analysis; the VulnCheck advisory scores it 8.5 (CVSS v4.0). Artifex shipped the fix in 10.08.0 on September 8.
What the bug does
The flaw is in .putgstringcopy in gs_fonts.ps, which calls the privileged .forceput operator without checking operand types. A crafted PostScript or PDF document triggers a type error, recovers .forceput through a custom error handler, and provokes a use-after-free across save/restore — enough to disable the -dSAFER sandbox that is supposed to stop documents from running commands or touching files. The result is command execution as the low-privilege account doing the rendering.
NVD classifies the CVE as local (AV:L), but that undersells it. Ghostscript sits downstream of libraries that silently hand it PostScript/EPS content — ImageMagick, Pillow, libvips and a Qt plugin among them — so a file named .png, .jpg or .pdf can still reach the interpreter.
Where a reader will meet it
pwn.ai tested roughly ten applications and reached code execution over the network in several, with no login required:
- An anonymous print job to a shared Debian 13 queue.
- Roundcube webmail, when the recipient merely opened a message with an attachment.
- Public upload forms in the WordPress plugins Forminator and Essential Addons for Elementor.
- WordPress core, which needs an account that can upload files (Author role or higher by default). WordPress patched its end of the chain, CVE-2026-65640, in 7.0.4 on August 12.
A public proof-of-concept exists but demonstrates only the memory-corruption primitive, not a full shell; on 10.08.0 it fails before that point. No in-the-wild exploitation has been reported.
Action checklist
- Update Ghostscript to 10.08.0 or later against the upstream bug report. Check your distro: pwn.ai lists Debian 12 as vulnerable, Amazon Linux and SUSE fixes pending, and openSUSE Leap 16.0/16.1 affected.
- Patch every bundled copy — container images and apps often ship their own Ghostscript that an OS update won't touch.
- Update WordPress to 7.0.4+ and audit Forminator / Essential Addons upload endpoints.
- Require authentication on print queues and restrict the file types image processors accept.
- Confine the renderer: in one pwn.ai test, an AppArmor profile stopped the compromised interpreter from spawning a shell.
Context
This is the latest in a long line of -dSAFER escapes — the sandbox has been bypassed repeatedly because, as Ghostscript maintainer Ken Sharp noted on the bug report, the font code is "an ancient piece of code well known to be a vulnerability, but difficult to eradicate." The lesson for operators is the same each time: -dSAFER is a hardening layer, not a boundary. If untrusted documents reach Ghostscript, assume they can reach a shell, and put a real sandbox — AppArmor, seccomp, a container with no egress — around the process.