79% vs 51%: independent neobanks lag on app security. Read the report

Deep Dive

Deep Dive

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

A crafted document escapes Ghostscript's -dSAFER sandbox through a font-loader use-after-free and runs commands; fixed in 10.08.0.

TL;DR

  • A use-after-free in Ghostscript's Type 1 font loader lets a crafted document run commands despite -dSAFER. pwn.ai's Paulos Yibelo published Upload2Shell.
  • Every Ghostscript release before 10.08.0 is affected. Applications that render uploaded PDF, PostScript or EPS files reach the flaw through ImageMagick, Pillow, CUPS and similar pipelines.
  • The CVE record rates it High, CVSS v4.0 8.5. A public proof demonstrates native memory control, and the command chain is described. No in-the-wild exploitation is known, and it is not in CISA KEV as of 2026-11-21.
  • Upgrade Ghostscript to 10.08.0 or the fixed package your distribution ships. Update the copies inside container images and application bundles too. See "How do I fix it?" for the renderer-level workarounds.

Am I affected?

All of these must hold:

  • A Ghostscript build older than 10.08.0, or a distribution package without the backported fix, processes the file.
  • An attacker can deliver a PostScript, EPS or PDF document to a path that reaches that build. Upload, preview, thumbnail, document import and print conversion are common paths.
  • The document is processed as a document, not merely stored or copied.

Direct use of gs is not required. ImageMagick, Pillow, libvips, CUPS, Ghostscript's library embedding and many document converters start the interpreter for you. The flaw is in the interpreter, so every route that reaches it carries the same primitive.

Branch Affected versions Fixed version
Ghostscript upstream Before 10.08.0 10.08.0
Debian 13 (trixie) Before 10.05.1~dfsg-1+deb13u2 10.05.1~dfsg-1+deb13u2, current security build +deb13u3
Debian 12 (bookworm) Before 10.0.0~dfsg-11+deb12u9 10.0.0~dfsg-11+deb12u9
Debian 14 and unstable Before 10.08.0~dfsg-2 10.08.0~dfsg-2
Ubuntu 26.10 Before 10.07.1~dfsg-1ubuntu2.1 10.07.1~dfsg-1ubuntu2.1
Ubuntu 26.04 LTS Before 10.06.0~dfsg-3ubuntu1.2 10.06.0~dfsg-3ubuntu1.2
Ubuntu 24.04 LTS Before 10.02.1~dfsg1-0ubuntu7.10 10.02.1~dfsg1-0ubuntu7.10
Ubuntu 22.04 LTS Before 9.55.0~dfsg-1ubuntu5.15 9.55.0~dfsg-1ubuntu5.15
Ubuntu 20.04 LTS (Pro) Before 9.50~dfsg-5ubuntu4.15+esm3 9.50~dfsg-5ubuntu4.15+esm3
Ubuntu 18.04 LTS (Pro) Before 9.26~dfsg+0-0ubuntu0.18.04.18+esm6 9.26~dfsg+0-0ubuntu0.18.04.18+esm6
Ubuntu 16.04 LTS (Pro and Legacy) Before 9.26~dfsg+0-0ubuntu0.16.04.14+esm11 9.26~dfsg+0-0ubuntu0.16.04.14+esm11

The Ubuntu rows are the fixed package versions in USN-8949-1. Older version numbers can contain a backported fix, so compare with the advisory rather than with the upstream version alone. The Debian rows come from the Debian security tracker.

Check the interpreter on the host:

gs --version
dpkg-query -W -f='${Version}\n' ghostscript    # Debian and Ubuntu
rpm -q ghostscript                             # RHEL, Fedora and derivatives
apk info -v ghostscript                        # Alpine
brew list --versions ghostscript               # macOS
gswin64c --version                             # Windows

Check the copy inside each container that processes files. A rebuilt image does not replace a running container:

docker exec <container> sh -c 'command -v gs && gs --version'

Check which programs on the host delegate to Ghostscript:

magick -list delegate | grep -i -E 'gs|ghostscript'

How do I fix it?

Upgrade Ghostscript to 10.08.0 or later, or install the fixed package for your distribution. Then update every copy that the application actually uses.

  1. On Debian and Ubuntu, run sudo apt-get update && sudo apt-get install --only-upgrade ghostscript.
  2. On RHEL, Fedora and their derivatives, run sudo dnf upgrade ghostscript.
  3. On Alpine, run sudo apk upgrade ghostscript.
  4. On macOS, run brew upgrade ghostscript. On Windows, install the 10.08.0 build from Artifex.
  5. Rebuild and recreate each container that bundles Ghostscript. Pulling a new image does not replace the running container.
  6. Update the renderer inside application bundles and document workers. A patched host does not patch a Ghostscript copy shipped in an image or an application directory.
  7. Confirm the running version with the checks in "Am I affected?".

