Ghostscript Upload2Shell (CVE-2026-125396): -dSAFER Sandbox Escape to Pre-Auth RCE

On 21 November 2026, security researcher Paulos Yibelo (@PaulosYibelo) of pwn.ai publicly published Upload2Shell, the technical writeup behind CVE-2026-125396: a use-after-free in Ghostscript's Type 1 font loader that escapes the interpreter's -dSAFER sandbox and executes attacker-chosen commands as the rendering process. The demonstrated chains are pre-authentication remote code execution through Debian 13 CUPS over anonymous IPP print jobs, through email thumbnails in Roundcube where the victim never clicks the attachment, and through signed-out upload forms in WordPress plugins. Google's production image and document pipeline was confirmed reachable and has since been fixed. Ten products or shipped components record completed proofs with repeat-trial evidence.
To be clear about provenance: IKZERO did not discover this vulnerability. All discovery, exploitation, and disclosure work belongs to pwn.ai, with the flaw in .putgstringcopy credited to GPT 5.6 Sol working with Yibelo, and the upstream fix authored by Artifex Software under Bug 709684. This is our technical read of the disclosure, our line-by-line review of the published proof of concept, and guidance for teams who ship document-processing software.
The bug in three layers
Ghostscript executes PostScript, which is a programming language, and -dSAFER is not a kernel boundary like seccomp: it is checks enforced by the interpreter's own internal state. Any memory-corruption bug in the interpreter is therefore a sandbox escape by construction. CVE-2026-125396 is not one bug but three composed ones, each individually survivable.
Layer 1 — the recovered privileged store. Parts of font loading are written in PostScript, in a helper marked executeonly that uses .forceput, an internal operator that can write into protected dictionaries documents must never touch. The helper runs dup length string copy before its .forceput without type-checking the operand. A malicious font forces that copy to fail with a typecheck error inside the helper, and a document-installed error handler rearranges the helper's operand stack so execution resumes at .forceput with attacker-chosen dictionary, key, and value. The document now holds a privileged write it was never supposed to reach.
Layer 2 — the use-after-free. PostScript's .forceput implementation temporarily marks the global systemdict as local while storing. A local object can therefore pass the store check into a dictionary that survives restore. The exploit stores a local 2,048-byte string into systemdict, restores, and the dictionary keeps a reference into freed memory.
Layer 3 — ref forging to native memory. PostScript value cells (refs) are 16 bytes: eight of type metadata, eight of value-or-pointer. Heap-spray arrays filled with the marker 0x12345678 locate the freed region by a differential byte-flip probe — no address guessing, no ASLR defeat needed. The dangling view then rewrites a live ref's type header into a string over a harvested native pointer, producing arbitrary memory read/write through ordinary PostScript get/put. A pointer walk over Ghostscript's own structures (gx_device → gs_memory_t → gs_lib_ctx → core+156) lands on path_control_active.
How the exploit reaches command execution
The published PoC (104 lines, self-contained, archived and reviewed line by line by IKZERO) proves native control reversibly: it overwrites the live mul operator's C function pointer with sub's, computes 29 × 11 = 18 while hijacked, and restores — with -dSAFER still on the command line. The full chain adds three writes: PermitFileWriting forced to [ (*) ] through the layer-1 primitive, four zero bytes over path_control_active, and the cached LockFilePermissions flag forced to false. Then (%pipe%command) (w) file executes a shell command as the renderer's account — uid=7(lp) on the Debian CUPS print server, uid=33(www-data) on Roundcube and WordPress targets.
The delivery requires nothing exotic. Ghostscript sits beneath thumbnail generation, preview, cropping, and print conversion, and format dispatch is loose enough that PostScript bytes in a file named .jpg or .pdf arrive intact. Confirmed chains include anonymous IPP Print-Job to a shared CUPS queue (pre-auth, network), an emailed attachment thumbnailed when the recipient merely views the message (Roundcube 1.7.2), signed-out PDF form uploads (Forminator 1.55.1), a public registration widget upload (Essential Addons for Elementor 6.7.0), anonymous wiki uploads (MediaWiki 1.46.0 PdfHandler, DokuWiki), email-driven document import (Mayan EDMS 4.11.5), ResourceSpace, Plesk Obsidian's shipped Roundcube stack against a 2021-era Ghostscript 9.54.0, and Google's production pipeline, mitigated 10 November 2026.
One exposure class deserves its own callout for our audience: AI-application upload paths. The pwn.ai index documents, at pinned source revisions, that Gradio, AUTOMATIC1111 Stable Diffusion WebUI, ComfyUI, InvokeAI, Frappe, Home Assistant, CVAT, Paperless-ngx, and django-filer all route uploads through Pillow — and Pillow's EPS decoder shells out to Ghostscript when one is installed. In Gradio's case the route is confirmed by live trace: gs -dSAFER started during framework preprocessing, before the application's own code ran, on an unauthenticated image submission. Publicly shared demo links and default-bound ML tooling make this a large population of pre-auth file-processing endpoints.
Verification notes
IKZERO performed a static, line-by-line review of the official PoC and cross-checked every stage against the published writeup. The PoC is exactly what it claims: PostScript bytes in a .pdf name (the disguise is part of the technique), font staged to the process-local %ram% device so no server-side font file is needed, marker constants 0x12345678/0x12345679 consistent with the 16-byte ref granularity, and clean failure exits (NO_OVERLAP, NO_ALIAS) on patched builds — 10.08.0 fails the dangling-reference lookup before any pointer write. We did not execute it; our verification host runs no Ghostscript, and the PoC's structure offsets are x86-64-Linux-specific. The dynamic reproductions, with recorded 5/5 trial counts per target, remain the original researchers'. The complete weaponized RCE script is unpublished; the Debian CUPS case study is announced as the series' first full PoC release.
Am I affected?
You are affected if the Ghostscript binary your application actually executes predates 10.08.0 or the distribution backport. The trap: host patching does not patch containers, appliance bundles, or application-shipped interpreters — Plesk Obsidian 18.0.79 shipped Ghostscript 9.54.0, and Mayan EDMS runs the interpreter inside its container. As of the researchers' 12 November data, Debian 12 Bookworm still listed a vulnerable package, Amazon Linux 2/2023/2027-Preview a pending fix, and several SUSE 12/15/16 branches were in progress; RHEL-family status was unestablished. Version numbers lie in both directions — backported fixes ship in old-looking versions, and a fixed host package does not fix a bundled one. Inventory per container: find / -name gs -type f -exec {} --version \;.
What to do
Patch the exact gs binary in every container image and bundle to 10.08.0 or a distro backport, then rebuild and redeploy images. Break the delivery chain regardless of interpreter state: deny the PostScript family in ImageMagick's policy.xml (PS,PS2,PS3,EPS,EPSI,EPSF,EPI,EPT,PDF,XPS with rights="none"), and treat "Pillow-validated image upload" as insufficient — Pillow's EPS decoder invokes Ghostscript if present. Adopt Roundcube's fix pattern (CVE-2026-114727): verify a file's real type before any thumbnail or conversion step, because Image.open() only identifies while load(), crop(), and thumbnail() summon the renderer. Close the network entries: no anonymous CUPS queues, and audit public upload forms that trigger media-library metadata generation — they are pre-auth file-processing endpoints. Contain the renderer under a mandatory-access-control profile: in pwn.ai's Plesk test, AppArmor blocked the shell even after full interpreter compromise. Detection: gs with -dSAFER spawning shells or writing outside spool directories, renderer UIDs (lp, www-data) executing shell builtins, PostScript markers (%!PS, %pipe%, Fontmap) in image-typed uploads, and any gs process spawned by Python web workers.
How Ikzero can help
Our penetration testing team can inventory Ghostscript reachability across your estate — including the container and AI-application paths most reviews miss — our DevSecOps practice can drive image rebuilds and policy hardening with verification, and our SOC service can deploy the renderer-anomaly detections described above.


