Upload2Shell: The Ghostscript Flaw Turning File Uploads Into Remote Shells
A font file that talks its way out of a sandbox
For almost three decades, Ghostscript has quietly sat behind some of the most common document-handling features on the internet. It is the interpreter that converts PostScript and PDF files into images, thumbnails, and print jobs — and it rarely runs on its own. Instead, it gets invoked indirectly, through ImageMagick, Pillow, CUPS, Imagick-based WordPress media processing, and dozens of other libraries that treat it as a trusted black box.
That trust just took a serious hit. On November 17, 2026, security researcher Paulos Yibelo of pwn.ai published "Upload2Shell," a write-up detailing CVE-2026-125396 — a sandbox-escape vulnerability in Ghostscript's -dSAFER protection that lets a single crafted document execute arbitrary commands on the server that renders it. The flaw affects every Ghostscript release before version 10.08.0, which Artifex quietly shipped on September 8, 2026. The CVE itself was not published until November 9, and public, weaponizable detail did not land until pwn.ai's research a week later — leaving a long window where defenders had no name for the bug they needed to patch.
The technical mechanism
-dSAFER is Ghostscript's built-in sandbox. It is supposed to stop PostScript or PDF content from reading or writing arbitrary files, or from invoking shell commands, even though the interpreter itself is a full programming language. CVE-2026-125396 breaks that promise through a chain of small mistakes in .putgstringcopy, a procedure defined in Resource/Init/gs_fonts.ps:
- A malicious document registers a crafted Type 1 font. When Ghostscript's font loader processes it,
.putgstringcopycalls the privileged.forceputoperator — an internal primitive that can write into protected system dictionaries — without validating the types of its operands. - The attacker engineers the call so that
copyraises atypecheckerror partway through. - A custom error handler, installed earlier in the document, catches that error and rearranges the operand stack so execution resumes inside
.forceputwith attacker-chosen dictionary, key, and value arguments. - A reference to a local object is kept alive inside a global dictionary across a
save/restoreboundary. When the local allocation is later reused, this produces a classic use-after-free. - With a resulting read/write primitive over Ghostscript's own memory, the exploit walks internal pointers and flips two flags:
path_control_activeand the PostScript-sidePermitFileWriting. - With those flags disabled,
-dSAFERis still present on the command line, but its actual file-path enforcement has been switched off in memory. The document can now write to the filesystem and invoke a shell through Ghostscript's%pipe%device — the device the sandbox exists specifically to block.
VulnCheck, acting as the CVE Numbering Authority, tracks the bug under CWE-648 (Incorrect Use of Privileged APIs) and rates it CVSS 4.0: 8.5 (High), vector AV:L/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N, alongside a CVSS 3.1 score of 7.8. Both scores list a local attack vector — a quirk of how CVSS models the interpreter process itself, even though pwn.ai's demonstrations reached that process over the network through ordinary web and mail features.
Why "local attack vector" is misleading in practice
The CVSS vector describes the Ghostscript process as the attacked machine, but the practical reach of this bug is anything but local. pwn.ai demonstrated the technique against roughly ten real-world products that invoke Ghostscript indirectly, including:
- WordPress, via the Imagick/ImageMagick media-thumbnail pipeline and the Forminator and Essential Addons for Elementor upload widgets — both reachable without any login.
- Roundcube webmail 1.7.2, triggered the instant a recipient opens an email with a crafted attachment, no click required.
- CUPS print queues on Debian 13, where an unauthenticated network print job ran a command as the
lpprint-service account.
In each case, an attacker never talks to Ghostscript directly. They upload a file, send an email, or submit a print job to an application that happens to call Ghostscript somewhere in its processing chain — and the malicious document does the rest. pwn.ai has so far published only a memory-corruption proof-of-concept that demonstrates the write-what-where primitive without executing a command; the per-application exploit chains for WordPress, Roundcube, and CUPS remain unpublished, but the researchers' description is detailed enough that reproduction by a motivated attacker is plausible.
Patch status: better at the application layer than the OS layer
Artifex fixed the root cause in Ghostscript 10.08.0, released September 8, 2026, roughly two months before the CVE was assigned a public identifier. That gap matters: distribution-level patching has been uneven.
- Debian shipped DLA-4914 for Debian 12 on November 17, closing the gap for that release.
- A pwn.ai distribution survey found Amazon Linux 2, Amazon Linux 2023, and the Amazon Linux 2027 preview still shipping a vulnerable Ghostscript as of last week, with fixes still pending on parts of SUSE.
- Critically, patching the host operating system's Ghostscript package does not touch a copy bundled inside a container image, a Flatpak, a Python virtual environment (via
ghostscript-wrapping libraries), or a vendored binary shipped with a commercial document-processing product. Each of those needs its own update.
No exploitation in the wild has been confirmed, and the flaw is not in CISA's Known Exploited Vulnerabilities catalog as of November 21, 2026. That is a narrow window to act in, not a reason to wait.
Remediation checklist
- Patch Ghostscript to 10.08.0 or later everywhere a copy exists: base OS packages, container base images, Flatpak runtimes, Python virtualenvs that pull in
ghostscript/camelot/similar wrappers, and any vendored binary inside commercial software. - Inventory every document pipeline, not just obvious ones. Any feature that previews, converts, prints, or generates a thumbnail from an uploaded PDF, PostScript, or EPS file is a candidate: media libraries (WordPress/Imagick), webmail attachment previews (Roundcube and similar), shared print services (CUPS), and PDF-to-image conversion microservices.
- Restrict CUPS exposure. Unauthenticated network printing should not be reachable from untrusted networks. Require authentication or network-level restrictions on print queues that process attacker-supplied files.
- Harden beyond
-dSAFER. Treat the flag as defense-in-depth, not a guarantee. Run Ghostscript-invoking services inside containers or sandboxes (seccomp, AppArmor, gVisor) with no filesystem write access and no ability to spawn subprocesses, so that even a successful sandbox bypass inside Ghostscript cannot reach a real shell. - Monitor for indicators. Unexpected child processes spawned by
gs,convert,identify,cupsd, or PHP-FPM workers handling media uploads are a strong signal worth alerting on, given how directly this bug maps to process spawning via%pipe%. - Re-test after patching. Because the vulnerable code lives in a PostScript-language resource file (
gs_fonts.ps) rather than purely in compiled C code, confirm the patched version is actually loaded at runtime — some deployments override or cache resource files independently of the binary version.
The bigger lesson: trusted format parsers are attack surface
Upload2Shell is a reminder that "trusted" document conversion utilities are some of the most under-scrutinized attack surface in modern infrastructure. Ghostscript has existed since 1988 and underpins an enormous share of PDF and print tooling across Linux distributions, yet a core sandbox bypass survived undiscovered for years, reachable through features — thumbnail previews, email attachments, shared printers — that most security teams don't think of as attacker-facing at all.
Any organization running document upload, email attachment preview, or shared printing infrastructure should treat Ghostscript version auditing as an immediate priority, independent of whether their base OS vendor has shipped a patch yet. The attack surface here isn't a rare edge case — it's the default behavior of some of the most widely deployed web applications in production today.