WordPress sites also need the application-layer fix. WordPress 7.0.4 fixed CVE-2026-65640, which let an Author or a Contributor with upload_files reach the renderer. The fix was backported to older branches back to 4.7. That change narrows one route. It does not fix Ghostscript itself.

If you cannot upgrade yet:

  1. Disable the Ghostscript delegate in ImageMagick with a policy that sets rights="none" for the gs delegate. This blocks one route and leaves direct gs use exposed.
  2. Reject PostScript, EPS and PDF uploads that do not need rendering, or convert them in a separate service with no shell and no network.
  3. Run the renderer as an unprivileged account with a restrictive seccomp or AppArmor profile, so a successful escape has less to reach.
  4. Require authentication on CUPS shared queues. The Debian 13 proof used an anonymous IPP Print-Job.

What is the root cause?

The Type 1 font loader implements part of its work in PostScript, and one helper writes into protected font dictionaries with .forceput. The helper does not check its operand types before a string copy that can fail.

The vulnerable code is in Resource/Init/gs_fonts.ps at the 10.07.0 tag, lines 1026 to 1035:

% any user of .putgstringcopy must use bind and executeonly
/.putgstringcopy  %   <dict> <name> <string> .putgstringcopy -
{ 2 index gcheck currentglobal
  2 copy eq {
    pop pop .forceput
  } executeonly {
    5 1 roll setglobal
    dup length string copy
    .forceput setglobal
  } executeonly ifelse
} .forcebind odef % must be bound and hidden for .forceput

.putgstringcopy receives a dictionary, a name and a string. It compares the allocation mode of the dictionary with the current mode. When the two differ, it switches to global mode, allocates a copy of the string and calls .forceput.

The copy is the weak point. dup length string copy raises a typecheck error if the value on the stack is not a string. A document can reach this helper by registering a Type 1 font in Fontmap and calling findfont. The font's loading code runs while the loader's operands are on the stack, and it can replace the filename string with an array.

The error then reaches the document's own errordict handler. That handler pops the failing operands and leaves a chosen dictionary, key and value in their place. Execution resumes at the already-bound .forceput, and the following setglobal consumes the saved allocation-mode boolean.

psi/zgeneric.c makes that store stronger than a normal protected write. .forceput temporarily treats systemdict as local while it stores the value, then restores the dictionary's space flags. A local object can therefore be stored in a dictionary that survives a later restore.

That breaks the object-lifetime rule. A global dictionary now holds a reference to a local object. When restore frees the local space, the dictionary keeps a pointer into reclaimed storage. If the allocator reuses that block, the stale reference points at live interpreter data.

The researcher turned that into a native write-what-where primitive. On the tested 64-bit build, a Ghostscript ref is 16 bytes. The proof identifies an overlapping slot with marker integers, forges a string view over a live device pointer, walks the interpreter's own structures and changes a live operator reference. It then restores the original bytes.

The last step targets path_control_active, the native flag behind -dSAFER's file-path checks. Four put operations clear it. The proof also sets the PostScript PermitFileWriting list and the cached LockFilePermissions flag, then opens a %pipe% file and runs a command as the rendering process.

How is it exploited?

  1. The attacker builds a document that contains a Type 1 font and an error handler. The font's loading code arranges the loader stack so that copy fails on a non-string operand.
  2. The document reaches a Ghostscript build older than 10.08.0 through an upload, preview, import or print path.
  3. findfont loads the font. .putgstringcopy reaches the global-to-local branch and copy raises typecheck.
  4. The document's error handler discards the failing operands and supplies the dictionary, key and value for the pending .forceput.
  5. The recovered store puts a local object into a dictionary that survives restore. After the restore, the dictionary points at freed storage.
  6. The attacker reuses the freed block and obtains a native read and write primitive inside the renderer.
  7. The proof clears the native path-control flag and the PostScript file-writing controls, then runs a command through %pipe%.

The public proof of concept is a self-contained PostScript file. It writes its own Type 1 font to the %ram% device, triggers the flaw, changes a live mul reference to call sub, and restores the original bytes. On 10.07.0 it prints BEFORE=319, HIJACKED=18 and RESTORED=319. On 10.08.0 the dangling-reference lookup fails before the pointer write.

The application proofs show the same primitive behind ordinary features. An anonymous IPP job to a shared CUPS queue ran a command as lp on Debian 13. A Roundcube recipient who viewed a message ran a command as www-data without clicking the attachment. A signed-out visitor to a Forminator form and to an Elementor registration widget ran commands through the WordPress media pipeline.

How does the attack flow?

A crafted document reaches a Ghostscript build through an application's file-processing path. It recovers the privileged store through a type error, then turns the stale reference into native control of the sandbox flag.

flowchart LR A["Crafted PDF or EPS
with a Type 1 font"] --> B["Upload, preview,
print or import"] B --> C["Ghostscript loads
the font with findfont"] C --> D["copy raises typecheck
on a non-string operand"] D --> E["Document error handler
recovers .forceput"] E --> F["Local object stored in
a dictionary that survives restore"] F --> G["Freed block reused,
native read and write"] G --> H["Path-control flag cleared,
command runs as the renderer"]

What can an attacker do?

An attacker who can deliver a document to an affected renderer can run commands with the renderer's operating-system account. The account is often www-data, lp or an application service user. What the command can reach depends on that account and on the surrounding controls.

The impact needs all of these conditions:

  • The document reaches a Ghostscript build older than 10.08.0, either directly or through a library or converter.
  • The application processes the document, for example to make a thumbnail, extract metadata, convert it to PDF or print it.
  • The renderer runs as an account with access worth taking, or the host lacks a sandbox that blocks the next step.

The application proofs reached www-data on WordPress, MediaWiki and DokuWiki, lp on a Debian CUPS server, and a service user inside a Mayan EDMS container. The researcher also reported a signed-out path in Google's document pipeline, which Google mitigated on 2026-11-10. Those were authorized tests, not attacks on third parties.

No in-the-wild exploitation is known as of 2026-11-21, and CVE-2026-125396 is not in CISA KEV. A public proof demonstrates native memory control, so an attacker does not need to discover the primitive from scratch.

Why does the fix work?

The first fix validates the operands before the helper can fail. It wraps the original branch in a type check and raises a clean typecheck when the dictionary, name or string is not the expected type.

 /.putgstringcopy  %   <dict> <name> <string> .putgstringcopy -
-{ 2 index gcheck currentglobal
-  2 copy eq {
-    pop pop .forceput
-  } executeonly {
-    5 1 roll setglobal
-    dup length string copy
-    .forceput setglobal
-  } executeonly ifelse
+{
+  % Check operand types
+  dup type /stringtype eq 2 index type /nametype eq and 3 index type /dicttype eq and {
+    2 index gcheck currentglobal
+    2 copy eq {
+      pop pop .forceput
+    } executeonly {
+      5 1 roll setglobal
+      dup length string copy
+      .forceput setglobal
+    } executeonly ifelse
+  }
+  {
+      /.putgstringcopy cvx /typecheck signalerror
+  } ifelse
 } .forcebind odef % must be bound and hidden for .forceput

The check closes the error path that the document used to recover .forceput. A second commit moves the helper into C and removes its dependence on .forceput entirely. That change is hardening for the next case, and it landed after the 10.08.0 release.

The fix does not remove every use of privileged operators from Ghostscript. Artifex described the removal as work in progress. Treat 10.08.0 as the fixed floor for this flaw, not as the end of the class.

How do I check if I was compromised?

No indicators of compromise are published for CVE-2026-125396. The researcher's proofs wrote marker files with names chosen for the tests, so those names do not identify an attacker. A failed attempt may leave no trace.

Start with the version and the routes:

  1. Run the version checks in "Am I affected?" on every host and inside every container that processes documents.
  2. List the services that spawn Ghostscript: web uploads, thumbnailers, document converters, mail importers and print queues.
  3. Search upload and spool directories for documents that contain %pipe% or a Type 1 font with an embedded error handler.
  4. Review process logs for gs children spawned by a web or print service around unusual times.
  5. Check for files written by the renderer's account outside its normal output directories.
grep -R -l -a '%pipe%' /var/spool/cups /srv/uploads 2>/dev/null

A hit on %pipe% is a lead, not proof. Legitimate PostScript can use it. The version check is the reliable exposure test.

Timeline

The fix reached Ghostscript and several distributions before the CVE was assigned, and the public analysis arrived eight days after the CVE.

From discovery to public analysis, the fix shipped before the CVE was assigned
Figure 1: From discovery to public analysis, the fix shipped before the CVE was assigned. Source: pwn.ai, Artifex, Debian, Ubuntu and the CVE record, checked November 21, 2026

  • 2026-07-27: Paulos Yibelo discovers the Type 1 font-loader escape.
  • 2026-07-30: Google receives a production proof for its image and document pipeline.
  • 2026-08-12: WordPress 7.0.4 fixes CVE-2026-65640, the Author-level route into the renderer.
  • 2026-09-02: Artifex receives the report as bug 709684 and authors the fix.
  • 2026-09-08: Ghostscript 10.08.0 is released.
  • 2026-09-25: Debian publishes DSA-6516-1 for Debian 13.
  • 2026-10-21: Ubuntu publishes USN-8949-1 with fixed packages for seven releases.
  • 2026-11-09: CVE-2026-125396 is published.
  • 2026-11-17: pwn.ai publishes the technical analysis and the native-write proof of concept.

FAQ

Is Ghostscript only reachable through ImageMagick?

No. ImageMagick is one common route, and Pillow, libvips, CUPS and direct gs calls reach the same interpreter. The tested paths included PHP Imagick, Python Pillow and imageio, libvips, Qt's EPS plugin, CUPS and several document converters.

Does -dSAFER prevent the attack?

No. The flaw bypasses -dSAFER by clearing the native path-control flag and the PostScript file-writing controls in memory. The sandbox is the boundary the exploit crosses, not a mitigation for it.

Is the public proof a full remote exploit?

The published file demonstrates native memory control inside Ghostscript. It changes a live operator reference and restores it. The command-execution chain is described in the writeup, and the application case studies are being published separately.

Which applications were confirmed reachable?

The writeup lists Debian 13 CUPS, Roundcube, WordPress Core, Forminator, Essential Addons for Elementor, MediaWiki with PdfHandler, DokuWiki, Mayan EDMS, ResourceSpace and Plesk's Roundcube stack. It also maps source-level paths in Gradio, InvokeAI, Stable Diffusion WebUI, ComfyUI, Frappe, Home Assistant, CVAT, Paperless-ngx and django-filer.

Was it exploited in the wild?

No in-the-wild exploitation is known, and the CVE is not in CISA KEV as of 2026-11-21. The researcher's tests ran against the researcher's own systems and against production services with authorization.

What is the fixed version?

Ghostscript 10.08.0 is the upstream fix. Debian, Ubuntu and other distributions shipped backports, sometimes with older version numbers. Check the package version against your distribution's advisory, not only against 10.08.0.

Find the Ghostscript copies in your images with Ostorlab

Ghostscript often arrives inside an application image, not on the host you patched. Ostorlab's software composition analysis inventories the libraries and packages in your builds. It shows every image that still ships a vulnerable Ghostscript before the next upload reaches it: https://www.ostorlab.co/product/sca_sbom

References

  • pwn.ai, "How We Hacked the Pipes", Upload2Shell technical analysis: https://pwn.ai/upload2shell/research.html (checked November 21, 2026)
  • pwn.ai, Upload2Shell index and application paths: https://pwn.ai/upload2shell (checked November 21, 2026)
  • CVE-2026-125396 record: https://www.cve.org/CVERecord?id=CVE-2026-125396 (checked November 21, 2026)
  • Ghostscript fix commit 1484854e: https://github.com/ArtifexSoftware/ghostpdl/commit/1484854e0c8ddfda1baa4ad4cd965b8a9790aa81 (checked November 21, 2026)
  • Ghostscript follow-up commit e0421767: https://github.com/ArtifexSoftware/ghostpdl/commit/e0421767e13627e75055bb44cb01486887c2f9e8 (checked November 21, 2026)
  • Artifex bug 709684: https://bugs.ghostscript.com/show_bug.cgi?id=709684 (checked November 21, 2026)
  • Ghostscript 10.08.0 release: https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/tag/gs10080 (checked November 21, 2026)
  • Ghostscript 10.07.0 source, gs_fonts.ps: https://github.com/ArtifexSoftware/ghostpdl/blob/ghostpdl-10.07.0/Resource/Init/gs_fonts.ps (checked November 21, 2026)
  • Debian security tracker, CVE-2026-125396: https://security-tracker.debian.org/tracker/CVE-2026-125396 (checked November 21, 2026)
  • Ubuntu USN-8949-1: https://ubuntu.com/security/notices/USN-8949-1 (checked November 21, 2026)
  • WordPress 7.0.4 release: https://wordpress.org/news/2026/08/wordpress-7-0-4-release/ (checked November 21, 2026)
  • WordPress advisory GHSA-8vr3-7mxf-gx8w: https://github.com/WordPress/wordpress-develop/security/advisories/GHSA-8vr3-7mxf-gx8w (checked November 21, 2026)
  • Repology, 416 Ghostscript packages: https://repology.org/project/ghostscript/versions (checked November 21, 2026)
  • CISA Known Exploited Vulnerabilities catalog, version 2026.11.20: https://www.cisa.gov/known-exploited-vulnerabilities-catalog (checked November 21, 2026)